aegorhum wrote:Hi Chivracq,
I am launching my macros from .VBS scripts currently, the issue is that I don't know how to do what I've described. I haven't written any macros for this (or created the .VBS wrappers) yet because I don't know how many macros are needed or how to loop through them correctly. If I were to break it down, I believe it would be three macros:
Macro 1
Code: Select all
VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
'URL GOTO=https://www.gold.oilfield.slb.com/cgi-bin/wspd_cgi.sh/WService=gold/MfgProOnTheWeb.html
FRAME NAME=FS_main
TAG POS=1 TYPE=A ATTR=TXT:CODXW079
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:submit-jumpto
Macro 2
Code: Select all
VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
'URL GOTO=https://www.gold.oilfield.slb.com/cgi-bin/wspd_cgi.sh/WService=gold/MfgProOnTheWeb.html
FRAME NAME=FS_main
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:PAR_PAC1 CONTENT=0
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:NEWLOC1 CONTENT=E1L1
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:STOCK1
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:PAR_PAC2 CONTENT=0
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:NEWLOC2 CONTENT=E1L1
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:STOCK2
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:PAR_PAC3 CONTENT=0
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:NEWLOC3 CONTENT=E1L1
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:STOCK3
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:PAR_PAC4 CONTENT=0
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:NEWLOC4 CONTENT=E1L1
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:STOCK4
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
Macro 3
Code: Select all
VERSION BUILD=12.0.501.6698
TAB T=1
TAB CLOSEALLOTHERS
'SET !PLAYBACKDELAY 0.00
'URL GOTO=https://www.gold.oilfield.slb.com/cgi-bin/wspd_cgi.sh/WService=gold/MfgProOnTheWeb.html
FRAME NAME=FS_main
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
TAG POS=1 TYPE=SELECT ATTR=NAME:Type_transport CONTENT=%TRUCK
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:FreightCost CONTENT=0
This doesn't use a loop (because I don't know how to loop through it correctly) and I didn't hit the final submit button (because the customer hasn't given us access to the test environment). I call macros to log in to the site and browse to the correct menu from .VBS because the HTML of the site's menu structure is..."wonky". Either way, that method works for me and it makes modifications easy (e.g. when the customer provides more permissions and the menu structure changes).
Each DOC# can have multiple DO#s, each with multiple parcels. These parcels are listed in numerical order (DO#1/par#1, DO#2/par#1, DO#1/par#2, DO#2/par#2) instead of the DO#s being listed in numerical order. One of the challenges is that each parcel must be submitted in DO#/parcel# order. So, the submit order for the above example must be DO#1/par#1, DO#1/par#2, DO#2/par#1, DO#2/par#2.
Since the number of DOs and parcels per DOC# is not consistent, I don't think looping line by line is the way to go.
If I were do try to put this into PowerShell, I think it would look something like this (though it's still not right since there's duplicate DOC#s and the pack_cost would be erratic)
Code: Select all
$csv = import-csv c:\input_file
$DOC = $csv.docn
foreach ($COD in $DOC) {
$DOns = $csv.don | where-object {($csv).docn -like $COD}
$Cost = $csv.freight_cost | where-object {($csv).docn -like $COD}
$Loc = $csv.new_loc | where-object {($csv).docn -like $COD}
TAG POS=1 TYPE=A ATTR=TXT:$DOC
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=NAME:submit-jumpto
foreach ($DOn in $DOns) {
$Parns = $csv.parceln | where-object {($csv).don -like $DOn}
foreach ($Parn in $Parns) {
$PCost = $csv.pack_cost | where-object {($csv).parceln -like $Parn}
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:PAR_PAC$Parn CONTENT=0
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:NEWLOC$Parn CONTENT=$Loc
TAG POS=2 TYPE=INPUT:RADIO ATTR=NAME:STOCK$Parn
}
}
TAG POS=1 TYPE=INPUT:BUTTON ATTR=NAME:submit-jumpto
TAG POS=1 TYPE=SELECT ATTR=NAME:Type_transport CONTENT=%TRUCK
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:FreightCost CONTENT=$Cost
}
OK, good...!, Thread Title is now Descriptive, even if the "Need help" part is always "useless", but OK, we can talk...!
(You edited your Thread Title after posting your last Reply, so that new Title didn't get taken over as Title for that Post, but OK, never mind...)
Hum..., and OK, you do use the Scripting Interface actually (=> correct Sub-Forum then), with a '.VBS' Script, yeah then, that was "worth" mentioning in your OP, ah-ah...! And that means you are a "Professional", even better...!, as "Professionals" tend to "understand" my "Explanations" and "Solutions"/"(Creative) Ideas for Implementation" usually more easily than "Script Kiddies", ah-ah...!
But, OK, this is going to be some "Interesting" Thread after all, ah-ah...!
(Hum, and "funnily" enough, some Friend of mine works for 'slb', ah-ah...!
)
Yeah, well, everything you want is indeed not very-very complicated, it could even be done with just 1 single Macro in pure '.iim' (I only use pure '.iim' for myself anyway), even if you'll have a bit more "Control" from a main '.VBS' Script...
Like you've already found out, you'll then need to "split" the complete Workflow of your whole Process into several Sub-Processes (with each a separate Sub-(on-the-fly)-'.iim' Macro and you'll need to "organize" them from your main '.vbs' Script logically according to their Dependencies and Nested Level, with or without Looping...
You could maybe already have a look at the following Thread, with complete Script Example(s), with several Sub-Macros controlled from a main '.vbs' Script as well, even if in that Thread, all Sub-Macros run a bit "linearly" with some simple 'IF' Condition, until the Final Script posted where the Workflow gets a bit a "Nested Levels" with several 'IF/ELSE' Conditions (but no Looping). But you'll find many Examples with (Nested) Looping in '.js' Scripts on the Forum, if you need Examples..., hum..., like in
this recent Post for example where I had posted a few Links to such Threads... But OK, the '.vbs' Thread:
-
Identify Wich Step Has Failed
(Hum, nearly surprised I didn't "bash" that User for the ugly Typo in their Thread Title, I normally don't answer Threads until the Thread Title is Descriptive and doesn't contain any Typos/Spelling Mistakes anymore...
)
For your (Nested) Loops, think about using 'while' or 'until' Loops instead of 'for' Loops for the parts where you don't know how many times you might need to loop a specific Sub-Macro, for the 'DO#'-Parcels for example, even if you could still use a 'for' Loop, as the "3" (Parcels) is already displayed on the Page and could be extracted and passed to the main '.vbs' to be reused for the 'for' Loop..., while a 'while' or 'until' Loop will, at the beginning or the end of the Macro, check if there is a new/next 'DOC' or 'DO' to handle or if the Loop can be aborted to go to the next "Step"...
- (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...