Help with code for switching the text? Anyone?
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Help with code for switching the text? Anyone?
For example
if text is = abc then switch it to xyz.
or
if text is = xyz the switch to abc.
Please help me with the code!
if text is = abc then switch it to xyz.
or
if text is = xyz the switch to abc.
Please help me with the code!
Re: Help with code for switching the text? Anyone?
No need to open Duplicates Threads when you open a Thread... (I've deleted the Duplicate.)manotop wrote:For example
if text is = abc then switch it to xyz.
or
if text is = xyz the switch to abc.
Please help me with the code!
CIM...! (Always mention your FCI when you open a Thread, read my Sig, many Commands are not implemented for all Browsers/Versions...)
For your Qt, yep, use 'EVAL()' + 'replace()'. (Many Examples on the Forum...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Help with code for switching the text? Anyone?
Sorry, i accidently made duplicate thread. BTW what does CIM and FCI stands for? I googled but found very odd abbreviations
Thanks for the hint!
Thanks for the hint!
chivracq wrote:No need to open Duplicates Threads when you open a Thread... (I've deleted the Duplicate.)manotop wrote:For example
if text is = abc then switch it to xyz.
or
if text is = xyz the switch to abc.
Please help me with the code!
CIM...! (Always mention your FCI when you open a Thread, read my Sig, many Commands are not implemented for all Browsers/Versions...)
For your Qt, yep, use 'EVAL()' + 'replace()'. (Many Examples on the Forum...)
Re: Help with code for switching the text? Anyone?
Hum, I googled as well "CIM + FCI + iMacros" and the first Hit is on the iMacros Forum and the second one on Stackoverflow, both with full explanation of what they mean...manotop wrote:Sorry, i accidently made duplicate thread. BTW what does CIM and FCI stands for? I googled but found very odd abbreviations
Thanks for the hint!
Searching the Forum for any Acronym would be even more "powerful", and reading 1 cm below this Post, => my Sig...!, even easier...
=> Search found 791 matches: CIM
=> Search found 662 matches: FCI
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Help with code for switching the text? Anyone?
I feel like a total noob right now
chivracq wrote:Hum, I googled as well "CIM + FCI + iMacros" and the first Hit is on the iMacros Forum and the second one on Stackoverflow, both with full explanation of what they mean...manotop wrote:Sorry, i accidently made duplicate thread. BTW what does CIM and FCI stands for? I googled but found very odd abbreviations
Thanks for the hint!
Searching the Forum for any Acronym would be even more "powerful", and reading 1 cm below this Post, => my Sig...!, even easier...
=> Search found 791 matches: CIM
=> Search found 662 matches: FCI
Script for replacing the text with condition?
I want to build a code for the form:
if text is = XYZ then switch it to ABC.
AND
if text is = XYZ then switch to ABC.
Please pay attention to the Script number 2:
Script number 1: Extract text line (this will get the text):
Script number 2: I found the below script on the forum but it only replaces the whole string and first of all it has no second condition and I am not sure how to implement it with this code below:
Script number 3: Add the texts:
P.S. I did some research and find out that I need to set some type of if else or true/false condition but I couldn't make it to work as I am not good at JavaScript.
I am using: Mac OS 10.11, FireFox iMacro 8.9.7, FireFox v48.02
if text is = XYZ then switch it to ABC.
AND
if text is = XYZ then switch to ABC.
Please pay attention to the Script number 2:
Script number 1: Extract text line (this will get the text):
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title EXTRACT=TXT
Code: Select all
SET !VAR2 EVAL("var extr2=\"{{!EXTRACT}}\"; extr2.replace(\"ABC\",\"XYZ\"); ")
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title CONTENT={{!VAR2}}
I am using: Mac OS 10.11, FireFox iMacro 8.9.7, FireFox v48.02
Re: Script for replacing the text with condition?
Maybe this code?
Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
Re: Script for replacing the text with condition?
First of all thanks for taking the time to reply.
For some reasons the code isnt working when I run it. Its not even replacing ABC to XYZ.
How about if the text is XYZ then switch it to ABC? Also please keep in mind that I want this to be run in one single code. Because if there are two separate codes it will replace ABC back to ABC (ABC > XYZ > XYZ > ABC) so I want to make sure that it doesnt run it twice. I hope you can understand. If you want more explanation please let me know.
Thanks again
For some reasons the code isnt working when I run it. Its not even replacing ABC to XYZ.
How about if the text is XYZ then switch it to ABC? Also please keep in mind that I want this to be run in one single code. Because if there are two separate codes it will replace ABC back to ABC (ABC > XYZ > XYZ > ABC) so I want to make sure that it doesnt run it twice. I hope you can understand. If you want more explanation please let me know.
Thanks again
iimfun wrote:Maybe this code?Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
Re: Script for replacing the text with condition?
Did you test in the following way?
Code: Select all
SET !EXTRACT "ABC"
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
PROMPT {{!VAR2}}
Re: Script for replacing the text with condition?
manotop wrote:I want to build a code for the form:
if text is = XYZ then switch it to ABC.
AND
if text is = XYZ then switch to ABC.
Please pay attention to the Script number 2:
Script number 1: Extract text line (this will get the text):
Script number 2: I found the below script on the forum but it only replaces the whole string and first of all it has no second condition and I am not sure how to implement it with this code below:Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title EXTRACT=TXT
Script number 3: Add the texts:Code: Select all
SET !VAR2 EVAL("var extr2=\"{{!EXTRACT}}\"; extr2.replace(\"ABC\",\"XYZ\"); ")
P.S. I did some research and find out that I need to set some type of if else or true/false condition but I couldn't make it to work as I am not good at JavaScript.Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title CONTENT={{!VAR2}}
I am using: Mac OS 10.11, FireFox iMacro 8.9.7, FireFox v48.02
iimfun wrote:Maybe this code?Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
manotop wrote:First of all thanks for taking the time to reply.
For some reasons the code isnt working when I run it. Its not even replacing ABC to XYZ.
How about if the text is XYZ then switch it to ABC? Also please keep in mind that I want this to be run in one single code. Because if there are two separate codes it will replace ABC back to ABC (ABC > XYZ > XYZ > ABC) so I want to make sure that it doesnt run it twice. I hope you can understand. If you want more explanation please let me know.
Thanks again
iimfun wrote:Maybe this code?Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
Hum..., @OP, good to see that you finally understood my Request to mention your FCI but there was no need to open a Duplicate Thread, you should have followed up and posted this Info (and your "more Info") in your Original Thread, so this current one will be merged with the Original one... and I won't try to help you anymore in the future... Good luck with @iimfun and other Advanced Users... (Sorry but I only help Users using the Forum a bit correctly... )iimfun wrote:Did you test in the following way?Code: Select all
SET !EXTRACT "ABC" SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';") PROMPT {{!VAR2}}
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: Script for replacing the text with condition?
So sorry about that I will pay attention to the forum rules next time.
chivracq wrote:manotop wrote:I want to build a code for the form:
if text is = XYZ then switch it to ABC.
AND
if text is = XYZ then switch to ABC.
Please pay attention to the Script number 2:
Script number 1: Extract text line (this will get the text):
Script number 2: I found the below script on the forum but it only replaces the whole string and first of all it has no second condition and I am not sure how to implement it with this code below:Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title EXTRACT=TXT
Script number 3: Add the texts:Code: Select all
SET !VAR2 EVAL("var extr2=\"{{!EXTRACT}}\"; extr2.replace(\"ABC\",\"XYZ\"); ")
P.S. I did some research and find out that I need to set some type of if else or true/false condition but I couldn't make it to work as I am not good at JavaScript.Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:newOffer ATTR=ID:add-title CONTENT={{!VAR2}}
I am using: Mac OS 10.11, FireFox iMacro 8.9.7, FireFox v48.02iimfun wrote:Maybe this code?Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
manotop wrote:First of all thanks for taking the time to reply.
For some reasons the code isnt working when I run it. Its not even replacing ABC to XYZ.
How about if the text is XYZ then switch it to ABC? Also please keep in mind that I want this to be run in one single code. Because if there are two separate codes it will replace ABC back to ABC (ABC > XYZ > XYZ > ABC) so I want to make sure that it doesnt run it twice. I hope you can understand. If you want more explanation please let me know.
Thanks again
iimfun wrote:Maybe this code?Code: Select all
SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';")
Hum..., @OP, good to see that you finally understood my Request to mention your FCI but there was no need to open a Duplicate Thread, you should have followed up and posted this Info (and your "more Info") in your Original Thread, so this current one will be merged with the Original one... and I won't try to help you anymore in the future... Good luck with @iimfun and other Advanced Users... (Sorry but I only help Users using the Forum a bit correctly... )iimfun wrote:Did you test in the following way?Code: Select all
SET !EXTRACT "ABC" SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';") PROMPT {{!VAR2}}
Re: Script for replacing the text with condition?
@iimfun u are a genius! It actually works!
BTW I am not sure if I am allowed to ask it out on the same post or not but I will ask you anyway as I have made a post on the forum a while back and nobody was able to answer it. Right now the last piece of this whole thing is I want the script to check which day is it and run/stop accordingly.
For example:
Check if the today is Monday or Wednesday or Friday if true Continue the script. Otherwise stop the script.
Thanks
BTW I am not sure if I am allowed to ask it out on the same post or not but I will ask you anyway as I have made a post on the forum a while back and nobody was able to answer it. Right now the last piece of this whole thing is I want the script to check which day is it and run/stop accordingly.
For example:
Check if the today is Monday or Wednesday or Friday if true Continue the script. Otherwise stop the script.
Thanks
iimfun wrote:Did you test in the following way?Code: Select all
SET !EXTRACT "ABC" SET !VAR2 EVAL("('{{!EXTRACT}}' == 'ABC') ? 'XYZ' : 'ABC';") PROMPT {{!VAR2}}
Re: Script for replacing the text with condition?
Play carefully this linemanotop wrote:For example:
Check if the today is Monday or Wednesday or Friday if true Continue the script. Otherwise stop the script.
Code: Select all
SET checkDay EVAL("var d = (new Date()).toString(); (d.match(/^(Mon|Wed|Fri)/)) ? 'CONTINUE' : MacroError(d + ' => STOP !');")
Re: Script for replacing the text with condition?
F*cking nice. I am also learning JS too. How much time do i have to spend to get to your level? I am learning from Treehouse and Codeacademy sites is it ok to learn from them or do you have a better recommendation?
iimfun wrote:Play carefully this linemanotop wrote:For example:
Check if the today is Monday or Wednesday or Friday if true Continue the script. Otherwise stop the script.Code: Select all
SET checkDay EVAL("var d = (new Date()).toString(); (d.match(/^(Mon|Wed|Fri)/)) ? 'CONTINUE' : MacroError(d + ' => STOP !');")
Re: Script for replacing the text with condition?
Well, learn JS by any tutorials that you like and just try to solve hard tasks. The progress depends mostly on your own efforts and sometimes on good advices. Good luck!