Macro last line is reached (csv)

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

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.

Macro last line is reached (csv)

by Tweety on Wed Feb 26, 2014 2:25 am

I have make a macro with a csv (txt) file. But how can i change the last row in macro when the last line is reached no longer perform the last line of macro use.

Code: Select all
VERSION BUILD=8031994
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1     
TAB CLOSEALLOTHERS 
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE C:\1Bulkinschrijvingensamenvoegen.txt
'Start at line 2 to skip the header in the file
SET !LOOP 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
FRAME NAME="TargetContent"

TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_ENRL_ACTION_DT$0 CONTENT=03-03-2014
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_CLASS_NBR$0 CONTENT ={{!COL1}}

TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif

I have try it with this but is not working
Code: Select all
TAG POS=1 TYPE=BUTTON:submit FORM=ID:demo ATTR=TXT:Submit

TAG POS=1 TYPE=A ATTR=TXT:*Back*


Greeting

Kasper
Tweety
 
Posts: 23
Joined: Wed Feb 26, 2014 2:15 am
Location: Heemstede

Re: Macro last line is reached (csv)

by chivracq on Wed Feb 26, 2014 3:04 am

I don't understand this sentence: "But how can i change the last row in macro when the last line is reached no longer perform the last line of macro use."
I have a feeling you mix up "Rows" (of Data in the .CSV File) and Lines (of Code in the Macro). Can you reformulate it more precisely... (eventually in Dutch, I can re-translate it...)?

Then, can you clarify the order between those 3 Lines and which one is the one you want to "modify"...? I don't understand their relationship...
TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif
and:
TAG POS=1 TYPE=BUTTON:submit FORM=ID:demo ATTR=TXT:Submit
TAG POS=1 TYPE=A ATTR=TXT:*Back*

Other Question (from what I think I already understood about your Question...):
Will you know the exact Number of Rows in your .CSV, for example 37, and when you Play (Loop) your Macro, you select exactly 37, or does that Number change but you know it's always between 20-40, so you select 50 for the Loop...?
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Macro last line is reached (csv)

by Tweety on Wed Feb 26, 2014 3:34 am

De regel die ik wil veranderen is
TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif (dit is een knop die het veld oplust(+))
Als ik nu de macro uitvoer dan vult hij automatisch een datum (Actiedatum) in en het nummer (Nr. studieactiv.) uit het txt bestand. vervolgens drukt hij op het + teken. Nu wil dat de macro niet het plusteken gebruikt als er geen nieuwe regel in txt bestand voorkomt.
De regels zijn die in het txt bestand staan varieren tussen 5 en 20
Attachments
Voorbeeld.JPG
Voorbeeld
Tweety
 
Posts: 23
Joined: Wed Feb 26, 2014 2:15 am
Location: Heemstede

Re: Macro last line is reached (csv)

by chivracq on Wed Feb 26, 2014 5:53 am

Tweety wrote:De regel die ik wil veranderen is
TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif (dit is een knop die het veld oplust(+))
Als ik nu de macro uitvoer dan vult hij automatisch een datum (Actiedatum) in en het nummer (Nr. studieactiv.) uit het txt bestand. vervolgens drukt hij op het + teken. Nu wil dat de macro niet het plusteken gebruikt als er geen nieuwe regel in txt bestand voorkomt.
De regels zijn die in het txt bestand staan varieren tussen 5 en 20


OK, now I understand, thanks for the clarification. And a Screenshot with visual Indicators is indeed always the best explanation...

I will first (freely) re-translate your Reply in English:

Tweety wrote:The Line I want to modify (once the end of the .CSV File has been reached) is:
TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif
(It's a '+' sign adding a new Row.)

The Macro fills in automatically a Date (Actiedatum) and a Number (Nr. studieactiv.) from the .CSV File and then clicks on the '+' sign. Now I want that the Macro doesn't click on the + sign if there is no new Row of Data in the .CSV File.
There are between 5 and 20 Rows in the .CSV File


OK, I think the easiest way to achieve what you want is to move the Line clicking on the '+' sign from the end of your Macro to the beginning and make sure that it is not executed on the 1st Run of your Looping.

I don't see any '!ERRORIGNORE' Statement in your Script, so I assume that you either type in the exact Number for MAX_LOOP corresponding to the Number of Rows in your .CSV File or that you always select a bigger Number and you wait for the Runtime Error to occur once the end of the .CSV has been reached.
If you always type in a bigger Number, that means that you want to check BEFORE clicking on the '+' sign if the (new) Row in the .CSV File contains valid Data.

And your Script will look like this:
Code: Select all
VERSION BUILD=8031994
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1
TAB CLOSEALLOTHERS
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE C:\1Bulkinschrijvingensamenvoegen.txt
'Start at line 2 to skip the header in the file
SET !LOOP 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}

'Check if valid Row of Data in .CSV File:
'(Triggers Runtime Error if end of .CSV File has been reached.)
SET !VAR1 {{!COL1}}

' Fill web form

'Click on '+' sign except on 1st Run of Looping:
'=> 'plus=0' for 1st Run, 'plus=1' for all others:
SET plus EVAL("var d=\"{{!LOOP}}\"; if (d<2) {var x=0;} else {var x=1;} x;")
'For Debugging (Uncomment to activate):
'PROMPT !LOOP:<SP>{{!LOOP}}<br>plus:<SP>{{plus}}<br>!COL1:<SP>{{!COL1}}
FRAME NAME="TargetContent"
TAG POS={{plus}} TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_ENRL_ACTION_DT$0 CONTENT=03-03-2014
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_CLASS_NBR$0 CONTENT ={{!COL1}}
'TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif


You are allowed to have 0 or 1 empty Row (= 0 or 1 Carriage Return) at the end of your .CSV File, if you have more, they will be treated like valid Rows with empty Data.

And a funny detail: I worked once for 1 year for the HVA (20 years ago).
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Macro last line is reached (csv)

by Tweety on Wed Feb 26, 2014 6:45 am

I have try it but i have a error on line 25 "TAG POS={{plus}} TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif"

BadParameter: expected POS=<number> or POS=R<number>
where <number> is a non-zero integer as parameter 1,
line 25 (Error code: -911)
Tweety
 
Posts: 23
Joined: Wed Feb 26, 2014 2:15 am
Location: Heemstede

Re: Macro last line is reached (csv)

by chivracq on Wed Feb 26, 2014 7:05 am

Tweety wrote:I have try it but i have a error on line 25 "TAG POS={{plus}} TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif"


Oh yes, of course! You need to use "SET !ERRORIGNORE YES"...!

When you get an Error, mention it...

Code: Select all
VERSION BUILD=8031994
'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database
TAB T=1
TAB CLOSEALLOTHERS
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE C:\1Bulkinschrijvingensamenvoegen.txt
'Start at line 2 to skip the header in the file
SET !LOOP 1
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
'Check if valid Row of Data in .CSV File:
'(Triggers Runtime Error if end of .CSV File has been reached.)
SET !VAR1 {{!COL1}}
' Fill web form
'Click on '+' sign except on 1st Run of Looping:
'=> 'plus=0' for 1st Run, 'plus=1' for all others:
SET plus EVAL("var d=\"{{!LOOP}}\"; if (d<2) {var x=0;} else {var x=1;} x;")
'For Debugging (Uncomment to activate):
'PROMPT !LOOP:<SP>{{!LOOP}}<br>plus:<SP>{{plus}}<br>!COL1:<SP>{{!COL1}}
SET !ERRORIGNORE YES
FRAME NAME="TargetContent"
TAG POS={{plus}} TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif
SET !ERRORIGNORE NO
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_ENRL_ACTION_DT$0 CONTENT=03-03-2014
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_CLASS_NBR$0 CONTENT ={{!COL1}}
'TAG POS=1 TYPE=IMG ATTR=SRC:https://sis.hva.nl:8011/cs/S2PRD/cache/PT_ADD_DUT_1.gif
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Macro last line is reached (csv)

