Can one call a program with a parameter
Moderator: Rathinagiri
Can one call a program with a parameter
Dear Mentors
If I want to run my program with a parameter that tells it what I want included this run,
is that supported in HMG.
Ex.
Myprogram <WithDiagnostics> // this time collect test data
Local lTest:= .F. // no unless asked for by WithDiagnostics parameter
.
.
.
if WithDiagnostics
lTest:=.T.
Endif
....later on
If lTest
... etc.
EndIf
If I want to run my program with a parameter that tells it what I want included this run,
is that supported in HMG.
Ex.
Myprogram <WithDiagnostics> // this time collect test data
Local lTest:= .F. // no unless asked for by WithDiagnostics parameter
.
.
.
if WithDiagnostics
lTest:=.T.
Endif
....later on
If lTest
... etc.
EndIf
- dragancesu
- Posts: 921
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Can one call a program with a parameter
See function PCOUNT()
Re: Can one call a program with a parameter
See my sample:
Code: Select all
function DebugMSG
local i
local cTemp := ""
cTemp := "Call point: "+ ProcName(1)+"(" + alltrim(str(ProcLine(1)))+")" + chr(10)
for i := 1 to pcount()
cTemp += "TYPE:" +valtype(hb_PValue(i))+" ->"+hb_valtoexp(hb_PValue(i)) + "<-"+chr(10)
next i
msgbox(cTemp, "Debug Informations" )
return
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Can one call a program with a parameter
Hi Bluebird,
I use this code for testing:
And this program will start on double click in your folder without parameters.
To start with paramters I use a little batchfile:
Serge
I use this code for testing:
Code: Select all
PUBLIC XINP_PARAM
IF PCOUNT() = 0
XINP_PARAM := 'P'
ELSE
XINP_PARAM := 'T'
MSGINFO('TEST!!!!!' ,'XINP_PARAM')
ENDIF
To start with paramters I use a little batchfile:
Code: Select all
START drive:\folder\program T
There's nothing you can do that can't be done...
Re: Can one call a program with a parameter
If you have only one parameter you can use:
Code: Select all
Function Main()
Para WithDiagnostics
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Can one call a program with a parameter
Hi Kryztof,
Can you please explain: Para WithDiagnostics
Where will input-parameter be stored and how to use it? This is completely new to me!
Thx, Serge
Can you please explain: Para WithDiagnostics
Where will input-parameter be stored and how to use it? This is completely new to me!
Thx, Serge
There's nothing you can do that can't be done...
Re: Can one call a program with a parameter
Hi Serge.
It's easy, like parameters in functions. When a program is calling with parameters, the defined variables receive the values of those parameters. If there are no parameters, the variable gets Nil.
Here is an example:
Same functionality but otherwise written:
Try running an exe without parameters, then with one, two, and three parameters, and you'll see that the variables get their values as character variables.
PS. You can use PARAMETER and PARA interchangeably.
Regards, Edward
It's easy, like parameters in functions. When a program is calling with parameters, the defined variables receive the values of those parameters. If there are no parameters, the variable gets Nil.
Here is an example:
Code: Select all
#include "hmg.ch"
Function Main()
PARAMETER FirstParameter, SecondParameter, ThirdParameter
MsgDebug ( FirstParameter, SecondParameter, ThirdParameter )
RETURN
Code: Select all
#include "hmg.ch"
Function Main( FirstParameter, SecondParameter, ThirdParameter )
MsgDebug ( FirstParameter, SecondParameter, ThirdParameter )
RETURN
PS. You can use PARAMETER and PARA interchangeably.
Regards, Edward
Re: Can one call a program with a parameter
Pls note that:
PARAMETETER variables have a scope equivalent to a PRIVATE variable
Variables within parenthesis eg: Main(param), have a scope equivalent to a LOCAL variable
So the PARAMETER sentence must be locate AFTER all local definitions.
HTH
Angel
PARAMETETER variables have a scope equivalent to a PRIVATE variable
Variables within parenthesis eg: Main(param), have a scope equivalent to a LOCAL variable
So the PARAMETER sentence must be locate AFTER all local definitions.
HTH
Angel
Angel Pais
Web Apps consultant/architect/developer.
Web Apps consultant/architect/developer.
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Can one call a program with a parameter
Thanks all!
Serge
Serge
There's nothing you can do that can't be done...