×
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

Having difficulty with an If Statement.

Having difficulty with an If Statement.

Having difficulty with an If Statement.

(OP)
The second If Statement is completely ignored when this runs in refection. I have tried it several different ways.  I want to keep the code as simple as possible because it will be modified in the future by end users.

Sub Test()

  On Error GoTo ErrorHandler

    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr(rcCR) = Chr(13) = Control-M
    Dim yArray(3)

    CR = Chr(Reflection2.ControlCodes.rcCR)

    yArray(0) = "A!A"
    yArray(1) = "B!B"
    yArray(2) = "C!C"
    yArray(3) = "D!D"

   With Session
    
    For i = 0 To 3
    
      
    If .WaitForString("Enter:", NEVER_TIME_OUT, rcAllowKeystrokes) Then
    .Transmit yArray(i)
    .Transmit CR
    End If

    If .WaitForString("      ...OK? Yes//", NEVER_TIME_OUT, rcAllowKeystrokes) Then
    Retest
    End If

    Next
    
    End With
    
    Exit Sub

ErrorHandler:
      Session.MsgBox Err.description, vbExclamation + vbOKOnly

    End Sub

RE: Having difficulty with an If Statement.



hi,

I believe that the WaitForString method need a SCREEN object reference, not a SESSION object.

Skip,

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

RE: Having difficulty with an If Statement.

(OP)
I am using Reflection.  According to the help and everything else I have read the syntax is correct, I'm missing something else?
It waits for the string of text. I can move the end of the Loop (Next) above the second if statement and the Macro runs with out a hitch unless the string     ...OK? Yes// comes up the I have to hit CR twice and it will continue. I would like to be able to hit run and walk away...As of now the array is accually 38 long and growing. Like i said the macro steps through the array just fine unless...

Function WaitForString(String As String, [Timeout], [Options]) As Boolean
    Member of Reflection2.Session
    Wait for a specified string from the host
 

RE: Having difficulty with an If Statement.

i'm not familiar with Reflection,but in using Attachmate, it states:

Description

Waits until the specified text appears on the screen. This method will wait for the amount of time set in the System.TimeoutValue.

not sure if this helps or not

 

RE: Having difficulty with an If Statement.

(OP)
Maybe I'm completely out in left field?  I don't have any problem with the array, it runs like a champ. The problem is the conditional statement.  It is either completely ignored as if it isn't there at all.  Or runs as if it isn't conditional.  Might as well not have the If...Then....End If at all.  Runs like it is a required statement and stops the macro waiting on the prompt. Any suggestions would be great.   



Sub Test()
'
' Per clinic
' Macro created 8/8/2011 by vhamoumorelh
'
    Const NEVER_TIME_OUT = 0
    Dim yArray(3)
  
    yArray(0) = "A!A"
    yArray(1) = "B!B"
    yArray(2) = "C!C"
    yArray(3) = "D!D"

On Error GoTo ErrorHandler:

    For i = 0 To 3
   
        Reflection2.Session.WaitForString "Select Patient name or Clinic name:", NEVER_TIME_OUT, rcAllowKeystrokes
        Reflection2.Session.Transmit yArray(i)
        Reflection2.Session.Transmit vbCr

    'Next - Conditional statement does not run until array is complete?
       
        If Reflection2.Session.WaitForString("        ...OK? Yes// ", NEVER_TIME_OUT, rcAllowKeystrokes) Then
        Retest
        End If
        
    Next '- Conditional statement runs as if required with each instance of array? Stops the Maro waiting on prompt.
        
    Exit Sub

ErrorHandler:
    MsgBox "Failed" _
        & vbCrLf & vbCrLf & Err.description, vbCritical


End Sub

Sub Retest()
    On Error GoTo ErrorHandler

    Const NEVER_TIME_OUT = 0

    Dim LF As String    ' Chr(rcLF) = Chr(10) = Control-J
    Dim CR As String    ' Chr(rcCR) = Chr(13) = Control-M

    LF = Chr(Reflection2.ControlCodes.rcLF)
    CR = Chr(Reflection2.ControlCodes.rcCR)

    With Session
        
        .StatusBar = "Waiting for Prompt: ...OK? Yes//"
        .WaitForString LF & "        ...OK? Yes// ", NEVER_TIME_OUT, rcAllowKeystrokes
        .StatusBar = ""
        .Transmit CR
        .Transmit CR

    End With
    Exit Sub

ErrorHandler:
    Session.MsgBox Err.description, vbExclamation + vbOKCancel

   
End Sub

RE: Having difficulty with an If Statement.



What is Reflection2?

Along with Session, it is UNDECLARED and UNASSIGNED!!!

See FAQ99-4069: How do I use VB(A) to manipulate attachmate (6.5+)?

In Attachmate Extra, the object reference for the WaitForString method is a SCREEN object, not a session object.

Skip,

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

RE: Having difficulty with an If Statement.

(OP)
Reflection for UNIX and OpenVMS is a connectivity software application. Reflection establishes and maintains communications between a host computer and your PC running Microsoft Windows XP, Windows 2000 Server or Workstation, or Windows Server 2003. With Reflection, your PC emulates, or operates like a VT-series, ADDS, DG, Unisys T27, WYSE terminal, or Linux console. This allows you to communicate with the host just as if you were using a terminal, and maintain a host connection while running other Windows applications.

Reflection emulates the following terminals: VT525, VT520, VT510, VT420, VT320, VT220, VT102, VT52, AT386, BBS-ANSI, SCO-ANSI, DG215, ADDS VP2, WYSE 50 and 60, IBM 3151, Unisys T27, TVI 955, TVI 950, VT-UTF8, QNX, and XTERM terminals. Support for the Linux console is also included.

©1994-2006 Attachmate Corporation

RE: Having difficulty with an If Statement.

(OP)
The issue is not the Reflection2.Session.WaitForString("        ...OK? Yes// ", NEVER_TIME_OUT, rcAllowKeystrokes)it is the If...Then...End If. It seems as if it is ignored? Or could it be because it is running in Reflection?
 

RE: Having difficulty with an If Statement.



You really did not answer my question/issue, TWICE stated on TWO different posts.  Your problem, not mine!

Try testing in a loop

CODE

Do
  if YourScreenObject.WaitForString(YourString) then
      Retest
      exit do
  end if
Loop
 

Skip,

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

RE: Having difficulty with an If Statement.

(OP)
I tried the loop.  I tried setting the screen as an object several different ways. I have attached a screen shot of the object browser showing how I got the Reflection2.Session.WaitForString - It came direct from the object browser.  This is an enterprise environment and I have never tried to write a macro to run on an user desktop in reflection(Attachmatte) so I may be way out in left field here...It is for an end user and she wants to be able to and to the array as needs change...

RE: Having difficulty with an If Statement.



We cannot "see" your C Drive!!!

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