failure... modify variable

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

failure... modify variable

by troscar on Mon May 14, 2018 11:13 am

Hi there,
I am a rocky in programing (a week for this script :( )
I use that for update records. They are in pages of 30

Code: Select all
Option Explicit
Dim tanun '# total of records
Dim panun '#total records for page
Dim counter
Dim tanunloop 'split group of three for to minimize the problem that affects my lack of knowledge. sicion , sicion2, sicion3 too
Dim sicion  ' 1 Positon of the record in the page
Dim sicion2  ' 2 Positon of the record in the page
Dim sicion3  ' 3 Positon of the record in the page

Dim pagina
Dim tiempo

tanun = 153 ''total records
tiempo = 300 'time for waiting
panun =30 'records x page
pagina = (tanun \ panun)+1 'total pages of 30 records
counter = 0 'move loop
sicion = tanun mod panun 'tells me the position of the last record, of 30 probable positions, on the last page (45 records; - 30 first page will be position 15)
sicion3 = sicion - 2 'Position for antepenultimate record
sicion2 = sicion - 1 'Posición for penultimate record
tanunloop = tanun \ 3 'number to records to update before re loging

Dim iim1,iret
Set iim1 = CreateObject("iMacros")
iret = iim1.iimOpen("", False) 'connect to open iMacros browser window

Dim macro
macro = macro + "TAB T=1" + vbNewLine
macro = macro + "SET !ERRORIGNORE YES" + vbNewLine
macro = macro + "URL GOTO=http://www.mysite.com/renew/?logout" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:email CONTENT=me8@gmail.com" + vbNewLine
macro = macro + "SET !ENCRYPTION NO" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:NoFormName ATTR=ID:contra CONTENT=xxxx" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "URL GOTO=http://www.mysite.com/renew/?pagina={{pagina}}" + vbNewLine
macro = macro + "TAG POS={{sicion}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "TAG POS={{sicion2}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "TAG POS={{sicion3}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine

Do Until counter = tanunloop
iim1.iimSet "sicion", sicion
iim1.iimSet "sicion2", sicion2
iim1.iimSet "sicion3", sicion3
iim1.iimSet "pagina", pagina
iim1.iimSet "tiempo", tiempo
iret = iim1.iimPlayCode(macro)
counter=counter+1
Loop


it works GREAT, but... I want improve it
If a record can't be update it always remain in the bottom position (sicion3) and only can work sicion2 and sicion but "wait seconds' works losing time.
When a record can't be update browser send a javascrpt alert.

I would like... If browser sends an alert don't 'wait seconds' and +1 to sicion variable

Thanks in advance folks.
I am a silly sure that you could do it with 30% less of code

"Hekp me obi wan kenobis you're my last hope"
troscar
 
Posts: 1
Joined: Mon May 14, 2018 10:29 am

Re: failure... modify variable

by chivracq on Mon May 14, 2018 12:55 pm

troscar wrote:Hi there,
I am a rocky in programing (a week for this script :( )
I use that for update records. They are in pages of 30

Code: Select all
Option Explicit
Dim tanun '# total of records
Dim panun '#total records for page
Dim counter
Dim tanunloop 'split group of three for to minimize the problem that affects my lack of knowledge. sicion , sicion2, sicion3 too
Dim sicion  ' 1 Positon of the record in the page
Dim sicion2  ' 2 Positon of the record in the page
Dim sicion3  ' 3 Positon of the record in the page

Dim pagina
Dim tiempo

tanun = 153 ''total records
tiempo = 300 'time for waiting
panun =30 'records x page
pagina = (tanun \ panun)+1 'total pages of 30 records
counter = 0 'move loop
sicion = tanun mod panun 'tells me the position of the last record, of 30 probable positions, on the last page (45 records; - 30 first page will be position 15)
sicion3 = sicion - 2 'Position for antepenultimate record
sicion2 = sicion - 1 'Posición for penultimate record
tanunloop = tanun \ 3 'number to records to update before re loging

Dim iim1,iret
Set iim1 = CreateObject("iMacros")
iret = iim1.iimOpen("", False) 'connect to open iMacros browser window

Dim macro
macro = macro + "TAB T=1" + vbNewLine
macro = macro + "SET !ERRORIGNORE YES" + vbNewLine
macro = macro + "URL GOTO=http://www.mysite.com/renew/?logout" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:email CONTENT=me8@gmail.com" + vbNewLine
macro = macro + "SET !ENCRYPTION NO" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:NoFormName ATTR=ID:contra CONTENT=xxxx" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "URL GOTO=http://www.mysite.com/renew/?pagina={{pagina}}" + vbNewLine
macro = macro + "TAG POS={{sicion}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "TAG POS={{sicion2}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine
macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=CLASS:submit<SP>btnSend" + vbNewLine
macro = macro + "TAG POS={{sicion3}} TYPE=A ATTR=TXT:Renovar" + vbNewLine
macro = macro + "FRAME F=1" + vbNewLine
macro = macro + "ONDIALOG POS=1 BUTTON=OK CONTENT=" + vbNewLine
macro = macro + "TAG POS=1 TYPE=A ATTR=ID:lren" + vbNewLine
macro = macro + "WAIT SECONDS={{tiempo}}" + vbNewLine

Do Until counter = tanunloop
iim1.iimSet "sicion", sicion
iim1.iimSet "sicion2", sicion2
iim1.iimSet "sicion3", sicion3
iim1.iimSet "pagina", pagina
iim1.iimSet "tiempo", tiempo
iret = iim1.iimPlayCode(macro)
counter=counter+1
Loop


it works GREAT, but... I want improve it
If a record can't be update it always remain in the bottom position (sicion3) and only can work sicion2 and sicion but "wait seconds' works losing time.
When a record can't be update browser send a javascrpt alert.

I would like... If browser sends an alert don't 'wait seconds' and +1 to sicion variable

Thanks in advance folks.
I am a silly sure that you could do it with 30% less of code

"Hekp me obi wan kenobis you're my last hope"

FCIM...! :mrgreen: (Read my Sig...)

OK, your Script is a little bit difficult to follow for sbd who doesn't speak your Language because of the many Names for your Vars in some "exotic" Language, even if you've luckily put some Comments in English, but from what I understand, you would need to make the 'WAIT' "Conditional" by splitting your current on-the-fly "macro" Macro constructed as one single big String into 2 or maybe more Sub-Macros.

And I guess you could actually use a Nested Loop (x2) for each 6 Line Block that you repeat twice from the 'FRAME' Statement until the 'TAG' Statement using your 'sicion2' and 'sicion3' Vars and you could even keep using the same Var and simply increment it between the 2 Inner Loops, without the Need for 2 different Names.

Mini-Caveat: You will need to repeat the '!ERRORIGNORE' Statement in each Sub-Macro as all Vars get reset (by Design) between each Call of the 'iimPlay(Code)()' Command.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 7714
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Command Line and Scripting Interface

Who is online

Users browsing this forum: No registered users and 3 guests

-->