Createport not working with RapaGUI

Discuss GUI programming with the RapaGUI plugin here
Post Reply
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Createport not working with RapaGUI

Post by amyren »

I tried using CreatePort() in my program for the purpose of detecting if the program was ran twice.
But it fail to create a port at all, and triggers the error.
The errorname is "Unable to open Window"

Is there another option for this purpose when using RapaGUI?
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Createport not working with RapaGUI

Post by plouf »

example program from manual works here.

what os ? sample program with your problem ?
Christos
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Createport not working with RapaGUI

Post by amyren »

I run it on windows 10.

For a working example, open the RapaGUI Dialogs.hws example and put this piece of code just before the main loop.

Code: Select all

ExitOnError(False)
	CreatePort("TEST")
	code=GetLastError()
	If code<>0
			SystemRequest("Warning", "Program is already running", "OK",#REQICON_ERROR)
	EndIf
ExitOnError(True)
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Createport not working with RapaGUI

Post by plouf »

you are checking against ANY error and not if "port has failed"

a more propriety approach should be that way

Code: Select all

ExitOnError(False)

	CreatePort("TEST")

	code=GetLastError()
	If code=#ERR_PORTNOTAVAIL
		SystemRequest("Warning", "Program is already running", "OK",#REQICON_ERROR)
	EndIf
ExitOnError(True)
Christos
amyren
Posts: 352
Joined: Thu May 02, 2019 11:53 am

Re: Createport not working with RapaGUI

Post by amyren »

Thanks for the lesson, it led me to read a bit more about error codes:)

Unfortunately it still will not work. The problem is that GetLastError() will never get that specific error code, it returns the 1010 code instead. Which is "Unable to open window"

Code: Select all

ExitOnError(False)
	CreatePort("TEST")
	code=GetLastError()
	DebugPrint(code)
	If code=#ERR_PORTNOTAVAIL
		SystemRequest("Warning", "Program is already running", "OK",#REQICON_ERROR)
	EndIf
ExitOnError(True)
plouf
Posts: 462
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Createport not working with RapaGUI

Post by plouf »

unable to open window is an error BEFORE your check
this error trigerer BEFORE your check so its last error as long as no NEW error added and became the new "last"

try my example egain, create a executable with this code and execute it twice

Code: Select all

ExitOnError(False)

	CreatePort("TEST")

	code=GetLastError()
	If code=#ERR_PORTNOTAVAIL
		SystemRequest("Warning", "Program is already running", "OK",#REQICON_ERROR)
	EndIf
ExitOnError(True)
Repeat
	Wait(10)
Forever
Christos
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Createport not working with RapaGUI

Post by airsoftsoftwair »

CreatePort() needs RapaGUI 2.0. See here: viewtopic.php?f=10&t=3282
Post Reply