×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Trouble getting macro to loop in Outlook

Trouble getting macro to loop in Outlook

Trouble getting macro to loop in Outlook

(OP)
I work for a major US airline that uses InfoConnect 9 to access our native system. What I'm trying to do is set up a macro that will scrape a passengers itinerary off an Attachmate screen, and put that information in an e-mail. I've got all the formatting set up, except that Outlook only saves the last leg. How can I get Outlook to write the information for the entire itinerary?

RE: Trouble getting macro to loop in Outlook

Hi,
And the code at issue is.....??

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
sorry, here's the code that I'm using:

reply "*i`<transmit>";

wait 5 ticks

for i = 1 to (ypos-1)

seg_nbr = strip(winstring (i,1,2), " ", 1)

seats = strip(winstring (i,45,19)," ",1)
if seats = "/UA" then seatsb = ""
if seats = "/R" then seatsb = " "
seatsa = subst (seats,"*","/")
seatsb = strip(seatsa, "/ ", 1)
dept_time = strip(winstring (i,33,4), " ", 2)
depart_time = pad(dept_time,4,"0",2)
dept_timea = insert(depart_time,":",3)
dept_timeb = strip(dept_timea,"0",2)
action_code = winstring(i,28,2)
if action_code = "WK" then goto skip_this_itin_line ----this is working
if action_code = "UN" then goto skip_this_itin_line
wait 1 ticks
--arnk = winstring(i,6,4)
--if arnk = "ARNK" then goto skip_this_itin_line ----this is not working as of 12feb/spi
------------------------------------------------------------------------------------------------------------
al_code = winstring(i,4,2)

----------------------------------------------------
flt_num = strip(winstring (i,6,4),"",2)
if flt_num = "ARNK" then goto skip_this_itin_line
if al_code = "US" then airline = "US%20Airways" else goto DETAILS
fnbr = val(flt_num)



if fnbr<2000 then airline = "%20" :goto DETAILS
if fnbr<2200 then airline = "%20-%20US Airways%20Shuttle%20Flight" :goto DETAILS
if fnbr>2199 and (fnbr<2600) then airline = "%20-%20Operated%20by%20PSA%20dba%20US%20Airways%20Express" :goto DETAILS
if fnbr>2599 and (fnbr<2850) then airline = "%20-%20Operated%20by%20Mesa%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>2849 and (fnbr<3000) then airline = "%20-%20Operated%20by%20SkyWest%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>2999 and (fnbr<3100) then airline = "%20-%20Operated%20by%20Chautauqua%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>3099 and (fnbr<3500) then airline = "%20-%20Operated%20by%20Republic%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>3499 and (fnbr<3550) then airline = "%20-%20Operated%20by%20Trans%20States%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>3549 and (fnbr<4100) then airline = "%20-%20Operated%20by%20Air%20Wisconsin%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>4099 and (fnbr<4650) then airline = "%20-%20Operated%20by%20Piedmont%20dba%20US%20Airways%20Express":goto DETAILS
if fnbr>4799 and (fnbr<4850) then airline = "%20-%20Operated%20by%20Aegean%20Airlines":goto DETAILS
if fnbr>4849 and (fnbr<4900) then airline = "%20-%20Operated%20by%20Tam%20Airlines":goto DETAILS
if fnbr>4899 and (fnbr<4912) then airline = "%20-%20Operated%20by%20Lacsa%20Airlines":goto DETAILS
if fnbr>4911 and (fnbr<4970) then airline = "%20-%20Operated%20by%20Taca%20Airlines":goto DETAILS
if fnbr>4969 and (fnbr<5000) then airline = "%20-%20Operated%20by%20Qatar%20Airways":goto DETAILS
if fnbr>4999 and (fnbr<5050) then airline = "%20-%20Operated%20by%20Turkish%20Airlines":goto DETAILS
if fnbr>5049 and (fnbr<5100) then airline = "%20-%20Operated%20by%20TAP%20Air%20Portugal":goto DETAILS
if fnbr>5099 and (fnbr<5150) then airline = "%20-%20Operated%20by%20Swiss%20International%20Airlines":goto DETAILS
if fnbr>5149 and (fnbr<5200) then airline = "%20-%20Operated%20by%20All%20Nippon":goto DETAILS
if fnbr>5199 and (fnbr<5270) then airline = "%20-%20Operated%20by%20Asiana":goto DETAILS
if fnbr>5299 and (fnbr<5350) then airline = "%20-%20Operated%20by%20Air%20New%20Zealand":goto DETAILS
if fnbr>5349 and (fnbr<5400) then airline = "%20-%20Operated%20by%20Air%20China":goto DETAILS
if fnbr>5399 and (fnbr<5450) then airline = "%20-%20Operated%20by%20Singapore%20Air":goto DETAILS
if fnbr>5549 and (fnbr<5600) then airline = "%20-%20Operated%20by%20South%20African%20Airways":goto DETAILS
if fnbr>5599 and (fnbr<5900) then airline = "%20-%20Operated%20by%20Lufthansa":goto DETAILS
if fnbr>5899 and (fnbr<6000) then airline = "%20-%20Operated%20by%20Brussels%20Air":goto DETAILS
if fnbr>5899 and (fnbr<6910) then airline = "%20-%20Operated%20by%20United%20Airlines":goto DETAILS
if fnbr>6909 and (fnbr<8000) then airline = "%20-%20Operated%20by%20United%20Express":goto DETAILS
if fnbr>7999 and (fnbr<8050) then airline = "%20-%20Operated%20by%20Avianca": goto DETAILS
if fnbr>8449 and (fnbr<8600) then airline = "%20-%20Operated%20by%20Hawaiian%20Airlines":goto DETAILS
if fnbr>8599 and (fnbr<8650) then airline = "%20-%20Operated%20by%20Croatian":goto DETAILS
if fnbr>8699 and (fnbr<8710) then airline = "%20-%20Operated%20by%20Royal%20Jordanian":goto DETAILS
if fnbr>8709 and (fnbr<8740) then airline = "%20-%20Operated%20by%20Eva%20Airlines":goto DETAILS


