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?
Createport not working with RapaGUI
Re: Createport not working with RapaGUI
example program from manual works here.
what os ? sample program with your problem ?
what os ? sample program with your problem ?
Christos
Re: Createport not working with RapaGUI
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.
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)
Re: Createport not working with RapaGUI
you are checking against ANY error and not if "port has failed"
a more propriety approach should be that way
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
Re: Createport not working with RapaGUI
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"
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)
Re: Createport not working with RapaGUI
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
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
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Createport not working with RapaGUI
CreatePort() needs RapaGUI 2.0. See here: viewtopic.php?f=10&t=3282