I am writing an applescript to grab some end of month reports from my mainframe. I am having an issue with the way the mainframe sets the list of reports up. Each report has a name and a number to select it. The name is the same all of the time, but the name/number (Description/Seq#) relationship changes every time.
I need to know how to get applescript to look for the “name” and then decide what number it is.
Can I do this or is applescript to juvenile for this?
Also, on another issue kind of pertaining to this… I know how to delay, but instead of using delay is there a way I can say wait for a specific text string?
Thanks for your help in advance.
Model: MacBook Pro Core duo
AppleScript: 2.1.1(81)
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)
set Rept to "Seq# ID Description Prior Sub-sq Size
------------------------------------------------------------------------------------------------------------
1 01050773 Print the payment/deposit register DONE 77300 341
2 01050774 Print a salesman commission report 0 77400 5
3 01050775 Print an invoiced sales tax report 0 77500 7
4 01050776 Print a customer invoiced sales report 0 77600 191
5 01050778 Print the monthly invoice reg. and sales journal 0 77800 55
6 00150785 Service Charge Journal 0 78500 14
7 00150786 Aged Receivables Report 0 78600 521
8 00150787 Cash Receipts Journal 0 78700 232
9 00150788 Customer Statements DONE 78800 396"
set theNums to {}
set myNames to {"Print the payment/deposit register", "Print a salesman commission report", "Aged Receivables Report"}
repeat with k from 3 to count of paragraphs of Rept
repeat with j from 1 to count of myNames
tell item j of myNames
if paragraph k of Rept contains it then
set AppleScript's text item delimiters to it
set theFront to first text item of paragraph k of Rept
set end of theNums to first word of theFront
set AppleScript's text item delimiters to ""
end if
end tell
end repeat
end repeat
theNums --> {"1", "2", "7"}
If you want to reassociate the search terms with the numbers, add this in place of theNums in the above:
set theOutput to "The numbers are ..." & return & return
repeat with j from 1 to count of myNames
set theOutput to theOutput & item j of myNames & " --> " & item j of theNums & return
end repeat
theOutput
With respect to your second question, the answer is yes, but you’ll have to be a lot more specific.
Finally, I think you meant “… is applescript too juvenile for this?” That’s a NO
Please forgive me for being ignorant and thank you for helping me…
I need to tell applescript the BOLD numbers are equal to the the italicized descriptions. So when I call for a specific one, say Print a salesman commission report it knows what BOLD number that is and then enters that number. So in this case it would enter 2. Does your reply do that? Again pardon me for being ignorant. I expected a very simple reply.
ps… The underlined items do nothing and I am not concerned with them at all.
Seq# ID Description Prior Sub-sq Size
101050773Print the payment/deposit registerDONE 77300 341 201050774Print a salesman commission report0 77400 5 301050775Print an invoiced sales tax report0 77500 7 401050776Print a customer invoiced sales report0 77600 191 501050778Print the monthly invoice reg. and sales journal0 77800 55 600150785Service Charge Journal0 78500 14 700150786Aged Receivables Report0 78600 521 800150787Cash Receipts Journal0 78700 232 900150788Customer StatementsDONE 78800 396
And as for…
Also, on another issue kind of pertaining to this… I know how to delay, but instead of using delay is there a way I can say wait for a specific text string?
Say I want to login to my unix box via telnet… This is what I have so far…
set CR to ASCII character of 13
tell application "System Events"
tell application "Terminal" to activate
keystroke "telnet 192.168.1.100" & CR
delay 4
keystroke "root" & CR
delay 2
keystroke "pass" & CR
end tell
Instead of saying delay can I put something like… wait “root’s Password:”
and if I could do that I could do that for the login itself also?
Maybe it is me that is too juvenile? This keyboard on my MacBook Pro kind of takes some getting used to misspellings are common as of late.
With respect to the script I proposed: it’s dealing with the plain ASCII text of your example, doesn’t know about bold or italics. Whatever you enter as text in the set myNames line, will be sought as text regardless of formatting. I’ve changed the line “set the front to the second item of paragraph k of Rept” in my original post to first item, which is the leading number in your example. Again, the script locates it by position, not by formatting.
Your task is to read the text of the report into an applescript variable, but I don’t know anything about how you get it. I just copied your example in quotes in the first line of the script. Formatting can be problematic if this document is in rich text format or something like that, but you will find examples here in the bbs for extracting the plain ASCII text from that if it gives you grief. If your telnet script downloads a text file, then you can just read the file into your variable: set Rept to read file (path to the file).
I can’t check your telnet script because I don’t have a machine to telnet to, but there is a way (can’t think of it) to put all the required information in one line - you don’t have to wait for the other system to ask. Hopefully, someone who telnets regularly will answer.
With respect to AppleScript’s capabilities, there are now a fair number of AppleScript applications “out there” on VersionTracker, etc. These are written in AppleScript and built as applications with proper GUIs in XCode. For some things, AS is not the language of choice for speed, but generally it can accomplish a lot.
That line worked quite well. I found it searching through this wonderful site. Edit… Actually, now I am not even sure if this is any different from delay? Anybody know for sure?
And from looking around, I believe your suggestion of using set will work nicely. Again, I am new to this. Just started this morning. So far I love applescript! I am sure that there will be some things about it I do not care for but right now I am satisfied.
I am downloading the intel version of XCode right now. Hopefully that will help a bit.