Page 3 of 10

Re: Scripting: User-Defined Functions

Posted: 12 Apr 2015 12:08
by PeterH
Next (I think) :bug:
:oops:

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 ')' :blackstorm:
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, :bug:

2) Yes, "".

Re: Scripting: User-Defined Functions

Posted: 12 Apr 2015 12:16
by PeterH
:D

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 :mrgreen:
(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. :oops: I happen to have a UDC with that same name (just for testing). :whistle:

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 :P
With double quotes OK :whistle:

(Should I stop testing? :biggrin:
No problem - I'm hungry now :P )

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: :wink:
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 ( :mrgreen: ) :arrow: 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 :wink:

(Thanks, Sammay :D )

Re: Scripting: User-Defined Functions

Posted: 12 Apr 2015 19:50
by admin
SammaySarkar wrote:not good.
good point :mrgreen:

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: :wink:
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 ( :mrgreen: ) :arrow: 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 :wink:

(Thanks, Sammay :D )
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 8) ) (between testing :whistle: )
(OK: this is a piece that's just on construction, so no problems with traffic.)

This says: weather in Germany is very fine :D sunny, sunny, sunny :D

There's an emoticon :blackstorm: , but none for the sun :cry:
OK: I'll try :idea:

Sorry for OT :biggrin:

PS: just found out why you changed your mind: you thought about documenting the new rules :appl: :ninja:

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 :D

Thanks a lot!
And so many new abilities :ugeek:

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