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!

*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

IF Statements help

IF Statements help

IF Statements help

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"
        Sendkeys "%{tab}"

'This section is a continuation  from coping several other screens until I get to this screen.       
        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.Sendkeys("M<Enter>")  'brings up another screen    
        Do While sess0.Screen.OIA.Xstatus <> 0
        Set MyScreen = Sess0.Screen
        Sess0.Screen.Sendkeys("<PF3>")  'back to the morbile screen
        Do While sess0.Screen.OIA.Xstatus <> 0

        AppActivate "Print.txt - Notepad"
        Sendkeys "{Enter 8}%EP"  '-----------------------Paste in Notepad
        Sendkeys "%{tab}" 'back to attachmate
        Do While sess0.Screen.OIA.Xstatus <> 0

'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"
        Sendkeys "%FP"
        Sendkeys "{Tab}"
        Sendkeys "-"
        Sendkeys "%P"
        Sendkeys "%FX"
        Sendkeys "N"

   System.TimeoutValue = OldSystemTimeout
End sub

RE: IF Statements help


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


RE: IF Statements help

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.

RE: IF Statements help

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.

RE: IF Statements help

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.


            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

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


RE: IF Statements help

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


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