by Tweety on Wed Feb 26, 2014 7:22 am

Thanks,
I have one line added.
WAIT SECONDS=0 (after SET !ERRORIGNORE NO)
The input data was not remembered
It was resolved with the line
Tweety
 
Posts: 23
Joined: Wed Feb 26, 2014 2:15 am
Location: Heemstede

Re: Macro last line is reached (csv)

by chivracq on Wed Feb 26, 2014 8:27 am

Tweety wrote:Thanks,
I have one line added.
WAIT SECONDS=0 (after SET !ERRORIGNORE NO)
The input data was not remembered
It was resolved with the line


OK, good (that it works) and glad I could help...!

If you want to understand a bit better for yourself a few Tricks and Techniques that I used in your Case, you can read the following Thread as your Macro is a direct Application and in return a good Example again for the other Thread:
Decision Making using iMacros/Possible Workarounds

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

JFC_TAG:
conditional_behaviour, conditional, behaviour, behavior, JavaScript, EVAL, LOOP, Looping, exclude, 1st, first, last, run, '+' sign, LOOP_MAX, CSV, !ERRORIGNORE
- (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: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Macro last line is reached (csv)

by Tweety on Wed Feb 26, 2014 12:49 pm

I have a other question but i ask it in Dutch

Is het mogelijk om een macro te maken die gegevens uit een csv/txt bestand haalt en dit op 2e verschillende tabbladen neerzet.
Op het 1e tabblad moet 1x de waarde geplaats worden uit de kolom Groep en op 2e tabblad de gegevens van Stud en Datum.
Tabblad 2 moet dan opgeplust worden tot de laatse rij waarvan de Groep het zelfde is. De aantallen kunnen verschillend zijn.

Ik dacht zelf om het csv.txt bestand op de volgende manier te maken

Groep,Stud,Datum
030D,123,03-03-2014
030D,124,03-03-2014
030D,125,03-03-2014
030E,126,03-03-2014
030E,127,03-03-2014

Hieronder staat de macro die ik opgenomen en aangepast hebt wat alleen wertkt als ik overal maar 1x iets invuld
Code: Select all
VERSION BUILD=8810214 RECORDER=FX
TAB T=1     
TAB CLOSEALLOTHERS 
' Specify input file (if !COL variables are used, IIM automatically assume a CSV format of the input file
'CSV = Comma Separated Values in each line of the file
SET !DATASOURCE C:\Test.txt
'Start at line 2 to skip the header in the file
SET !LOOP 2
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
' Fill web form   
URL GOTO=https://sis.hva.nl:8011/psp/S2PRD/EMPLOYEE/HRMS/c/MANAGE_ACADEMIC_RECORDS.BLOCK_ENROLL_MERGE.GBL?Folder=MYFAVORITES
FRAME NAME="TargetContent"
TAG POS=1 TYPE=SPAN ATTR=TXT:Nieuwe<SP>waarde<SP>toevoegen
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:SNS_DERIVED_STDNT_GROUP CONTENT={{!COL1}}
TAG POS=1 TYPE=A ATTR=ID:BLK_ENRL_WRK_CRSE_BLOCK_PB
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_ENRL_ACTION_DT$0 CONTENT={{!COL3}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:BLK_ENR_CRS_TMP_CLASS_NBR$0 CONTENT={{!COL2}}
WAIT SECONDS=0
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:win0 ATTR=ID:#ICSave
WAIT SECONDS=3
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:win0 ATTR=ID:BLK_ENRL_WRK_ENRL_REQ_CREATE_PB
WAIT SECONDS=5
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:win0 ATTR=ID:BLK_ENRL_WRK_ENRL_REQ_RC_PB


Mvg/Greeting

Kasper
Attachments
Schermafbeelding 2014-02-26 om 20.09.47.png
Tabblad 1
Schermafbeelding 2014-02-26 om 20.10.10.png
Tabblad 2
Tweety
 
Posts: 23
Joined: Wed Feb 26, 2014 2:15 am
Location: Heemstede


Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 13 guests

-->