Page 1 of 1

best way to check function and program called

PostPosted: Sat Mar 18, 2017 2:20 pm
by damianodec
hi to all
I have my MYPROG.EXE, in this program I have this choiche on menu...
Code: Select all  Expand view

function BuildMenu()
   local oMenu
    MENU oMenu
        MENUITEM "Ricerca"
        MENU
            MENUITEM "Trova articoli" ACTION ricerc() ;
                MESSAGE "trova articoli"
            MENUITEM "Articoli in ordine" ACTION ordini() ;
                MESSAGE "Articoli in ordine"
 

Action Ricerc() start and open one nowait dialog.
1. How can I to check if ricerc() is already active ?
2. How can I stopped If users run another time MYPROG.EXE?

ciao
Damiano

Re: best way to check function and program called

PostPosted: Sat Mar 18, 2017 2:27 pm
by Enrico Maria Giordano
damianodec wrote:1. How can I to check if ricerc() is already active ?


You can use a flag. Set it to .T. just before the DEFINE DIALOG and to .F. in the dialog's VALID clause.

damianodec wrote:2. How can I stopped If users run another time MYPROG.EXE?


Use something like this:

Code: Select all  Expand view
IF ISEXERUNNING( CFILENOEXT( HB_ARGV( 0 ) ) )
    // EXE already executing
    RETURN NIL
ENDIF


EMG

Re: best way to check function and program called

PostPosted: Sat Mar 18, 2017 2:30 pm
by damianodec
hi Enrico, thank you for reply
You can use a flag. Set it to .T. just before the DEFINE DIALOG and to .F. in the dialog's VALID clause.

can you show me any example?

thank you

Re: best way to check function and program called

PostPosted: Sat Mar 18, 2017 2:44 pm
by Enrico Maria Giordano
No, sorry. But you can do something like this:

Code: Select all  Expand view
lFlag = .T.

DEFINE DIALOG oDlg...

...

ACTIVATE DIALOG oDlg;
    VALID lFlag := .F.;
    NOMODAL


EMG