EVAL When another function is activated

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
Post Reply
GUTAO
Posts: 15
Joined: Sun May 10, 2015 7:52 am

EVAL When another function is activated

Post by GUTAO » Fri Oct 12, 2018 10:46 am

Version 12.0.501.6698
Sistema windows 7 português
Internet Explorer 9


Personally I know imacros at one time but I use very little and would like help with the following question ...
I want the macro to find a certain data on the page ignore all the rest of the code, return to the beginning of the execution or skip to the next execution. I read a lot and believed that the EVAL function could solve this, but I could not make it work. Thank you very much in advance.

follow the code:

TAB CLOSEALLOTHERS
SET !DATASOURCE guto.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=
FRAME NAME=principal
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:Cadastro
TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante
ONDIALOG POS=1 BUTTON=YES
ONDIALOG POS=2 BUTTON=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidadeText CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=SELECT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidade CONTENT=%*~*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:codNet CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:PesquisaAssinanteForm ATTR=NAME:btoPesquisa
TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"\";} else {var x=\"https://www.youtube.com\";} x;")
SET !TIMEOUT_STEP 0
Last edited by GUTAO on Tue Nov 09, 2021 10:04 pm, edited 2 times in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL Com acionamento de outra função

Post by chivracq » Fri Oct 12, 2018 4:10 pm

GUTAO wrote:

Code: Select all

Version 12.0.501.6698
Sistema windows 7 português
Internet Explorer 9
Pessoal sou bem novo no imacros e gostaria de uma ajuda com a seguinte questão... Desejo que a macro ao encontrar um determinado dado na pagina ignore todo o restante do código, retorne ao inicio da execução ou pule para a próxima execução, tipo esta executando na vez numero 10 ao encontrar esse dado ignore tudo e pule para a 11. Não coloquei o código todo porque ficou muito grande. A linha do SET !VAR2 EVAL no código encontrei na internet porem não consigo fazer a alteração para ignorar todo restante do código.

Segue codigo:

Code: Select all

TAB CLOSEALLOTHERS
SET !DATASOURCE guto.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=https://netsales.netservicos.com.br/NETSales/
FRAME NAME=principal
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:Cadastro
TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante
ONDIALOG POS=1 BUTTON=YES
ONDIALOG POS=2 BUTTON=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidadeText CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=SELECT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidade CONTENT=%*~NETSALES_BASE_*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:codNet CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:PesquisaAssinanteForm ATTR=NAME:btoPesquisa
TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"https://netsales.netservicos.com.br/NETSales/\";} else {var x=\"https://www.youtube.com\";} x;")
SET !TIMEOUT_STEP 0
Pfff..., Forum Language is ENGLISH...! :roll:

Nice to see that you (finally) mention your FCI, but hum, are you sure about IE9...? I thought iMacros for IE v12.0 only worked from IE10, and even preferably IE11...

Funniest Thread of the Month until now with your "I'm new to iMacros...", LOL, ah-ah-ah...! :lol:

Hum, your previous Thread is still waiting for some some Follow-up from your Side, more than 1 year later... You'll first need to finish that one "a bit correctly" for me to help you on this current one... And, pfff..., last time I ask, it's not the first time you don't follow up on your Threads... :roll:
- (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...
GUTAO
Posts: 15
Joined: Sun May 10, 2015 7:52 am

Re: EVAL Com acionamento de outra função

Post by GUTAO » Fri Oct 12, 2018 4:25 pm

I'm sure about internet explorer 9, in all the tests I did for the macros I run was the fastest.

I have a time of imacros but I am not a programmer so my knowledge is very little and when I need to do something
besides my knowledge I try to find the solution in the forum more for my current problem I could not solve.

With regard to my topic antogo I do not know what I need to do can you tell me please?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL Com acionamento de outra função

Post by chivracq » Fri Oct 12, 2018 5:23 pm

GUTAO wrote:I'm sure about internet explorer 9, in all the tests I did for the macros I run was the fastest.

I have a time of imacros but I am not a programmer so my knowledge is very little and when I need to do something
besides my knowledge I try to find the solution in the forum more for my current problem I could not solve.

With regard to my topic antogo I do not know what I need to do can you tell me please?
Hum, OK about IE9. I thought v12.0 didn't even work on IE9...

"I have a time...", yeah, after 3.5 years using iMacros, you definitely "have a time", ah-ah...! That doesn't qualify for "I'm new" anymore, ah-ah...!. a bit like Madonna singing "I'm a Virgin...!", ah-ah...! 8)
And you don't need to be a "Programmer" to do "interesting Things" with iMacros if you read a bit of the Documentation, search the Forum a bit, and "try" a few "Things" by yourself... But OK, never mind...

Well, about your "antigo" [sic...!] = "previous" Thread... "Follow-up" means "Follow-up"...! You ask a Qt on a Tech Forum, sbd (=me) answers, => you follow up...!, by replying..., answering Qt's if I asked any, reacting to the Suggestions I gave you, and sharing your Solution in the end, of course..., for other Users searching the Forum with a similar Qt/Pb/Scenario and that might be interested by the Sol...! :roll:
Well, your "Problem" if you've been too "lazy" in those 3.5 years to improve a bit your Knowledge about iMacros, I don't really care in a way, but if you ask a Qt on the Forum, I reply with Qt's and/or Suggs/Sol(s), and you don't bother to follow up and to share your Sol, then that's usually a "Show-Killer" for me and I won't waste any time trying to help you a next time... Tja...! :roll:

:arrow: And are you going to convert/translate your OP in this Thread to ENGLISH...!? (And don't forget the Thread Title as well...!) :roll:
And if you are going to use Google Translate or some Translating Service, use short and clear Sentences, your long Sentence for example about "10" and "11" doesn't make sense to me using Google Translate (to English)... :idea:
- (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...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL Com acionamento de outra função

Post by chivracq » Sat Oct 13, 2018 5:08 pm

Hum, FYI (and for mine as well actually, ah-ah...!), I've asked the Forum Admin for "Advice" about Threads in other Languages than English, if he could "rule" about that..., as there is actually nothing mentioned in the Forum Rules about English being the Forum Language, so maybe it's completely OK to post in any Language... :?
I know in the "past", several Threads were posted in German (and even answered in German as well by TechSup), + a few as well in Spanish and even Russian I think...

All I can say "for myself", even if I speak several Languages fluently, is that I will "refuse" to answer those Threads... (And I'm the most "active" Helper on the Forum...) :!:
When I answer a Thread, I don't answer "only" for the @OP, but for the whole iMacros Forum Community, and thus for "other" Users as well searching the Forum with a similar Qt/Pb/Case/Scenario..., and looking for a Solution... :idea:
It is already "complicated" enough to use English to search the Forum, it will become a complete "Nightmare" if Users then need to repeat their Search in 5 or 10 different Languages, with approx Translations of Keywords... :shock:

OK, this is my "Opinion", you do what you want with it... If you don't want to translate your OP, fair enough..., we'll see what the Forum Admin "thinks", and good luck with other (Advanced) Users willing to answer your Thread... :|
(There is ONE Brazilian Advanced User on the Forum, but he only answers a few Threads (1 easy one in each Sub-Forum) when sbd posts a Paid-Job in the 'Consultants' Sub-Forum, and he wants to "impress" a little bit..., so good luck with that... :wink: )
- (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...
GUTAO
Posts: 15
Joined: Sun May 10, 2015 7:52 am

Re: EVAL When another function is activated

Post by GUTAO » Sun Oct 14, 2018 12:01 pm

Friend I believe that now I have corrected everything you asked for in the topic, if you can give me a strength to solve the problem I would be very grateful. hugs.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL When another function is activated

Post by chivracq » Sun Oct 14, 2018 8:54 pm

GUTAO wrote:Friend I believe that now I have corrected everything you asked for in the topic, if you can give me a strength to solve the problem I would be very grateful. hugs.
Oh...!, very good indeed..., now we "can talk"...! :D

Hum..., not sure about the "Hugs" though...! :shock: , I "usually" only take "Hugs" from Friends or Family or "nice Ladies", I'm not sure you "qualify" (yet), ah-ah...! (Is a Joke, of course...!) :wink:

OK, I will re-quote your OP as we'll start from there...:
GUTAO wrote:

Code: Select all

Version 12.0.501.6698
Sistema windows 7 português
Internet Explorer 9
Personally I know imacros at one time but I use very little and would like help with the following question ...
I want the macro to find a certain data on the page ignore all the rest of the code, return to the beginning of the execution or skip to the next execution. I read a lot and believed that the EVAL function could solve this, but I could not make it work. Thank you very much in advance.

follow the code:

Code: Select all

TAB CLOSEALLOTHERS
SET !DATASOURCE guto.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=https://netsales.netservicos.com.br/NETSales/
FRAME NAME=principal
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:Cadastro
TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante
ONDIALOG POS=1 BUTTON=YES
ONDIALOG POS=2 BUTTON=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidadeText CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=SELECT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidade CONTENT=%*~NETSALES_BASE_*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:codNet CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:PesquisaAssinanteForm ATTR=NAME:btoPesquisa
TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"https://netsales.netservicos.com.br/NETSales/\";} else {var x=\"https://www.youtube.com\";} x;")
SET !TIMEOUT_STEP 0
=> Description on the Pb/Qt is:
I want the macro to find a certain data on the page ignore all the rest of the code, return to the beginning of the execution or skip to the next execution.
Okay..., you need some Conditional Logic in your Script for that then, which is "usually" done using a '.js' Script if you are on FF and using iMacros for FF until v9.0.3 (+FF until v56(-)), (current iMacros for FF Version is now v10.0.2 which doesn't support '.js' Scripts anymore/yet), or with any of the 4 Browsers supported by iMacros, => using the Scripting Interface.
But from your FCI, you are on IE (oh yeah, IE9, hum, a bit of a "strange" IE Version, but you've already 'demystified" that part...) and using the Free iMacros for IE Add-on v12.0, meaning you can't use '.js' Scripts and you probably don't have the Scripting Interface, hum, OK, fair enough...

The Functionality you want can then indeed be achieved using 'EVAL()', it's a bit "cumbersome" and only works for "fairly simple" Cases, and relatively "short" Scripts or short Sections of Code that you want to skip and requires a few "creative" Workarounds, but it can be done, and I use it myself (even if I still use an iMacros for FF Version that still supports '.js' Scripts (v8.8.2 + v8.9.7), but I (deliberately) don't use any '.js' Scripts)... :wink:

The relevant part in your Script will be those 2 Lines, with the 'EXTRACT' being your only 'EXTRACT' in your Script (or you would need to reset '!EXTRACT' to "NULL" prior to the Extract to avoid "polluting" its Content)...:

Code: Select all

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"https://netsales.netservicos.com.br/NETSales/\";} else {var x=\"https://www.youtube.com\";} x;")
Hum, OK, "strange" 'EVAL()' indeed (because of the "if(s==d)" which will always be TRUE..., and you return an URL..., but you don't do anything after that with that URL in '!VAR2'...!? :?

Yeah well, OK, but what do you want...?, what is your "Condition"/Trigger...?
You are currently "comparing" '!EXTRACT' from the 'EXTRACT' on that "Nenhum<SP>Registro<SP>Encontrado!" Cell with itself, which will always return 'TRUE' of course...!

If you want to return 2 different URL's depending on if your Field will be found or not, you would need to use stg like:

Code: Select all

SET URL_1 "https://netsales.netservicos.com.br/NETSales/"
SET URL_2 "https://www.youtube.com"

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}', u1='{{URL_1}}', u2='{{URL_2}}'; var x,y,z; if(s!='#EANF#'){z=u1;} else {z=u2;}; z;")
URL GOTO={{!VAR2}}
And if, like you mention in your Description ("... ignore all the rest of the code, return to the beginning of the execution or skip to the next execution."), you would like after the 'EVAL()' to return to the beginning of your Script and ignore the rest of your Script, it all depends a bit on what for Code you have afterwards (not posted...!), but one "Technique" that I use and which "always" works, is to conditionally "send" the Script to some "fake" 'TAB_2' (already opened), where the Script won't do anything... (with a very short Value (=1/0) for all '!TIMEOUT_xxx' Settings of course), and your 'EVAL()' Statement would then return a "1"/"2" to reuse in some "TAB T=n" Statement, with your Script staying on 'TAB_1' if the (rest of the) Code needs to run, or switching to the fake 'TAB_2' if you want to "mute" that Section of Code... :idea:
- (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...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL When another function is activated

Post by chivracq » Sun Oct 14, 2018 10:28 pm

And don't worry, I still "see" you when you are checking the Forum, even if you are hiding your Status, ah-ah...! :wink:

But OK, "digest" my previous Post, and I'll be "waiting" for your Follow-up..., with your final/working Script showing that you understood the Principle... :|
- (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...
GUTAO
Posts: 15
Joined: Sun May 10, 2015 7:52 am

Re: EVAL When another function is activated

Post by GUTAO » Mon Oct 15, 2018 12:44 pm

Friend now would like to thank you for the attention and help in solving the problem.

In fact the first extract is not the only one in the code.
The result of the extact will not always be true being that I use this code to perform a search on a system and sometimes it finds and sometimes not, I'm comparing the extract with itself because I could not do the extract comparison with the "None <SP > Record SP found! " I know it's very simple but I have to redeem it and say that I really can not.

Another detail is that I do not want to return with the urls, this line with the urls I found searching in the forum and was trying to change so that instead of the urls they would be a command for when EVAL is true to execute this command more until the moment I could not find the solution.

Regarding the command to be executed if EVAL is true I believe the best one for the macro would be it when it encountered "No SP <SP> Found!" skip all remaining code and for the next run, for example: in search number 1 found "None <SP> Found SP!" then ignore the rest of the code and go to search number 2.


follows full code:

TAB CLOSEALLOTHERS
SET !DATASOURCE guto.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES
URL GOTO=https://netsales.netservicos.com.br/NETSales/
FRAME NAME=principal
WAIT SECONDS=1
TAG POS=1 TYPE=DIV ATTR=TXT:Cadastro
TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante
ONDIALOG POS=1 BUTTON=YES
ONDIALOG POS=2 BUTTON=YES
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidadeText CONTENT={{!COL1}}
WAIT SECONDS=1
TAG POS=1 TYPE=SELECT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidade CONTENT=%*~NETSALES_BASE_*
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:codNet CONTENT={{!COL2}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:PesquisaAssinanteForm ATTR=NAME:btoPesquisa
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"https://netsales.netservicos.com.br/NETSales/\";} else {var x=\"https://www.youtube.com\";} x;")
SET !TIMEOUT_STEP 0
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
SET contrato {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=2 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
SET nome {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=3 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
SET cpf {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=4 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
SET cidade {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=5 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
SET status {{!EXTRACT}}
SET !EXTRACT NULL
TAB CLOSEALLOTHERS
ONDIALOG POS=1 BUTTON=NO
ONDIALOG POS=2 BUTTON=NO
ONDIALOG POS=3 BUTTON=NO
ONDIALOG POS=4 BUTTON=NO
TAB CLOSEALLOTHERS
TAG POS=1 TYPE=A ATTR=TXT:{{!COL2}}
TAG POS=9 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
SET rg {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=10 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
SET tel1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=13 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
SET tel2 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=14 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
SET tel3 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=12 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
SET tel4 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TEXTAREA ATTR=ID:descEndereco EXTRACT=TXT
SET endereco {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=FONT ATTR=TXT:Contrato
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.assinatura EXTRACT=TXT
SET produto {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:perfilAssinante EXTRACT=TXT
SET combo {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:nivelRelacionamento EXTRACT=TXT
SET chip {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.dtVenda EXTRACT=TXT
SET datavenda {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.dtInstalacao EXTRACT=TXT
SET dtinsta {{!EXTRACT}}
SET !EXTRACT NULL
URL GOTO=http://189.16.11.69/crm/leadsext-netpro ... &sucesso=1
TAG POS=2 TYPE=INPUT:TEXT ATTR=* CONTENT={{contrato}}
TAG POS=3 TYPE=INPUT:TEXT ATTR=* CONTENT={{nome}}
TAG POS=4 TYPE=INPUT:TEXT ATTR=* CONTENT={{cpf}}
TAG POS=5 TYPE=INPUT:TEXT ATTR=* CONTENT={{cidade}}
TAG POS=6 TYPE=INPUT:TEXT ATTR=* CONTENT={{status}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone1 CONTENT={{tel1}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone2 CONTENT={{tel2}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone3 CONTENT={{tel3}}
TAG POS=10 TYPE=INPUT:TEXT ATTR=* CONTENT={{produto}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:numero_combo CONTENT={{combo}}
TAG POS=12 TYPE=INPUT:TEXT ATTR=* CONTENT={{chip}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:data_venda CONTENT={{datavenda}}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:data_instalacao CONTENT={{dtinsta}}
TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:Salvar
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL When another function is activated

Post by chivracq » Mon Oct 15, 2018 2:41 pm

GUTAO wrote:Friend now would like to thank you for the attention and help in solving the problem.

In fact the first extract is not the only one in the code.
The result of the extact will not always be true being that I use this code to perform a search on a system and sometimes it finds and sometimes not, I'm comparing the extract with itself because I could not do the extract comparison with the "None <SP > Record SP found! " I know it's very simple but I have to redeem it and say that I really can not.

Another detail is that I do not want to return with the urls, this line with the urls I found searching in the forum and was trying to change so that instead of the urls they would be a command for when EVAL is true to execute this command more until the moment I could not find the solution.

Regarding the command to be executed if EVAL is true I believe the best one for the macro would be it when it encountered "No SP <SP> Found!" skip all remaining code and for the next run, for example: in search number 1 found "None <SP> Found SP!" then ignore the rest of the code and go to search number 2.

follows full code:

Code: Select all

	TAB CLOSEALLOTHERS
	SET !DATASOURCE guto.csv
	SET !DATASOURCE_COLUMNS 2
	SET !LOOP 1
	SET !DATASOURCE_LINE {{!LOOP}}
	SET !ERRORIGNORE YES
	URL GOTO=https://netsales.netservicos.com.br/NETSales/
	FRAME NAME=principal
	WAIT SECONDS=1
	TAG POS=1 TYPE=DIV ATTR=TXT:Cadastro
	TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante
	ONDIALOG POS=1 BUTTON=YES
	ONDIALOG POS=2 BUTTON=YES
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidadeText CONTENT={{!COL1}}
	WAIT SECONDS=1
	TAG POS=1 TYPE=SELECT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:cidade CONTENT=%*~NETSALES_BASE_*
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:PesquisaAssinanteForm ATTR=NAME:codNet CONTENT={{!COL2}}
	TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:PesquisaAssinanteForm ATTR=NAME:btoPesquisa
	SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var d=\"{{!EXTRACT}}\"; if(s==d){var x = \"https://netsales.netservicos.com.br/NETSales/\";} else {var x=\"https://www.youtube.com\";} x;")
	SET !TIMEOUT_STEP 0
	SET !EXTRACT_TEST_POPUP NO
	TAG POS=1 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT 
	SET contrato {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=2 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
	SET nome {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=3 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
	SET cpf {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=4 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
	SET cidade {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=5 TYPE=TD ATTR=CLASS:bg-cinza-0 EXTRACT=TXT
	SET status {{!EXTRACT}}
	SET !EXTRACT NULL
	TAB CLOSEALLOTHERS
	ONDIALOG POS=1 BUTTON=NO
	ONDIALOG POS=2 BUTTON=NO
	ONDIALOG POS=3 BUTTON=NO
	ONDIALOG POS=4 BUTTON=NO
	TAB CLOSEALLOTHERS
	TAG POS=1 TYPE=A ATTR=TXT:{{!COL2}}
	TAG POS=9 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
	SET rg {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=10 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
	SET tel1 {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=13 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
	SET tel2 {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=14 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
	SET tel3 {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=12 TYPE=INPUT:TEXT ATTR=DISABLED:disabled EXTRACT=TXT
	SET tel4 {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=TEXTAREA ATTR=ID:descEndereco EXTRACT=TXT
	SET endereco {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=FONT ATTR=TXT:Contrato
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.assinatura EXTRACT=TXT
	SET produto {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:perfilAssinante EXTRACT=TXT
	SET combo {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:nivelRelacionamento EXTRACT=TXT
	SET chip {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.dtVenda EXTRACT=TXT
	SET datavenda {{!EXTRACT}}
	SET !EXTRACT NULL
	TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:DadosContratoForm ATTR=NAME:contratoView.dtInstalacao EXTRACT=TXT
	SET dtinsta {{!EXTRACT}}
	SET !EXTRACT NULL
	URL GOTO=http://189.16.11.69/crm/leadsext-netprodutos.php?78a7f420cdb1b34f2b596f7b63f5891ac5484b7f=6269c0b0e642f00028c9b36766260b066f4e6061&sucesso=1
	TAG POS=2 TYPE=INPUT:TEXT ATTR=* CONTENT={{contrato}}
	TAG POS=3 TYPE=INPUT:TEXT ATTR=* CONTENT={{nome}}
	TAG POS=4 TYPE=INPUT:TEXT ATTR=* CONTENT={{cpf}}
	TAG POS=5 TYPE=INPUT:TEXT ATTR=* CONTENT={{cidade}}
	TAG POS=6 TYPE=INPUT:TEXT ATTR=* CONTENT={{status}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone1 CONTENT={{tel1}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone2 CONTENT={{tel2}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:telefone3 CONTENT={{tel3}}
	TAG POS=10 TYPE=INPUT:TEXT ATTR=* CONTENT={{produto}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:numero_combo CONTENT={{combo}}
	TAG POS=12 TYPE=INPUT:TEXT ATTR=* CONTENT={{chip}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:data_venda CONTENT={{datavenda}}
	TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:data_instalacao CONTENT={{dtinsta}}
	TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=TXT:Salvar
OK..., hum, would quite improve the Readability of your Post(s) if you could use the ]CODE[ Meta-Tags to format your Script(s)... :idea:

Oh...!, I wanted to "adapt" your Script to implement the Functionality that you want as it's fairly easy to implement if you understood the "Principle"..., but can you edit your previous Post with your Script enclosed between ]CODE[ Tags, and remove all 'TAB''s or Spaces at the beginning of each Line of Code, I'm not going to remove them myself one by one to be able to adapt your Script... :wink:

But hum, I actually already gave you the/a Solution, with the 'EVAL()' I posted, which is just an Example, returning 2 URL's, but you can return what you want, any String(s) or any Number(s), it's not difficult to adapt it..., and in this Case, I would simply return your CRM URL with the IP-Address for the last 'URL GOTO' in your Script, or an empty String, an 'URL GOTO' to an empty String/URL won't do anything...!
- (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...
GUTAO
Posts: 15
Joined: Sun May 10, 2015 7:52 am

Re: EVAL When another function is activated

Post by GUTAO » Wed Oct 17, 2018 3:30 pm

My friend apologize for the work and my lack of knowledge, the code below that you have already clarified some things for me and it is exactly this concept that I need to execute with the macro but I would like it to execute a command instead of opening a url like in the example below but I can not make it work. Thanks so much if you can give me this help any more.



code that you submitted:

SET URL_1 "https://netsales.netservicos.com.br/NETSales/"
SET URL_2 "https://www.youtube.com"

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}', u1='{{URL_1}}', u2='{{URL_2}}'; var x,y,z; if(s!='#EANF#'){z=u1;} else {z=u2;}; z;")
URL GOTO={{!VAR2}}



code with the command I'd like it to execute:

SET URL_1 "TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante"
SET URL_2 "https://netsales.netservicos.com.br/NETSales/"

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}', u1='{{URL_1}}', u2='{{URL_2}}'; var x,y,z; if(s!='#EANF#'){z=u1;} else {z=u2;}; z;")
URL GOTO={{!VAR2}}


I already researched everywhere in the forum and I can not find the solution.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL When another function is activated

Post by chivracq » Wed Oct 17, 2018 7:31 pm

GUTAO wrote:My friend apologize for the work and my lack of knowledge, the code below that you have already clarified some things for me and it is exactly this concept that I need to execute with the macro but I would like it to execute a command instead of opening a url like in the example below but I can not make it work. Thanks so much if you can give me this help any more.

code that you submitted:

Code: Select all

SET URL_1 "https://netsales.netservicos.com.br/NETSales/"
SET URL_2 "https://www.youtube.com"

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}', u1='{{URL_1}}', u2='{{URL_2}}'; var x,y,z; if(s!='#EANF#'){z=u1;} else {z=u2;}; z;")
URL GOTO={{!VAR2}}
code with the command I'd like it to execute:

Code: Select all

SET URL_1 "TAG POS=1 TYPE=DIV ATTR=TXT:Pesquisar<SP>Assinante"
SET URL_2 "https://netsales.netservicos.com.br/NETSales/"

TAG POS=2 TYPE=TD ATTR=TXT:Nenhum<SP>Registro<SP>Encontrado! EXTRACT=TXT
SET !VAR2 EVAL("var s='{{!EXTRACT}}', u1='{{URL_1}}', u2='{{URL_2}}'; var x,y,z; if(s!='#EANF#'){z=u1;} else {z=u2;}; z;")
URL GOTO={{!VAR2}}
I already researched everywhere in the forum and I can not find the solution.
Yeah, well, you don't need to "(re)search everywhere in the Forum", you need to understand the Principle and to adapt my Example to your Need, you already have the "best Example" from the Forum...! 8)
Here is another Thread with other Examples (or that links to other relevant Threads) and where I explained that Principle (+ other ones/Techniques that can be used also for Conditional Logic in pure '.iim'), but I'm afraid if you don't understand "it" from your own Thread that it won't really help you further...:
- Workarounds for Conditional Logic in Macro Code

And I mentioned in my previous Post that I was willing to adapt you full Script if you could edit your previous Post to format your Script using the ']CODE[' Meta-Tags and removed all the indent Tabs and Spaces at the beginning of each Line in your Script, but tja...!, you didn't do that...! :roll:
(Hum..., I think I found an easy way to remove them all myself, but pfff..., it would "speed up the whole Process" if you understood a bit directly each time I ask you stg or suggest stg..., and not after repeating 20 times for weeks/months/years...! OK, I'll see a bit later on if I find the "Courage" to adapt your Script, but the Forum is a bit "busy" at the moment and you are not the only one needing Help..., and it's more "rewarding" for me to help Users who "understand" what I'm trying to explain..., and make some "Progress" by themselves... After more than 3 years of using iMacros, you should have understood how to modify your Script to implement your desired Functionality after just one simple Sentence from me from a first Reply... :shock: )
OK, maybe till later on... :wink:
- (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...
Post Reply