Page 22 of 28
Re: Minor scripting related wishes (a generic thread)
Posted: 21 Apr 2015 12:39
by bdeshi
Null if $c=Null was a constant like True False ...
"And I think it's not really neccessary as long as you can express the meaning of a non-specified operand by supplying the default value for this operand"I know, but asked because built-in functions already have default values defined. Redundundancy...
Re: Minor scripting related wishes (a generic thread)
Posted: 21 Apr 2015 21:45
by PeterH
SammaySarkar wrote:Null if $c=Null was a constant like True False ...
"And I think it's not really neccessary as long as you can express the meaning of a non-specified operand by supplying the default value for this operand"I know, but asked because built-in functions already have default values defined. Redundundancy...
But you know that TRUE/FALSE are *inside* the values of all possible strings: any string resolving to 0 is FALSE, any other string is TRUE.
And if you *set* TRUE or FALSE you just set 1 or 0. (Identical '1' or '0'.)
What you are looking for is a variable content saying "I'm no string". But this is outside the definition of a variable representing any string, including the nul string "".
But inside a function there can be tested: is a parameter specified or not - if not a default is used. Now you want to specify a variable for a parameter, but wish it's meaning to be "nothing specified". No...

Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 07:51
by bdeshi
PeterH wrote:Now you want to specify a variable for a parameter, but wish it's meaning to be "nothing specified". No...
I took the concept of a Null constant name from other languages, where $c = Null; is possible. In JS:
maybe in XYscript lanuguage I should have said this instead $c = $Null where $Null is a special or defined variable whose value is empty.
anyways let it go, i asked for it and Don said not possible now.
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 08:18
by admin
FYI: I checked this in PHP and AFAIK it does not offer a way to set a variable to a value that would be equivalent to omitting it:
Code: Select all
// test 1: error in line 3 ( echo test($b); ) ------------------------------------------
$b = "x";
unset($b);
echo test($b);
function test($a = "def") {
return $a;
}
// test 2: no error, line 3 echoes NULL
$b = "x";
$b = NULL;
echo test($b);
function test($a = "def") {
return $a;
}
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 11:39
by PeterH
admin wrote:FYI: I checked this in PHP and AFAIK it does not offer a way to set a variable to a value that would be equivalent to omitting it:
Code: Select all
// test 1: error in line 3 ( echo test($b); ) ------------------------------------------
$b = "x";
unset($b);
echo test($b);
function test($a = "def") {
return $a;
}
// test 2: no error, line 3 echoes NULL
$b = "x";
$b = NULL;
echo test($b);
function test($a = "def") {
return $a;
}
I think both execute as expected

I'd interpret the 1st case in another way:
You defined that an undefined var returns it's name as it's value - so it does

no error.
If you'd wish you
could change functions to interpret a non-defined (= non-initialized) var as "no parameter". [like isset()] But I don't think it would make sense.
(Overloading: uninitialized variable might be an error; but then also might be "no parameter meant".)
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 11:47
by PeterH
SammaySarkar wrote:PeterH wrote:Now you want to specify a variable for a parameter, but wish it's meaning to be "nothing specified". No...
I took the concept of a Null constant name from other languages, where $c = Null; is possible. In JS:
maybe in XYscript lanuguage I should have said this instead $c = $Null where $Null is a special or defined variable whose value is empty.
Could it be that in JS a variable has more states than in XY? I.e. that variables can also have a type, like string and integer? Then it's possible to define info outside the string-contents.
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 11:57
by admin
PeterH wrote:If you'd wish you could change functions to interpret a non-defined (= non-initialized) var as "no parameter". [like isset()] But I don't think it would make sense.
(Overloading: uninitialized variable might be an error; but then also might be "no parameter meant".)
I think I could do that. Whether it makes sense, well, that's a good question.
I could add more states to variables, also NULL. I'm the coder, I can do everything I want.

But is NULL the same as "omitted"? Not in the languages I have heard of.
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 13:26
by bdeshi
no not the same. "No value/omitted" would be prerreferred, because the concept of null is completely absent in xyscripting.
But I think it can cause too much trouble.
As it stands, introducing an empty value constant may be possible, but detecting this in one expression is not possible now afaik.
When a var is initialized but not given any value, it should logically have and return empty.
(instead of returning var name)
set $a;
this will have to convey that $a has no value. How? '' ? then how will it differ from $a = '';
?
And how to use this fact in expressions?
if ($a == ??) { echo '$a is really empty'; }
Mightn't this feature break compatibility (somehow) ?
hh, did I open a can of worms!
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 14:05
by admin
Let's close the can before the worms come out.
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 17:26
by PeterH
@Sammay: set $a; doesn't return $a, it returns nothing, also called an empty string - the same as $a='';
If you never did set $a, or unset $a; - then it is undefined and returns the string $a. (As if it were no variable, but just the string $a would be meant.)
In the end it seams you want a variable, but it should contain less than an empty string. I can't imagine...
Re: Minor scripting related wishes (a generic thread)
Posted: 22 Apr 2015 19:04
by bdeshi
PeterH wrote:set $a; doesn't return $a, it returns nothing
Absolutely right. I wonder why I said that, and even extrapolated on that. My unthinkably embarrassing mistake. (Maybe a worm got out

)
Thanks for the correction.
Re: Minor scripting related wishes (a generic thread)
Posted: 19 Jun 2015 23:03
by nerdweed
On file operations, the "Goto Last Target (Ctrl+Alt+F7), offers a nice functionality of taking to the last target as well as selecting the copied/moved files (even if they were renamed on collisions).
Wish: a variable to hold full qualified path names in the destination.
Re: Minor scripting related wishes (a generic thread)
Posted: 20 Jun 2015 12:24
by admin
Good idea. Next version has this:
PS: Just saw it does not really work yet in 0003 ... wait...
Re: Minor scripting related wishes (a generic thread)
Posted: 20 Jun 2015 22:59
by nerdweed
Yippee. Thanks. Time to optimize some scripts.
Re: Minor scripting related wishes (a generic thread)
Posted: 26 Jun 2015 20:12
by SkyFrontier
Sometimes readurl() pops a message:
"url not found. error #0".
which in turn halts the script sequence.
It should first return a usable value instead.