-------------------------------------------------------------------------------------------------

LABEL DETAILS

if al_code = "UA" then airline = "%20-%20United Airlines":goto Formatting
if al_code = "AA" then airline = "%20-%20American%20Airlines":goto Formatting
if al_code = "DL" then airline = "%20-%20Delta%20Air%20Lines":goto Formatting
if al_code = "LH" then airline = "%20-%20Lufthansa":goto Formatting
if al_code = "JP" then airline = "%20-%20Adria%20Airways":goto Formatting
if al_code = "A3" then airline = "%20-%20Aegean%20Airlines":goto Formatting
if al_code = "AC" then airline = "%20-%20Air%20Canada":goto Formatting
if al_code = "CA" then airline = "%20-%20Air%20China":goto Formatting
if al_code = "NZ" then airline = "%20-%20Air%20New%20Zealand":goto Formatting
if al_code = "NH" then airline = "%20-%20All%20Nippon%20Airways":goto Formatting
if al_code = "OZ" then airline = "%20-%20Asiana%20Airlines":goto Formatting
if al_code = "KF" then airline = "%20-%20Blue1":goto Formatting
if al_code = "BD" then airline = "%20-%20British%20Midland%20Airways":goto Formatting
if al_code = "SN" then airline = "%20-%20Brussels%20Airlines":goto Formatting
if al_code = "OU" then airline = "%20-%20Croatia%20Airlines":goto Formatting
if al_code = "MS" then airline = "%20-%20Egypt%20Air":goto Formatting
if al_code = "ET" then airline = "%20-%20Ethiopian%20Airlines":goto Formatting
if al_code = "LO" then airline = "%20-%20LOT%20Polish%20Airlines":goto Formatting
if al_code = "SK" then airline = "%20-%20Scandinavian%20Airlines":goto Formatting
if al_code = "SQ" then airline = "%20-%20Singapore%20Airlines":goto Formatting
if al_code = "SA" then airline = "%20-%20South%20African%20Airways":goto Formatting
if al_code = "OU" then airline = "%20-%20Croatia%20Airlines":goto Formatting
if al_code = "LY" then airline = "%20-%20El%20Al":goto Formatting
if al_code = "TP" then airline = "%20-%20Air%20Portugal":goto Formatting
if al_code = "LX" then airline = "%20-%20Swiss%20International%20Airlines":goto Formatting
if al_code = "JJ" then airline = "%20-%20Tam%20Linhas%20Aereas":goto Formatting
if al_code = "TG" then airline = "%20-%20Thai%20Airways":goto Formatting
if al_code = "TK" then airline = "%20-%20Turkish%20Airlines":goto Formatting
if al_code = "UP" then airline = "%20-%20Bahamasair":goto Formatting
if al_code = "WM" then airline = "%20-%20Windward%20Island%20Airways%20Intl":goto Formatting
if al_code = "EI" then airline = "%20-%20Aer%20Lingus":goto Formatting
if al_code = "IB" then airline = "%20-%20Iberia":goto Formatting
if al_code = "RJ" then airline = "%20-%20Royal%20Jordanian":goto Formatting
if al_code = "1B" then airline = "%20-%20Abacus%20International":goto Formatting
if al_code = "B6" then airline = "%20-%20JetBlue%20Airways":goto Formatting
if al_code = "9K" then airline = "%20-%20Cape%20Air":goto Formatting
if al_code = "BA" then airline = "%20-%20British%20Airways":goto Formatting
if al_code = "VS" then airline = "%20-%20Virgin%20Atlantic":goto Formatting
if al_code = "VX" then airline = "%20-%20Virgin%20America":goto Formatting
if al_code = "QF" then airline = "%20-%20Qantas%20Airways":goto Formatting
if al_code = "EK" then airline = "%20-%20Emirates":goto Formatting
if al_code = "AS" then airline = "%20-%20Alaska%20Airlines":goto Formatting
if al_code = "F9" then airline = "%20-%20Frontier%20Airlines":goto Formatting
if al_code = "ZK" then airline = "%20-%20Great%Lakes%20Air": goto Formatting






