Page 3 of 10
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 12:08
by PeterH
Next (I think)
Defaults for parameters are specified without quotes. If you use quotes they are part of the default value.
But: I need special characters, like blank or ')'
So I think defaults should should be quoted as every string?
By the way: if not defining a default, and not supplying a value for a variable, the default is ""?
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 12:15
by admin
1) Yep,
2) Yes, "".
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 12:16
by PeterH
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 12:24
by PeterH
By the way: you always write like:
! Scripting: Included functions were effectively not updated after loading a
script using User | Run Script | Load selected script file. Fixed.
I think people usually don't use
User | ... but
Scripting | Load Script File or
Scripting / Load Selected Script File.
User | ... is only defined if you have defined it
(and is there need for it, in this case?)
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 16:14
by admin
Whoops, what a stupid oversight.
I happen to have a UDC with that same name (just for testing).
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 18:00
by PeterH
Hoppala - for .317:
I wrote defaults as $b01='ol', i.e.used single quotes. The quotes were taken into the variables
With double quotes OK
(Should I stop testing?
No problem - I'm hungry now
)
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 18:37
by admin
No, you should stop using single quotes. They are not supported here.
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 19:09
by bdeshi
not good.
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 19:44
by PeterH
admin wrote:No, you should stop using single quotes. They are not supported here.
Is the emoticon you wanted to use:
As I don't think it makes sense this way!
Reason: you would have to teach new rules for this one case to all scripters:
- don't use 'single quotes'
- don't double double quotes inside double quotes (
)
not ="""c:\a b\""" but =""c:\a b\""
- maybe more? Please document!
Or use the rules valid for all other situations, like
global $a='"c:\a b\"'; // For me this is almost the same use case, isn't it?
So I hope it was a joke
(Thanks, Sammay
)
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 19:50
by admin
SammaySarkar wrote:not good.
good point
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 19:50
by admin
PeterH wrote:admin wrote:No, you should stop using single quotes. They are not supported here.
Is the emoticon you wanted to use:
As I don't think it makes sense this way!
Reason: you would have to teach new rules for this one case to all scripters:
- don't use 'single quotes'
- don't double double quotes inside double quotes (
)
not ="""c:\a b\""" but =""c:\a b\""
- maybe more? Please document!
Or use the rules valid for all other situations, like
global $a='"c:\a b\"'; // For me this is almost the same use case, isn't it?
So I hope it was a joke
(Thanks, Sammay
)
Yes, just added. It's the weather...
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 20:07
by PeterH
Weather, yes!
My feet hurt - I walked some km on the A33 (That's the German highway 33
) (between testing
)
(OK: this is a piece that's just on construction, so no problems with traffic.)
This says: weather in Germany is very fine
sunny, sunny, sunny
There's an emoticon
, but none for the sun
OK: I'll try
Sorry for OT
PS: just found out why you changed your mind: you thought about documenting the new rules
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 20:24
by admin
Yes.
Re: Scripting: User-Defined Functions
Posted: 12 Apr 2015 23:06
by PeterH
Tested, even some strange (= never used) parameter combinations: all well.
Not bad!
To be true: very very lucky. I've waited for this quite a time - and now it's there.
...and enjoyed testing
Thanks a lot!
And so many new abilities
Re: Scripting: User-Defined Functions
Posted: 13 Apr 2015 07:25
by bdeshi
Code: Select all
$b = 'var_$b';
echo q();
function q($a = "1" . "2" , $b) { return $a . | . $b ; } //returns 1" . "2|var_$b
Code: Select all
function q($a = """1" . """2" , $b) { return $a . | . $b ; } //returns "1" . "2"|var_$b