Minor scripting related wishes (a generic thread)
Re: Minor scripting related wishes (a generic thread)
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...
"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...
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Minor scripting related wishes (a generic thread)
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.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...
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...
Win11 Pro 223H2 Gerrman
Re: Minor scripting related wishes (a generic thread)
I took the concept of a Null constant name from other languages, where $c = Null; is possible. In JS:PeterH wrote:Now you want to specify a variable for a parameter, but wish it's meaning to be "nothing specified". No...
Code: Select all
var foo = null;
anyways let it go, i asked for it and Don said not possible now.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Minor scripting related wishes (a generic thread)
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;
}
FAQ | XY News RSS | XY Twitter
Re: Minor scripting related wishes (a generic thread)
I think both execute as expected I'd interpret the 1st case in another way: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; }
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".)
Win11 Pro 223H2 Gerrman
Re: Minor scripting related wishes (a generic thread)
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.SammaySarkar wrote:I took the concept of a Null constant name from other languages, where $c = Null; is possible. In JS:PeterH wrote:Now you want to specify a variable for a parameter, but wish it's meaning to be "nothing specified". No...maybe in XYscript lanuguage I should have said this instead $c = $Null where $Null is a special or defined variable whose value is empty.Code: Select all
var foo = null;
Win11 Pro 223H2 Gerrman
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Minor scripting related wishes (a generic thread)
I think I could do that. Whether it makes sense, well, that's a good question.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 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.
FAQ | XY News RSS | XY Twitter
Re: Minor scripting related wishes (a generic thread)
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!
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.
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!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Minor scripting related wishes (a generic thread)
Let's close the can before the worms come out.
FAQ | XY News RSS | XY Twitter
Re: Minor scripting related wishes (a generic thread)
@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...
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...
Win11 Pro 223H2 Gerrman
Re: Minor scripting related wishes (a generic thread)
Absolutely right. I wonder why I said that, and even extrapolated on that. My unthinkably embarrassing mistake. (Maybe a worm got out )PeterH wrote:set $a; doesn't return $a, it returns nothing
Thanks for the correction.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Minor scripting related wishes (a generic thread)
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.
Wish: a variable to hold full qualified path names in the destination.
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Minor scripting related wishes (a generic thread)
Good idea. Next version has this:
PS: Just saw it does not really work yet in 0003 ... wait...
Code: Select all
echo <get "targetitems">;
FAQ | XY News RSS | XY Twitter
Re: Minor scripting related wishes (a generic thread)
Yippee. Thanks. Time to optimize some scripts.
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Minor scripting related wishes (a generic thread)
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.
"url not found. error #0".
which in turn halts the script sequence.
It should first return a usable value instead.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...