LABEL Formatting
flt = pad(flt_num, 4,"%20",2)
flt_date = winstring (i,12,5)
flt_datea = pad(flt_date,5,"%20",2)
flt_dateb = insert(flt_datea,"%20",3)


arr_time = winstring (i,39,4)
arrive = strip(arr_time," ", 2)
arrival_time = pad(arrive,4,"0",2)
arr_timea = insert(arrival_time,":",3)
arr_timeb = strip(arr_timea, "0",2)

arr_time_am_pm = winstring(i,43,1)


if arr_time_am_pm = "A" then arr_time_am_pm = "AM"
if arr_time_am_pm = "P" then arr_time_am_pm = "PM"

if arr_time_am_pm = "N" then arr_time_am_pm = "PM"

dept_am_pm = winstring (i,37,1)

if dept_am_pm = "A" then dept_am_pm = "AM"

if dept_am_pm = "P" then dept_am_pm = "PM"
if dept_am_pm = "N" then dept_am_pm = "PM"
------------------------------------------------------------------------

----------------------------------------------------------------------
orig = winstring (i,21,3)
gosub find_orig


wait 1 tick
label found_orig



dest = winstring(i,24,3)
gosub find_dest

desta = dest


label found_dest
wait 2 ticks

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


linessss="----------------------------------------------------------------------------------------------"


itinstr = "%0dDate:%20"+flt_dateb+"%09Flight:%20"+al_code+flt+airline+"%0dDeparts:%20%20"+orig+"%20at%20"+dept_timeb+"%20"+dept_am_pm+"%0dArrives:%20%20"+desta+"%20at%20"+arr_timeb+"%20"+arr_time_am_pm+"%0dSeat(s):%20"+seatsb+"%0d"

RE: Trouble getting macro to loop in Outlook

You have no Outlook Objects in you code???

How does code like this execute, with DASHES???

CODE

--if arnk = "ARNK" then goto skip_this_itin_line ----this is not working as of 12feb/spi 
"Not working" is not a helpful comment! It is vague, and posits a plethora of possibilities!

I was looking for your "loop in Outlook"???

What language is "wait 1 tick"???

BTW, waiting a specific length of time is akin to pulling up to a traffic light and waiting 5 seconds, for instance. Do you get how absurd that would be? Rather, use a technique that waits for the cursor to return to the screen's rest opinion in a loop.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
We must be using a simpler code method. Supposedly, though, this is CASL Macro language. We're not talking Extra! - just the in app text editor. We've already got the sessions established. All we set up is code that works with reservations.

