Hi'
Back online (for a short time), so I tought I'd help a bit...
Code: Select all
if $var » determines if a variable is different from zero
if isset($var) » determines if a variable has been declared (with or without content)
---------------------------
if $var{} // true — because $var = "$var" !
set $var; if $var{} // false — because $var = 0
$var=0; if $var{} // false — because $var = 0
$var=1; if $var{} // true — because $var different from 0
if isset($var){} // false — because $var hasn't been declared
set $var; if isset($var){} // true — because $var has been declared
$var=0; if isset($var){} // true — because $var has been declared
$var=1; if isset($var){} // true — because $var has been declared
I looked into my scripts to find some "real life" uses of
isset(), so here are two (stripped down) examples.
isset() used to check the existence of a permanent variable:
Code: Select all
if !isset($p_VirtualDrive) {
action("mount drive");
perm $p_VirtualDrive;
$p_VirtualDrive = get("drives", 5);
} else {
action("unmount drive");
unset $p_VirtualDrive;
}
isset() used "internally" to check if an action has been done:
Code: Select all
foreach($CurrentItem, $list) {
if ($CurrentItem == $PreviousItem) {
action("Do something");
$i++;
}
$PreviousItem = $CurrentItem
}
if isset($i) {
msg "$i duplicate items processed";
}
------------------------------------------------------
So in in your script, you could just use:
if $ea_path {}, which would give
(note: I fixed the missing "XY" in some $parentdir):
Code: Select all
" Run Program 1|:refresh : THUMB_REFRESH"
global $XYparentDir, $ea_path;
$XYparentDir = "<xypath>";
sub "_MESSAGE"; end 1;
" Run Program 2|:refresh : THUMB_REFRESH"
global $XYparentDir, $ea_path;
$ea_path = "<xyscripts>";
sub "_MESSAGE"; end 1;
"_MESSAGE";
global $XYparentDir, $ea_path;
if $ea_path {$test_folder = $ea_path; }
else {$test_folder = $XYparentDir; }
text "If Run Program 1, Variable ea_path was not set, test_folder<crlf>below should be XYpath, not XYscripts.<crlf 2>Test Folder: $test_folder";
[/size]Still, a gettoken() on the caption can be a valid alternative if you'd rather avoid using global variables for whatever reason.
Hope this helps.
Have a nice day,
Flux