function Pos(Substr: string; S: string): Integer
Moderators: JRL, Dorian (MJT support)
function Pos(Substr: string; S: string): Integer
I have exhausted all combinations of possible VALID parameters in vain. Has anyone succeeded in calling the function? Please help. Thanks.
For example, Let>h={Pos(AW,PC_AW)} will fail.
For example, Let>h={Pos(AW,PC_AW)} will fail.
As per the documentation variables in complex expressions must be encased in % symbols (otherwise the complex expression parser is unable to determine that they are variables):
Let>AW=R
Let>PC_AW=FRED
Let>h={Pos(%AW%,%PC_AW%)}
H becomes 2.
Let>AW=R
Let>PC_AW=FRED
Let>h={Pos(%AW%,%PC_AW%)}
H becomes 2.
MJT Net Support
[email protected]
[email protected]
Or, if you meant these to be literal strings then, again, as the documentaion says, be sure to quote strings with double quote char:
Let>h={Pos("AW","PC_AW")}
h would equal 4
Let>h={Pos("AW","PC_AW")}
h would equal 4
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Good clarification. Would be good examples to include in the Help documentation.
(See User Defined Help).
(See User Defined Help).
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
The semicolon is used in the function definition to separate different items. E.g.:
function Copy(S: string; Index, Count: Integer): string
Note that Index and Count are separated by a comma. S is separated from the rest by a semicolon because it is a string. These function definitions include the type too. The definition for Pos is :
function Pos(Substr: string; S: string): Integer
And could equally have been written:
function Pos(Substr, S: string): Integer
This format is quite common in program language documentation to define the function but I concede that it is a departure from basic syntax used in Macro Scheduler's help for regular commands. Due to the nature of complex expressions we used this more standardised syntax for the documentation. Perhaps we should add a paragraph to further explain what this all means.
In short:
1) Always use a comma between variables in the actual program code.
2) In complex expressions use quote markes ("..") around strings.
3) In complex expressions Use % symbols around variables.
You can see why it is important to distinguish between strings and numerics in the documentation for complex expressions. This has not been necessary for regular commands. Since there is a need to distinguish between type the function definitions get a little more complex and it could be far more confusing if only commas were used.
Sorry for the confusion. It gets harder and harder to write documentation that everyone can understand all the time.
We are, and have always been, open to offers from anyone who thinks they could do a better job, but no offers have ever been forthcoming.
[/b]
function Copy(S: string; Index, Count: Integer): string
Note that Index and Count are separated by a comma. S is separated from the rest by a semicolon because it is a string. These function definitions include the type too. The definition for Pos is :
function Pos(Substr: string; S: string): Integer
And could equally have been written:
function Pos(Substr, S: string): Integer
This format is quite common in program language documentation to define the function but I concede that it is a departure from basic syntax used in Macro Scheduler's help for regular commands. Due to the nature of complex expressions we used this more standardised syntax for the documentation. Perhaps we should add a paragraph to further explain what this all means.
In short:
1) Always use a comma between variables in the actual program code.
2) In complex expressions use quote markes ("..") around strings.
3) In complex expressions Use % symbols around variables.
You can see why it is important to distinguish between strings and numerics in the documentation for complex expressions. This has not been necessary for regular commands. Since there is a need to distinguish between type the function definitions get a little more complex and it could be far more confusing if only commas were used.
Sorry for the confusion. It gets harder and harder to write documentation that everyone can understand all the time.
We are, and have always been, open to offers from anyone who thinks they could do a better job, but no offers have ever been forthcoming.
[/b]
MJT Net Support
[email protected]
[email protected]
Just in case you have missed the correct section in the documentation, info on Complex Expressions can be found here:
http://www.mjtnet.com/OnlineHelp/index. ... ssions.htm
(identical to what is in the help file). Note the very first paragraph:
"In Macro Scheduler all complex functions should be contained within curly braces ("{" and "}"). Variables should be enclosed within % symbols and literal strings should be enclosed within double quotes ("). "
I have made a note to add a sentence to the effect that parameters must be separated by commas.
http://www.mjtnet.com/OnlineHelp/index. ... ssions.htm
(identical to what is in the help file). Note the very first paragraph:
"In Macro Scheduler all complex functions should be contained within curly braces ("{" and "}"). Variables should be enclosed within % symbols and literal strings should be enclosed within double quotes ("). "
I have made a note to add a sentence to the effect that parameters must be separated by commas.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Please see my earlier reference to User Defined Help.We are, and have always been, open to offers from anyone who thinks they could do a better job, but no offers have ever been forthcoming.
This would allow each of us to provide our own examples using script lines that are meaningful to our own applications. Takes some of the burden off your back to write something that everyone can understand. We could then provide ourselves with the interpretation that makes sense to us.
In all fairness though, most of the Help documentation is well done. Thanks for the hard efforts to please all of us.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
This is a good idea. We're eagerly (nervously?) awaiting the Longhorn beta, within which is an entirely new XML based help system which may offer a nice way to do this. To avoid potential rework we will wait until we have reviewed this thoroughly before changing the current help system.
MJT Net Support
[email protected]
[email protected]
2 more last questions on Complex Expressions:
1. Do Complex Expressions support Macro Scheduler ARRAY, both a whole array and an element?
For example, is it a valid Complex Expressions: Let>h={Pos("AW",USERS[1])} ?
By whole array, I mean operations such as sum and average on ALL elements in an array.
2. Any sample script for function If(Condition: Boolean, TrueResult, FalseResult): ResultType ?
1. Do Complex Expressions support Macro Scheduler ARRAY, both a whole array and an element?
For example, is it a valid Complex Expressions: Let>h={Pos("AW",USERS[1])} ?
By whole array, I mean operations such as sum and average on ALL elements in an array.
2. Any sample script for function If(Condition: Boolean, TrueResult, FalseResult): ResultType ?
Yes, on elements:armsys wrote:1. Do Complex Expressions support Macro Scheduler ARRAY, both a whole array and an element?
For example, is it a valid Complex Expressions: Let>h={Pos("AW",USERS[1])} ?
By whole array, I mean operations such as sum and average on ALL elements in an array.
Let>User[1]=ARMSTRONG
Let>User[2]=BOB
Let>User[3]=CYBERCITIZEN
Let>h={Pos("E",%User[3]%)}
No, not on whole arrays.
Let>User[3]=CYBERCITIZENarmsys wrote:2. Any sample script for function If(Condition: Boolean, TrueResult, FalseResult): ResultType ?
Let>h={Pos("E",%User[3]%)}
Let>x={if(%h%>0,"yes","no")}
This sets x to yes if E appears in User[3]. Clearly in the case above E appears in CYBERCITIZEN so it's position is positive. Therefore in the if line x is set to yes. x would equal no if User[3] was set to a value that did not contain an E.
MJT Net Support
[email protected]
[email protected]
Hi Support,
Now it's perfectly clear. Prior your revelation, no one in the entire universe could have deciphered correctly that Let>h={Pos("E",%User[3]%)} is a valid complex expression.
BTW, I'm also surprised by my discovery of an undocumented feature. While experimenting new functions and commands in Macro Scheduler, I found that, for example, Goto>Array[3] is supported by Macro Scheduler.
Thanks a lot. Happy Chinese New Year!
Now it's perfectly clear. Prior your revelation, no one in the entire universe could have deciphered correctly that Let>h={Pos("E",%User[3]%)} is a valid complex expression.
BTW, I'm also surprised by my discovery of an undocumented feature. While experimenting new functions and commands in Macro Scheduler, I found that, for example, Goto>Array[3] is supported by Macro Scheduler.
Thanks a lot. Happy Chinese New Year!
I dearly hope that isn't the case. I have already pointed you in the direction of the documentation which states clearly:armsys wrote:Now it's perfectly clear. Prior your revelation, no one in the entire universe could have deciphered correctly that Let>h={Pos("E",%User[3]%)} is a valid complex expression.
"In Macro Scheduler all complex functions should be contained within curly braces ("{" and "}"). Variables should be enclosed within % symbols and literal strings should be enclosed within double quotes (")."
So let's look at the example again:
Let>h={Pos("E",%User[3]%)}
Ok, we have curly braces around it. Good, that's what the documentation says. E is a literal string so it is enclosed in quotes as the help says. User[3] is a Macro Scheduler variable. So we'll put it in % symbols as the documentation says. Excellent. What am I missing?
MJT Net Support
[email protected]
[email protected]