The items with dashes do not execute. Waiting ticks is essentially like pulling up to a traffic light. The odd thing is, this doesn't work unless you have it sitting at a traffic light.
What the code does is display the itinerary, then go through and scrape the flight number, date, origin and destination. Finally, it's supposed to do is take that information and write it to an e-mail.

RE: Trouble getting macro to loop in Outlook

Well you still have not posted ANYTHING regarding OUTLOOK! No LOOP!

Quote:

Waiting ticks is essentially like pulling up to a traffic light. The odd thing is, this doesn't work unless you have it sitting at a traffic light.
So you just WAIT a certain length of time at traffic lights, even if the light might turn GREEN before that period expires, and then GO, even when the light might be RED when the period expires? REALLY???

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
Here's the last bit of code (edited for privacy). Perhaps saying Outlook was a bit inaccurate. It won't call Outlook by name. The macro simply composes an e-mail in whatever the default mail program is. At my company, it happens to be Outlook.

label skip_this_itin_line

next i





label alldone

reply "<clear>";

message "Done"



Alert "Change From Field to Inventory Services (inventorysvcs@xxx.com)",ok
emailstr=paxemail
subjectstr="XXX%20Itinerary%20Change%20Confirmation"
bodystr="Hello,%0dThis%20is%20to%20confirm%20you%20have%20voluntarily%20changed,%20at%20our%20request,%20from%20"+probflt+"%20to%20"+reaccom+".%20%20You%20may%20also%20view%20your%20changes%20online%20under%20'Manage%20Reservations'%20at%20XXX%20by%20entering%20your%20confirmation%20code%20and%20travel%20date.%20%20"+comptxt
bodystr1 = "%0dThank%20you%20for%20your%20cooperation%20and%20assistance.%0dXX%0d%0dYour%20new%20itinerary:%0d%0dConfirmation%20Code:%20%20"+rloc+"%0d"
run "mailto:"+emailstr+"?subject="+subjectstr+"&body="+bodystr+bodystr1+itinstr

halt

end

label stopnow
halt

end

What is supposed to happen is, ideally, "itinstr" is written 2,3,4, or however many times is needed.

RE: Trouble getting macro to loop in Outlook

(OP)
BTW, the macro needs to sit at the green light, or else it doesn't properly scrape the data off the displays.

RE: Trouble getting macro to loop in Outlook

Quote:

Here's the last bit of code (edited for privacy).
HUH! You have proprietary DATA in your code that you cannot launder???

Quote:

What is supposed to happen is, ideally, "itinstr" is written 2,3,4, or however many times is needed.
Well HOW do you determine "however many times is needed"? What is THAT logic???

Quote:

Perhaps saying Outlook was a bit inaccurate.
Please state accurate information, if you want accurate information in return!

Quote:

BTW, the macro needs to sit at the green light, or else it doesn't properly scrape the data off the displays.
If the light is green, it implies that the screen is ready to accept commands. In that even, your code would be waiting unnecessarily.

However, and of much greater concern, if, after waiting a specific period of time, your screen STILL is not ready to accept data and commands (ie, the light is STILL RED!!!) your code proceeds and in so doing, CAUSES DATA TO BE LOST!!! This sort of thing can and will happen in emulators that interface asynchronous systems. The traffic light analogy, is designed to point out the absurdity of ALWAYS STOPPING at a traffic light A FIXED LENGTH OF TIME.

I agree that the analogy falls apart when the light is green when you arrive. You must stop and wait for your screen to respond.

But assuming that the light is RED when you arrive, you should always wait UNTIL THE LIGHT TURNS GREEN and not a nanosecond sooner or later!

Bottom Line: When controlling a screen interfacing an asynchronous system, do not use static wait values or you run the risk of loosing data!


Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
Forgive my poor information. I'll try to clarify things.
First, a tick equals .1 second
Where the macro gets the information as to how many segments are in the itinerary is in this line

CODE --> Script

for i = 1 to (ypos-1) 

This tells the macro to read the itinerary from row 1 to 1 row above where the cursor is. Everything that follows is in this format

CODE --> Script

al_code = winstring(i,4,2) 

