The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "File-2-Web.vbs"
Jump to navigation
Jump to search
Line 34: | Line 34: | ||
for i = 2 to 4 | for i = 2 to 4 | ||
'Set the current read position | 'Set the current read position | ||
− | iret = iim1.iimSet(" | + | iret = iim1.iimSet("line", i) |
'Run the macro | 'Run the macro |
Revision as of 23:38, 27 June 2011
This script takes values from a comma separated variable file (.csv) using the Internet Macros DATASOURCE features.
It calls the macro Wsh-File-2-Web, which handles the file accessing directly.
The macro could also be run directly in the iMacros browser. However, this script demonstrates advanced error checking and provides greater flexibility.
Option Explicit 'This script demonstrates how to read data from the <address.csv> text file in the '/datasource directory using iMacros DATASOURCE features. In other words, the 'macro reads the data directly, this script is only responsible for the loop 'over the data. This similar to pressing the LOOP button, but offers more flexibility 'e. g. for advanced error checking. The script uses the macro <wsh-file-2-web.iim>. 'Tip: This script has the same function as <file-2-web-method2.vbs> but 'uses a different method. MsgBox "This script demonstrates how to read data from the <address.csv> text file in the /datasource directory." Dim iim1, i, iret set iim1= CreateObject ("imacros") iret = iim1.iimInit iret = iim1.iimDisplay("Submitting Data") 'Note: The input file name and the number of columns are specified in the macro 'You can also specify them inside the script with "iimSet" 'Loop through the input file 'We start at "2" to skip the first header line in the file for i = 2 to 4 'Set the current read position iret = iim1.iimSet("line", i) 'Run the macro iret = iim1.iimPlay("wsh-file-2-web") 'Check if user wants to stop if iret = - 3 or iret = - 5 Then MsgBox "User closed browser" WScript.Quit(0) End If If iret < 0 Then MsgBox iim1.iimGetLastError() End If next iret = iim1.iimDisplay("Done!") iret = iim1.iimExit WScript.Quit(0)
Macro code for Wsh-File-2-Web:
VERSION BUILD=3700331 TAB T=1 TAB CLOSEALLOTHERS 'Uses a Windows script to submit several datasets to a website, e. g. for filling an online database ' 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 CMDLINE !DATASOURCE address.csv 'Number of columns in the CSV file. This must be accurate! SET !DATASOURCE_COLUMNS 8 'Increase the current position in the file with each loop SET !DATASOURCE_LINE {{line}} ' ' Fill web form URL GOTO=http://www.iopus.com/imacros/demo/v5/f2/automatic-data-entry.asp TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:FNAME CONTENT={{!COL1}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:LNAME CONTENT={{!COL2}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:ADDRESS CONTENT={{!COL3}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:CITY CONTENT={{!COL4}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:ZIP CONTENT={{!COL5}} 'Tip: Use the string ($) instead of the index to select the state and country 'Index would be the position of an entry in the combo box list, e. g. 161 for United States 'The $ option is more robust against changes of the combo box content 'Note * is used to ignore leading and trailing blanks that could be in the input data TAG POS=1 TYPE=SELECT FORM=NAME:WebDataEntry ATTR=NAME:STATEID CONTENT=$*{{!COL6}}* TAG POS=1 TYPE=SELECT FORM=NAME:WebDataEntry ATTR=NAME:COUNTRYID CONTENT=$*{{!COL7}}* TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:EMAIL CONTENT={{!COL8}} TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:WebDataEntry ATTR=NAME:SendButton&&VALUE:Click<SP>to<SP>submit<SP>data TAG POS=1 TYPE=A ATTR=TXT:Back