Where to read command$

Started by James Padgett, December 05, 2010, 09:56:41 AM

Previous topic - Next topic

James Padgett

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


Paul Squires

Paul Squires
PlanetSquires Software

Andrew Lindsay

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

James Padgett

In FF_AppSTart .. I can set %DEBUG to whatever I want ...

I was wanting to set it via command$ ...

Elias Montoya

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.
Win7, iMac x64 Retina display 5K, i7-5820K 4.4 ghz, 32GB RAM, All updates applied. - Firefly 3.70.

Paul Squires

Paul Squires
PlanetSquires Software

Peter House

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

James Padgett

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...