Discussion:
How do I check to see if an environment variable exists?
Stephen MacLean via use-livecode
2018-11-23 22:27:26 UTC
Permalink
Hi All,

Looking to see how I check to see if my standalone was launch via command line with a parameter?

I know that when it’s launched via command line with a parameter in windows, I will see a $0 (Name of executable) and $1 for the parameter.

Since this is a dual launch able app, double click and command line with parameter I have the following in the main stack:

on openStack

if exists($1) then

put $1 into pState

put "prod" into pMode

runBuildAndPush pState, pMode

end if

end openStack


However, the exists($1) never returns true, even when it should. Which leads to to believe that’s not what I want to use.

How would I test to see if the $1 variable exists?

TIA,

Steve MacLean
bob--- via use-livecode
2018-11-24 14:03:00 UTC
Permalink
$# tells you how many parameters there are for a script. Perhaps if $# > 0 then... instead might work (I’ve not tried that). You might find using environment() potentially helps as well. The Dictionary has the details. If neither of those options work let me know. I have another way you could tackle the issue.

- Bob Hall
Post by Stephen MacLean via use-livecode
However, the exists($1) never returns true, even when it should. Which leads to to believe that’s not what I want to use.
How would I test to see if the $1 variable exists?
J. Landman Gay via use-livecode
2018-11-24 16:35:28 UTC
Permalink
Post by Stephen MacLean via use-livecode
How would I test to see if the $1 variable exists?
I don't check for existence, I only check whether it's empty.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On November 24, 2018 8:04:50 AM bob--- via use-livecode
Post by Stephen MacLean via use-livecode
$# tells you how many parameters there are for a script. Perhaps if $# > 0
then... instead might work (I’ve not tried that). You might find using
environment() potentially helps as well. The Dictionary has the details. If
neither of those options work let me know. I have another way you could
tackle the issue.
- Bob Hall
On Nov 23, 2018, at 5:27 PM, Stephen MacLean via use-livecode
However, the exists($1) never returns true, even when it should. Which
leads to to believe that’s not what I want to use.
How would I test to see if the $1 variable exists?
_______________________________________________
use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-livecode
Stephen MacLean via use-livecode
2018-11-24 16:59:43 UTC
Permalink
Thanks all!

I am basically doing what Jacqueline does and check to see if empty and then verify against a list of switches.

It does seem strange that we can’t check for the existence of a variable, but this works.

Thanks,

Steve MacLean
Post by J. Landman Gay via use-livecode
Post by Stephen MacLean via use-livecode
How would I test to see if the $1 variable exists?
I don't check for existence, I only check whether it's empty.
--
HyperActive Software | http://www.hyperactivesw.com
Post by Stephen MacLean via use-livecode
$# tells you how many parameters there are for a script. Perhaps if $# > 0 then... instead might work (I’ve not tried that). You might find using environment() potentially helps as well. The Dictionary has the details. If neither of those options work let me know. I have another way you could tackle the issue.
- Bob Hall
Post by Stephen MacLean via use-livecode
However, the exists($1) never returns true, even when it should. Which leads to to believe that’s not what I want to use.
How would I test to see if the $1 variable exists?
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
http://lists.runrev.com/mailman/listinfo/use-livecode
Richard Gaskin via use-livecode
2018-11-25 06:47:53 UTC
Permalink
Post by Stephen MacLean via use-livecode
Looking to see how I check to see if my standalone was launch via
command line with a parameter?
I know that when it’s launched via command line with a parameter in
windows, I will see a $0 (Name of executable) and $1 for the
parameter.
...
Post by Stephen MacLean via use-livecode
How would I test to see if the $1 variable exists?
if "$1 is among the lines of the globalNames then ...

But that won't tell you if your app is running from the command line.

If the user double-clicks a document associated with your app, the OS
will pass the path to the document to the app in $1.

To determine if an app is running facelessly from the command line
(assuming you include -ui as an option with the command to bypass
loading the GUI), see the environment function:

if the environment is "command line" then ...
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
***@FourthWorld.com http://www.FourthWorld.com
Loading...