$While with strings

Here you can discuss any topic concerning Far macro commands.
Locked
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

$While with strings

Post by jonib »

Hi

I need a while loop to loop as long as two strings are diffrent like this:
$While ( %string1 != %string2) do somthing $End

But it don't work for me, anyway to do this?
User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex »

jonib
I'm not an expert on macros but as far as I know it should work. Could you provide the full macro sequence?
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

This example works shows a message "Strings match":
Macro:Post $If ("String"=="String") msgbox("Test","Strings match",0) $Else msgbox("Test","Strings don't match",0) $End

This should show a message "Strings don't match" but nothing happens:
Macro:Post $If ("String"!="String") msgbox("Test","Strings match",0) $Else msgbox("Test","Strings don't match",0) $End

Only diffrens "==" and "!=".
HaRT
Posts: 100
Joined: Thu Mar 09, 2006 6:33 pm
Location: St. Petersburg, Russia

Post by HaRT »

Works perfectly.
What version of FAR (and of the FarCmds plugin) do you use?
User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex »

jonib
Works fine as HaRT said. If you tried to add this to the registry did you remember to escape each " character with \ - like this \" ?
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

t-rex wrote:jonib
Works fine as HaRT said. If you tried to add this to the registry did you remember to escape each " character with \ - like this " ?
I should have specified that I run the macro from "File associations".

Now I tested it from registry and commandline and it works but not from "File associations" :shock:
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

HaRT wrote:Works perfectly.
What version of FAR (and of the FarCmds plugin) do you use?
I use the "mantis97.1.rar" version that t-rex posted before and FarCmds from the last FAR relese.
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

I tested FAR ver 1.70 build 2087 on another PC and it's the same.
User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex »

jonib
What exactly do you write in the "File associations"?
Remember that !.! expands to something with backslashes and makes the macro inoperable.
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

t-rex wrote:jonib
What exactly do you write in the "File associations"?
Remember that !.! expands to something with backslashes and makes the macro inoperable.
Exactly like I wrote:
Macro:Post $If ("String"!="String") msgbox("Test","Strings match",0) $Else msgbox("Test","Strings don't match",0) $End
User avatar
t-rex
Admin
Posts: 417
Joined: Sun Mar 20, 2005 6:10 pm
Location: Ashdod
Contact:

Post by t-rex »

jonib
Well, ! is "Long file name without extension" in "File associations".

Write like this:

Macro:Post $If ("String"!!="String") msgbox("Test","Strings match",0) $Else msgbox("Test","Strings don't match",0) $End
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

t-rex wrote:jonib
Well, ! is "Long file name without extension" in "File associations".

Write like this:

Macro:Post $If ("String"!!="String") msgbox("Test","Strings match",0) $Else msgbox("Test","Strings don't match",0) $End
Doh! :oops: :shock: :? :lol:
jonib
Posts: 70
Joined: Thu Mar 31, 2005 3:00 am
Location: Sweden

Post by jonib »

If my last message was not clear it works now when I use "!!", I did not think of the special symbols in "File associations", but i'm still learning the more advanced macro stuff and forgot other stuff.
Locked