PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: James Padgett on December 05, 2010, 09:56:41 AM

Title: Where to read command$
Post by: James Padgett on December 05, 2010, 09:56:41 AM
I would like to read command$ so I can do this:

"myapp.exe debug"

IF command$ = "debug" THEN 
     %DEBUG = -1
ELSE
     %DEBUG = 0
END IF

Title: Re: Where to read command$
Post by: Paul Squires on December 05, 2010, 10:03:13 AM
I would do that in FF_WINMAIN.
Title: Re: Where to read command$
Post by: Andrew Lindsay on December 05, 2010, 10:06:45 AM
James,

The only issue with your code is that using %DEBUG is not a variable that can be set at run time.  You would need to use either a local or probably a global variable.

Andrew
Title: Re: Where to read command$
Post by: James Padgett on December 05, 2010, 11:14:02 AM
In FF_AppSTart .. I can set %DEBUG to whatever I want ...

I was wanting to set it via command$ ...
Title: Re: Where to read command$
Post by: Elias Montoya on December 05, 2010, 05:45:16 PM
I think what Andrew meant was that %DEBUG is not a variable, its an Equate (Constant), and those cannot be set (change its value) at run time. You would need a global variable, because the values of equates can only be set at compile-time.
Title: Re: Where to read command$
Post by: Paul Squires on December 05, 2010, 06:39:45 PM
Elias - exactly right.
Title: Re: Where to read command$
Post by: Peter House on December 05, 2010, 09:10:23 PM
You probably also want to use something like:

' Global Storage for Debug State
Global DebugMode as Long

' Position of Parameter in Command$
local ParamPos as Long

ParamPos = instr$(ucase$(Command$), "DEBUG")
If ParamPos > 0 then
' Debug Mode Set
   DebugMode = %True
Else
' Debug Mode Not Set
   DebugMode = %False
End If

So you can test for more than one command line option and possibly pass parameters.

Peter
Title: Re: Where to read command$
Post by: James Padgett on December 05, 2010, 10:44:12 PM
I'm only looking for one command$ item..  just to signal whether I want to enable ztrace statements or not.
If command$ = "debug" Then gztrace = -1
If gztrace = -1 then
    ztrace "my data is " & mydata
end if

So I only have to add  ' debug ' to the command line parameter in the project environment to enable ztrace output.

I guess if anyone else has problems I can also use the "debug" command$ to generate output for trouble shooting...