so let's say you had an itinerary that read like this:
[quote ]
1 US3229U 16OCT TU PVDDCA HK1 628A 757A 09D*
2 US3151U 16OCT TU DCAMSP HK1 825A 1018A 10D*
3 US1836G 18OCT TH MSPPHL HK1 145P 520P 13C*
4 US3656G 18OCT TH PHLPVD HK1 625P 744P 03D*
[/qoute]
The macro would read down in column 4, looking for 2 characters, and would call the resulting variable al_code. The result would, or rather should be, this:

US
US
US
US

What our e-mail program gives me is this:
US

RE: Trouble getting macro to loop in Outlook

Well I never saw a For...Next in your original post. So I don't know where the loop ends???


It is difficult to understand incomplete code.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
Here's the full for...next loop:

CODE -->

for i = 1 to (ypos-1)
seats = strip(winstring (i,45,19)," ",1)
dept_time = strip(winstring (i,33,4), " ", 2)
arr_time = strip(winstring (i,39,4), "",2)
action_code = winstring(i,28,2)
if action_code = "WK" then goto skip_this_itin_line    
if action_code = "UN" then goto skip_this_itin_line

flt_date = winstring (i,12,5)
flt_num = strip(winstring (i,6,4),"",2)
if flt_num = "ARNK" then goto skip_this_itin_line

label skip_this_itin_line
next i 

So what it should do is copy every line unless it encounters either a "UN", "WK" or an "ARNK". Where it does encounter one of those three conditions, it skips that line. Notepad handles this without difficulty.

RE: Trouble getting macro to loop in Outlook

Okay. Then I'd guess that something goes HERE

CODE

if flt_num = "ARNK" then goto skip_this_itin_line
'code here that you do do NOT want to skip
label skip_this_itin_line
next i 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Trouble getting macro to loop in Outlook

(OP)
Well, after a little tinkering, I've gotten the macro to do what I want; it just doesn't do it how I want. The issue seems to be with our e-mail program rather than the macro.

What seems to be at the root is this string:

CODE -->

linessss="-------------------------------------------------------------------------------------------------------------"
string1 = linessss+"%0dDate:%20"+flt_dateb+"%09Flight:%20"+al_code+flt_num+airline+"%0dDeparts:%20%20"+orig+"%20at%20"+dept_timeb+"%20"+dept_am_pm+"%0dArrives:%20%20"+desta+"%20at%20"+arr_timeb+"%20"+arr_time_am_pm+"%0dSeat(s):%20"+seatsb+"%0d"+linessss 
All of the variables are stored in this string. What I want it to do is write this string multiple times in a single e-mail, so that if this was your itinerary:
ABC123 -ETKT- *FQ
1. 1DOE/JANE
1 US2703S 06OCT SA TUSPHX HK1 310P 400P
2 US 409S 06OCT SA PHXSFO HK1 450P 649P 21C*
FONE-
1.WEB5551212*DAYOFDEPFON/EH925
2.WEB*USAIRWAYS.COM BOOKING/N000
3.WEB*EMAIL-SOMEONE*SOMEWHERE.COM/N000

This would be the hypothetical e-mail you'd get:

Hello,
This is to confirm that you have voluntarily changed, at our request, from flight 415 on October 6 to flight 409 on October 6. As compensation, each passenger will be issued one (1) Electronic Transportaion Voucher, which is valid for $200 off your next US Airways ticket purchase. We will send an email confirmation for your voucher(s) within four to six weeks after your travel has been completed.

Thank you for your coooperation and assistance
US Airways - Inventory Services

Your new itinerary:

Confirmation code: ABC123
--------------------------------------------------------------------
Date: 06 OCT Flight: US2703 - Operated by Mesa Airlines dba US Airways Express
Departs: Tucson, AZ at 3:10pm
Arrives: Phoenix, AZ at 4:00pm
Seat(s):
---------------------------------------------------------------------
---------------------------------------------------------------------
Date: 06 OCT Flight: US 409
Departs: Phoenix, AZ at 4:50pm
Arrives: San Francisco, CA at 6:49pm
Seat(s): 21C
---------------------------------------------------------------------

What I get instead is two seperate emails - one for each segment - with the string written once. Since I know I can get it to work the way I want when I write to a .txt file, I'm thinking the best way is to let the macro write to the .txt file, and then copy and paste into the email. Is this possible in CASL?

RE: Trouble getting macro to loop in Outlook

Why write it to a file? Why not just concatenation each text segment to a string variable? Then it's ALL right there!

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close