pos function question
Moderators: Dorian (MJT support), JRL
pos function question
Maybe a beginners question:
Why is
Let>UseAltS={ If( Pos("-UseAltS", %COMMAND_LINE%) = 0 , 0, 1) }
always giving me a "Incorrectly formed Parameters" Message (twice) and then a "Error Parsing Expression"?
Why is
Let>UseAltS={ If( Pos("-UseAltS", %COMMAND_LINE%) = 0 , 0, 1) }
always giving me a "Incorrectly formed Parameters" Message (twice) and then a "Error Parsing Expression"?
Well the answer to your exact question is: Because it's an incorrectly formed expression.
If I break down what you've put:
Let>UseAltS={ If( Pos("-UseAltS", %COMMAND_LINE%) = 0 , 0, 1) }
Pos("-UseAltS", %COMMAND_LINE%) should return an integer
to:
Let>UseAltS={ If( interger = 0 , 0, 1) }
Then perhaps you can see why this is incorrect. Are you trying to use an "if" command, and send it to a label called "0" if the result is 0, and "1" otherwise? If so, it shouldn't be on the right side of a "Let>" command.
What exactly are you trying to assign to the variable "UseAltS" ?
If I break down what you've put:
Let>UseAltS={ If( Pos("-UseAltS", %COMMAND_LINE%) = 0 , 0, 1) }
Pos("-UseAltS", %COMMAND_LINE%) should return an integer
to:
Let>UseAltS={ If( interger = 0 , 0, 1) }
Then perhaps you can see why this is incorrect. Are you trying to use an "if" command, and send it to a label called "0" if the result is 0, and "1" otherwise? If so, it shouldn't be on the right side of a "Let>" command.
What exactly are you trying to assign to the variable "UseAltS" ?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Ignoring other syntax issues, you should also be careful not to put unwanted space characters before/after commas, equal signs, etc. when defining parameters.
This:
Macro Scheduler is very literal when it comes down to compiling the command lines. It assumes that spaces are intentional and they become part of the elements when the lines are parsed and compiled.
This:
is probably wrong, and not the same as this:Let>UseAltS={ If( Pos("-UseAltS", %COMMAND_LINE%) = 0 , 0, 1) }
which is probably more correct.Let>UseAltS={If(Pos("-UseAltS",%COMMAND_LINE%)=0,0,1)}
Macro Scheduler is very literal when it comes down to compiling the command lines. It assumes that spaces are intentional and they become part of the elements when the lines are parsed and compiled.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Folks,
Many thanks for your efforts. Only, It's not really solving the question or I am just not getting it.
The story behind the problem is: My macro helps me on my home and my office machine. At home, I have to use an alternative way to make my application do, what I want by using a number of ALT-S keystrokes instead of a mouse action. To be able to use the same macro in both environments, I intended to use the command line. If my command line for the exe version of the macro would be "c:\mymacro.exe -UseAltS", I could assign the value 1 (integer) to my variable UseAltS and later in the code do a conditional jump (the latter already works).
So, what I assumed to be codeing was based on the understanding that Pos("-UseAltS", %COMMAND_LINE%) does return an integer of 0 if the string "-UseAltS" was not on the command line and any value larger that 0 if it was.
Does that help someone to help me out?
Kidada
Many thanks for your efforts. Only, It's not really solving the question or I am just not getting it.
The story behind the problem is: My macro helps me on my home and my office machine. At home, I have to use an alternative way to make my application do, what I want by using a number of ALT-S keystrokes instead of a mouse action. To be able to use the same macro in both environments, I intended to use the command line. If my command line for the exe version of the macro would be "c:\mymacro.exe -UseAltS", I could assign the value 1 (integer) to my variable UseAltS and later in the code do a conditional jump (the latter already works).
So, what I assumed to be codeing was based on the understanding that Pos("-UseAltS", %COMMAND_LINE%) does return an integer of 0 if the string "-UseAltS" was not on the command line and any value larger that 0 if it was.
Does that help someone to help me out?
Kidada
It seems the If>{Pos(...)} expression always returns false.
The following appears to work, although during debugging I would regularlly get an error when using COMMAND_LINE.
Let>nPos={Pos("-UseAltS",%COMMAND_LINE%)}
If>nPos=0
Let>UseAltS=0
Else
Let>UseAltS=1
EndIf
May I suggest you check out the ability to use the command line like this:
/USEALTS=1
Then in your code, the variable %USEALTS% will already be assigned to 1
(You can then probably add a few lines like)
Assigned>USEALTS,WasParamGiven
If>%WasParamGiven%=FALSE
Let>USEALTS=0
EndIf
The following appears to work, although during debugging I would regularlly get an error when using COMMAND_LINE.
Let>nPos={Pos("-UseAltS",%COMMAND_LINE%)}
If>nPos=0
Let>UseAltS=0
Else
Let>UseAltS=1
EndIf
May I suggest you check out the ability to use the command line like this:
/USEALTS=1
Then in your code, the variable %USEALTS% will already be assigned to 1
(You can then probably add a few lines like)
Assigned>USEALTS,WasParamGiven
If>%WasParamGiven%=FALSE
Let>USEALTS=0
EndIf
Or do:
Let>p={Pos("-UseAltS",%COMMAND_LINE%)}
If>p>0
etc
Else
etc
Endif
Or:
Position>-UseAltS,COMMAND_LINE,1,p
If>p>0
etc
Or the If line can be:
If>{%p% > 0}
Let>p={Pos("-UseAltS",%COMMAND_LINE%)}
If>p>0
etc
Else
etc
Endif
Or:
Position>-UseAltS,COMMAND_LINE,1,p
If>p>0
etc
Or the If line can be:
If>{%p% > 0}
MJT Net Support
[email protected]
[email protected]
Captive, thank's a lot! Using /USEALTS did work. Where is that documented? Even now knowing about it I could not find it.Captive wrote:
It seems the If>{Pos(...)} expression always returns false.
...
May I suggest you check out the ability to use the command line like this:
/USEALTS=1
EndIf
>> It seems the If>{Pos(...)} expression always returns false.
Is that a bug in MS?
Kidada
Command Line (Command line options) ...Kidada wrote: Captive, thank's a lot! Using /USEALTS did work. Where is that documented? Even now knowing about it I could not find it.
Nope. There's nowhere that even suggests If() will work as a function inside a complex expression.Kidada wrote:>> It seems the If>{Pos(...)} expression always returns false.
Is that a bug in MS?
Thank's Again. As my impressions of the tool are very fresh and I had this problem, I would like to suggest to more clearly separate the documentation between the "programmers docs" and the "how to use, install and register the application MS as such". There are several references to the MS application, which deal with simmilar topics, relevant for development. Would have helped me.Captive wrote:Command Line (Command line options) ...Kidada wrote: Captive, thank's a lot! Using /USEALTS did work. Where is that documented? Even now knowing about it I could not find it.
And just that you get me right -- MS is a very noice tool.
Kidada