Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statements help

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
I have no experience with If Statements. But I think I need one to accomplish this task unless there is another way to do it.
I have a specific screen that has "Morbiles" which is a > that is underlined. Placing the cursor on it and typing "M" and press enter brings up another screen that I have to copy to a file then go back and do the next one. Problem is this screen could have no Morbiles or up to 6 morbiles. Hence the problem. After all the screens are copied to the file the macro sends the file to print.

Here is that part of the code.

Shell "Notepad c:\My Documents\Print.txt"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}"

‘This section is a continuation from coping several other screens until I get to this screen.
Sess0.Screen.Sendkeys("<PF10>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 10,68 'Moves to the First Morbile “ > “
‘Morbiles could exist on 11,68, 12,68, 13,68 thru 16 or none at all.’
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("M<Enter>") ‘brings up another screen
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
Set MyScreen = Sess0.Screen
MyScreen.SelectAll
MyScreen.Copy
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<PF3>") ‘back to the morbile screen
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop

AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Enter 8}%EP" ‘-----------------------Paste in Notepad
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}" 'back to attachmate
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop

‘If Morbile exists go to each morbile “m <Enter>” and copy each page to Print.txt.
‘Then print the file.
' Prints the File
AppActivate "Print.txt - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FP"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "-"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%P"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%FX"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "N"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout
End sub
 
sbc,

i'm not sure if i understand your problem correctly. can you elaborate on what should transpire?

is this what you mean?
call up screen with Morbiles
on this screen, there could be 7 instances of ">"
for each instance, jump to another screen
send that to printer
so if there were 7 instances, you would have 7 documents sent to printer

zach
 
The screen with Morbils shows there are other screens present.
I type an M on the first Morbile and hit enter which brings up the screen for that morbil. Copy the screen then PF3 back to the morbile screen then past the copied screen in the file. Put M on the second morbile press enter which brings up the screen for that morbile, copy to file and so on. The number of morbils could be 0-6.
> 123456
> 136457
> 145458
> 125690

After all the morbil screens have been copied to the file,
Then I go to the file to print the file.

Morbiles could exist on 11,68, 12,68, 13,68 thru 16,68 or none at all.'

If none exist then just print the file "which contains the screens I have alread copied there" before I got to the screen with morbils.

After I copy a screen, I paste it in the file and add 9 carriage returns.
This is so 2 screens print on one page. It works out perfect and saves paper.
 
Also there are other Morbils on the Morbil screen that I am not concerned with. Only if they exist at 10,68;11,68;12,68 and so on.
 
i would do something like this. i don't know how you would know there is a morbil so i made an assumption that in column 68 there is a ">" character. see if this makes any sense.

Code:
            for x = 10 to 16
            
                a = sess.getstring (x, 68, 1)
                
                if a = ">" then
                
                    sess.putstring "M", x, 68
                    
                    'your code goes here
                    
                end if
                
            
            next

just curious about why you use the method you use to copy and paste.

zach
 
Thanks Zach but this is going to be more complicated than I thought. I found out that on certain accounts (I don't know which ones but not all accounts) the programmers for our system made a popup screen. When putting an M on the first morbil and pressing enter, a screen pops up with a message and you have to enter Y and press enter to get to the screen I need. Problem is they didn't make it to be able to go back to the morbil screen for the next morbil.

Instead, I have to copyappend each row of account numbers next to the morbil. Then I can use pastecontinue on the bottom go line to get to each screen. Morbils will be 0-4.
> 5326589
> 7520456
> 6547852
> 4532547

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top