|
-
Jun 7th, 2013, 08:56 AM
#1
Thread Starter
Junior Member
Help with GoTo statements and looping
Firstly, I'm new.
I'm scripting something that uses FORTRAN and need some help... I believe IF/THEN statements don't work properly here, so I'm forced to use "GoTo" statements.
**Goal**: I'm trying to create a script that repeats itself, then stops when it recognizes the end point. The end statement is "Waiting for Prompt: Default Portal:" Each time I run this, I want it to remove a random set of lines. I successfully got this to run a static 16 times, but wanted something more automated. The system I'm trying to run the script on is CLI based, if that helps.
**Problem**: It seems to get stuck in a loop, I think.
**Code**: See below...
*************************
rmvseconds:
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
GoTo ending
Else
GoTo rmvseconds:
ending:
.Transmit CR
.Transmit CR
End If
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
********************
-
Jun 7th, 2013, 09:41 AM
#2
Re: Help with GoTo statements and looping
ok... let's think about this... basically you want to run some commands in a loop until a particular text is received, at which point, it exists out...
Code:
do loop 'Start the loop
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
until .StatusBar = "Waiting for Prompt: Default Portal:" 'loop untl the status bar changes to this text
.Transmit CR
.Transmit CR
'There's probably more here that you're not showing....
'Exti so we don't fal into the error handle...
Exit Sub
'Presumably there's an On Error Goto ErrorHandler somewhere back at the top...
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
-tg
-
Jun 7th, 2013, 10:30 AM
#3
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
When I try to perform "do loop" it throws me an error "Compile error: Expected: While or Until at end of statement" From what I can tell, FORTRAN doesn't support do-loop structure. In case you were wondering why I was trying to use "GOTO".
http://www.obliquity.com/computer/fortran/do.html
"FORTRAN does not have a formal do-while loop structure but it is easy to construct one using IF and GOTO statements."
For some reason when I pasted some of the code was left out, I'll repost it in entirety.
Code:
Sub Newscript()
' Generated by Reflection for UNIX and OpenVMS 14.1.0.
On Error GoTo ErrorHandler
With Session
rmvseconds:
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
If .StatusBar = "Waiting for Prompt: Default Division:" Then
GoTo ending
Else
GoTo rmvseconds:
ending:
.Transmit CR
.Transmit CR
End If
End With
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
I hope I got this right, because I can't edit my posts..
-
Jun 7th, 2013, 10:36 AM
#4
Re: Help with GoTo statements and looping
To use a do while structure it would be
Code:
do while not .StatusBar = "Waiting for Prompt: Default Portal:" 'loop untl the status bar changes to this text
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
Loop
.Transmit CR
.Transmit CR
That is the structure but I see that in your code you are setting the .StatusBar="" which looks like it would cause an infinite loop
-
Jun 7th, 2013, 12:53 PM
#5
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
 Originally Posted by DataMiser
To use a do while structure it would be
Code:
do while not .StatusBar = "Waiting for Prompt: Default Portal:" 'loop untl the status bar changes to this text
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
Loop
.Transmit CR
.Transmit CR
That is the structure but I see that in your code you are setting the .StatusBar="" which looks like it would cause an infinite loop
The .StatusBar = "Waiting for Prompt: Default Portal:" is the field that the CLI menu outputs when it requests the next field. I'm using it as a marker for when to exit the script (two carriage returns). I'll post a sample of what the recording is telling me.
Code:
' The following string was not unique:
' .WaitForString ESC & "[23;52H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: OK to DELETE the entire Abracadabra Entry?"
.WaitForString "K" & ESC & "[23;52H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "y"
.StatusBar = "Waiting for Prompt: OK to DELETE the entire Abracadabra Entry? y"
.WaitForString "23;53H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press CursorUp (Move the cursor up one line).
.TransmitTerminalKey rcVtUpKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: Default Portal:"
.WaitForString " " & ESC & "[11;19H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press VtSelect (Select key).
.TransmitTerminalKey rcVtSelectKey
.StatusBar = "Waiting for Prompt: Default Portal:"
.WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press VtRemove (Perform the VT terminal's Remove function).
.TransmitTerminalKey rcVtRemoveKey
I tried the code you listed, but it didn't execute...
Here is what I have now.
Code:
Sub SixJune()
' Generated by Reflection for UNIX and OpenVMS 14.1.0.
On Error GoTo ErrorHandler
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[
CR = Chr(Reflection2.ControlCodes.rcCR)
ESC = Chr(Reflection2.ControlCodes.rcESC)
With Session
Do While Not .StatusBar = "Waiting for Prompt: Default Portal:" 'loop until the status bar changes to this text
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
Loop
.Transmit CR
.Transmit CR
End With
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
-
Jun 7th, 2013, 01:02 PM
#6
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
Nevermind... I think I got this to work, but it doesn't stop looping
-
Jun 7th, 2013, 01:13 PM
#7
Re: Help with GoTo statements and looping
So is the line .Transmit "Y" changing the text in the status bar? If not then it would always be blank when it gets to your goto and likely in the do while as well.
Not sure what you meant when you said you tried the code but it did not execute. Did you get a RT error, a compile error or what?
What you show looks like in uses the structure I showed you but I am not sure if that is what you are saying did not execute or something else
Your initial post mentions that it seems to get stuck in the loop
Code:
.StatusBar = ""
.Transmit CR
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
Unless the .Transmit does something that changes the status bar text then it is going to be blank and you are going to be stuck in a loop. Also note that the string must be an exact match when using the = operator,
-
Jun 7th, 2013, 01:30 PM
#8
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
I was mistaken earlier. The script does work, it just never ends the loop.
I believe it does change the status bar text. I posted this previously with everything included, but I'll try and break it down below from the recorder:
Code:
.StatusBar = "Waiting for Prompt: OK to DELETE the entire Abracadabra Entry?"
.StatusBar = ""
.Transmit "y"
.StatusBar = "Waiting for Prompt: OK to DELETE the entire Abracadabra Entry? y"
.StatusBar = ""
.Transmit CR
.TransmitTerminalKey rcVtUpKey
.StatusBar = "Waiting for Prompt: Default Portal:"
.StatusBar = ""
.TransmitTerminalKey rcVtSelectKey
After ".TransmitTerminalKey rcVtUpKey" it displays the status bar on the next line (bolded). Instead of stopping after see'ing it is the target loop end, it just ignores it and starts back from the top.
Last edited by mitch27; Jun 7th, 2013 at 01:33 PM.
-
Jun 8th, 2013, 01:40 AM
#9
Re: Help with GoTo statements and looping
The code you have shown there changes the status bar but there is no loop
the code fromt he other post
Code:
Do While Not .StatusBar = "Waiting for Prompt: Default Portal:" 'loop until the status bar changes to this text
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
Loop
Sets the status bar to "" within the loop The code in the first post also sets the status="" then checks to see if it = something else and if not then uses goto to loop
So like I said unless the .Transmit call actually executes a function that sets the status bar text then the loop would never exit
I am assuming that last code you posted has nothing to do with it as that also calls .transmit and is not in the loop
-
Jun 8th, 2013, 11:26 AM
#10
Re: Help with GoTo statements and looping
BTW:
Can be ugly to read as well as leading to errors. You can easily replace this with no performance penalty using:
-
Jun 9th, 2013, 06:39 PM
#11
PowerPoster
Re: Help with GoTo statements and looping
Add this snippet of source code into the position where you wish to make a multipul of processing jobs, and then being able to do all of them at more or less at the very same time, even...
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 9th, 2013, 10:53 PM
#12
Re: Help with GoTo statements and looping
Not a good idea, doevents will allow events to fire but it does not allow 2 pieces of code to run at the same time, that requires threading. doevents can lead to many different issues and should be avoided when possible there are places to use it but you should make sure you know how it may effect your project before you do. For exampel adding a doevents within an event sub can cause that code to reenter and open up a big can of worms for you.
That of course has nothing to do with the issue at hand.
-
Jun 9th, 2013, 11:32 PM
#13
Lively Member
Re: Help with GoTo statements and looping
Try this :
Code:
Sub SixJune()
' Generated by Reflection for UNIX and OpenVMS 14.1.0.
On Error GoTo ErrorHandler
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[
CR = Chr(Reflection2.ControlCodes.rcCR)
ESC = Chr(Reflection2.ControlCodes.rcESC)
With Session
top:
.TransmitTerminalKey rcVtUpKey
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
IF ( .StatusBar .EQ. "Waiting for Prompt: Default Portal:" ) THEN
.Transmit CR
.Transmit CR
GOTO fin
ELSE
GOTO top
END IF
fin:
End With
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
-
Jun 9th, 2013, 11:34 PM
#14
Re: Help with GoTo statements and looping
Looking at the 'recording' in Post #5 it looks as if the Statusbar text is changed following a rcVtUpKey. That being the case, you need to check the text immediately after that has been transmitted.
Code:
Do
.TransmitTerminalKey rcVtUpKey
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
Exit Do
Else
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
End If
Loop
I'm a bit confused about what Fortran has to do with any of this.
{EDIT}: However, if you wanted to go back to GoTo's
Code:
StartLoop:
.TransmitTerminalKey rcVtUpKey
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
GoTo ExitLoop
Else
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
End If
GoTo StartLoop
ExitLoop:
.Transmit CR
.Transmit CR
{End EDIT}
I also noticed in Post #5 in the code posted
Code:
End With
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
You need an Exit Sub before the error handler otherwise when the loop does exit, you'll display an error message of nothing.
Code:
End With
Exit Sub
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
Last edited by Doogle; Jun 10th, 2013 at 01:10 AM.
-
Jun 10th, 2013, 09:21 AM
#15
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
 Originally Posted by Doogle
Looking at the 'recording' in Post #5 it looks as if the Statusbar text is changed following a rcVtUpKey. That being the case, you need to check the text immediately after that has been transmitted.
Code:
Do
.TransmitTerminalKey rcVtUpKey
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
Exit Do
Else
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
End If
Loop
For some reason it appears to be ignoring If .StatusBar = "Waiting for Prompt: Default Portal:" Then. It goes straight to the next line and repeats itself, as if it doesn't see the statusbar text. But it shows in the recording...
Sorry to be a bother..
-
Jun 10th, 2013, 10:04 AM
#16
Re: Help with GoTo statements and looping
Have you tried setting a break point and stepping through the code?
-
Jun 10th, 2013, 10:16 AM
#17
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
I'm pretty new to scripting. I just read about breakpoint's and noticed that if I leave the fields blank (as if everything is already deleted, and it should go up to "Default Portal:" and stop itself), it still tries to loop. It stops at the breakpoint.
Perhaps "If .StatusBar = "Waiting for Prompt: Default Portal:" Then" is the wrong syntax? I'm not too familiar with .StatusBar
To clarify, the "Default Portal:" field is blank and the field itself is what I would like to use as a stopping point.
-
Jun 10th, 2013, 02:16 PM
#18
PowerPoster
Re: Help with GoTo statements and looping
Well you can use a Timer loop until the Interval has been reached and then execute the lines of source code after that???
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 10th, 2013, 06:23 PM
#19
Lively Member
Re: Help with GoTo statements and looping
 Originally Posted by mitch27
I'm pretty new to scripting. I just read about breakpoint's and noticed that if I leave the fields blank (as if everything is already deleted, and it should go up to "Default Portal:" and stop itself), it still tries to loop. It stops at the breakpoint.
Perhaps "If .StatusBar = "Waiting for Prompt: Default Portal:" Then" is the wrong syntax? I'm not too familiar with .StatusBar
To clarify, the "Default Portal:" field is blank and the field itself is what I would like to use as a stopping point.
have you tried :
Code:
IF ( .StatusBar .EQ. "Waiting for Prompt: Default Portal:" ) THEN
or
Code:
IF ( .StatusBar .EQ. 'Waiting for Prompt: Default Portal:' ) THEN
-
Jun 11th, 2013, 01:27 AM
#20
Re: Help with GoTo statements and looping
The only thing I can suggest (as DataMiser has already suggested) is that you put a breakpoint on the 'Do' statement, check the contents of .StatusBar and then step through the code (using F8), checking the contents of .StatusBar after each step, or modify the code to output the details to the Immediate Window. I appreciate that this duplicates the functionality of the 'recorder' to some extent - but that might be misleading us all !
If, at the point the 'If' statement is executed, .StatusBar is blank, then it's obviously in the wrong place (or for some reason, your code can't 'see it' at all, or by the time control gets back to your Code it's been blanked out by something else)
Code:
Do
.TransmitTerminalKey rcVtUpKey
Debug.Print "After vcVtUpKey: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
If .StatusBar = "Waiting for Prompt: Default Portal:" Then
Debug.Print "Exiting Loop"
Exit Do
Else
.TransmitTerminalKey rcVtSelectKey
Debug.Print "After vcVtSelectKey: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
.TransmitTerminalKey rcVtRemoveKey
Debug.Print "After vcVtRemoveKey: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
.Transmit CR
Debug.Print "After first Transmit CR: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
.StatusBar = ""
.Transmit "Y"
Debug.Print "After Transmit Y: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
.StatusBar = ""
.Transmit CR
Debug.Print "After second Transmit CR: StatusBar is: " & .StatusBar & " Length is: " & Len(.StatusBar)
If InStr(.StatusBar, vbTab) > 0 Then Debug.Print "There's a Tab Character in there!"
End If
Loop
EDIT3: Having Googled around it seems that it's quite common to separate items on the StatusBar using a Tab character. Also there may be an odd space character kicking around at the end of the Text. I've modified the above code to report the actual length of the text in .StatusBar (you're looking for exactly 35 characters) and also to report if there's a Tab character in it. The former situation would cause the 'If' statement to return False, but to the eye, the two values would look identical. I suppose it's within the bounds of possibility that there's some sort of other control character somewhere in the StatusBar text, which can't be seen.
If you run the above or step through line by line you should see when (or if) the StatusBar value changes to what you want (and what it changes to). That should give you an idea where to put the If statement and exit the loop.(You can view the Immediate Window from the View menu on the IDE.)
It'd be interesting to see the results from the Immediate Window if you execute the code above. It should give you some idea of whats going on.
I also note some messages like this:
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
in the 'recorder' output - are they safe to ignore or are they indicitive of a problem ? (e.g. it doesn't wait so you're now out of sync with what's on the screen)
EDIT: I'm wondering if we're all assuming that the StatusBar will change to the required contents at the same point in the code. Is it possible that under one particular circumstance it could change after sending, say 'Transmit Y' and under different circumstances after, say 'Transmit CR'? i.e. It will depend when the 'virtual cursor' for the session is on the screen at the time the code executes.
EDIT2: BTW, please put me out of my misery and expalin what Fortran has to do with all this
Last edited by Doogle; Jun 11th, 2013 at 06:33 AM.
Reason: Removed some extraneous comments
-
Jun 11th, 2013, 06:49 AM
#21
Re: Help with GoTo statements and looping
I'm now beginning to wonder about the processes involved here.
[Taking-a-complete-flyer]
I'm guessing that you're using AttachMate or Reflection or some high level language to determine the logic you wish to follow for some sort of 'screen scraping' application.
That is being converted into an 'intermediate', something that looks like VB (with Fortran overtones, perhaps). It also appears that the 'intermediate' code is also translated / post processed in some way so that the extra statements (e.g. .WaitForString "23;53H", NEVER_TIME_OUT, rcAllowKeystrokes) are inserted in the appropriate places and it's this code that is actually being executed. If that is broadly accurate, perhaps the 'intermediate' code never 'sees' the .StatusBar changes and you should be modifying the code that is actually being executed (i.e. the result of the 'post processing of the 'intermediate' code).
[/Taking-a-complete-flyer]
Last edited by Doogle; Jun 11th, 2013 at 06:53 AM.
-
Jun 11th, 2013, 08:12 AM
#22
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
I think my Fortran comment was mistaken in my first post. Sorry about that, I'm still pretty new to all this.
I tried your script to check for tabs, and it never screen printed anything. I also tried to print a test debug (Debug.Print "Test text") and nothing popped up. Perhaps I'm not see'ing the message?
Update related to your flyer post. It seems to only read the last message (.StatusBar = ""), and exits after see'ing the first entry... I wish it would read the important part which is the field itself, because .Statusbar = "" happens after every key input...
Last edited by mitch27; Jun 11th, 2013 at 08:22 AM.
-
Jun 11th, 2013, 09:52 AM
#23
Re: Help with GoTo statements and looping
The output would have been printed to the Immediate Window - did you look at that ? As I said, you can open the Immediate Window from the View Menu on the main screen of the IDE.
-
Jun 11th, 2013, 11:21 AM
#24
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
I did, this is the output.
After vcVtUpKey: StatusBar is: Length is: 0
All the lines afterwards are the same, Length is 0.
-
Jun 11th, 2013, 04:06 PM
#25
Re: Help with GoTo statements and looping
So, the results imply that the .StatusBar in your VB code is either not the same .StatusBar in the Code being executed or that it's being changed prior to control returning to your VB Code. EDIT: or what you're doing is not changing the StatusBar's state.
Could you possibly describe the overall process, from doing whatever it is you do at the highest level and what happens from there? Is my [Taking-a-complete-flyer] post anything like what's going on ?
i.e. High Level Language -> 'VB' intermediate code -> code that is actually executed. I'm struggling to understand how the whole thing hangs together.
Is there a way you can post the 'actual' code that's being executed? (i.e. the code with all the 'WaitForString' statements). As I mentioned before, perhaps it's that code you should be modifying to incorporate the loop and test.
Last edited by Doogle; Jun 12th, 2013 at 01:42 AM.
-
Jun 11th, 2013, 07:05 PM
#26
PowerPoster
Re: Help with GoTo statements and looping
Can you please post your updated source code project, that would be really good if you could. So that we can see what kind of processes and levels are involved here???
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 12th, 2013, 09:16 AM
#27
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
Here is the recording unedited.
Code:
Sub Source()
' Generated by the Reflection Macro Recorder on 06-12-2013 10:10:57.69.
' Generated by Reflection for UNIX and OpenVMS 14.1.0.
On Error GoTo ErrorHandler
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[
CR = Chr(Reflection2.ControlCodes.rcCR)
ESC = Chr(Reflection2.ControlCodes.rcESC)
With Session
' Press CursorUp (Move the cursor up one line).
.TransmitTerminalKey rcVtUpKey
.WaitForString ESC & "[16;2H", NEVER_TIME_OUT, rcAllowKeystrokes
' Press VtSelect (Select key).
.TransmitTerminalKey rcVtSelectKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[16;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press VtRemove (Perform the VT terminal's Remove function).
.TransmitTerminalKey rcVtRemoveKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[16;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[23;37H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: OK to DELETE the entire TEST Entry?"
.WaitForString "K" & ESC & "[23;37H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "y"
.StatusBar = "Waiting for Prompt: OK to DELETE the entire TEST Entry? y"
.WaitForString "23;38H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[16;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press CursorUp (Move the cursor up one line).
.TransmitTerminalKey rcVtUpKey
.WaitForString ESC & "[15;2H", NEVER_TIME_OUT, rcAllowKeystrokes
' Press VtSelect (Select key).
.TransmitTerminalKey rcVtSelectKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press VtRemove (Perform the VT terminal's Remove function).
.TransmitTerminalKey rcVtRemoveKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[23;36H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: OK to DELETE the entire AGE Entry?"
.WaitForString "K" & ESC & "[23;36H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit "y"
.StatusBar = "Waiting for Prompt: OK to DELETE the entire AGE Entry? y"
.WaitForString "23;37H", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press CursorUp (Move the cursor up one line).
.TransmitTerminalKey rcVtUpKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: Default Portal:"
.WaitForString " " & ESC & "[11;17H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press VtSelect (Select key).
.TransmitTerminalKey rcVtSelectKey
.StatusBar = "Waiting for Prompt: Default Portal:"
.WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
.Transmit CR
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' .WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
End With
Exit Sub
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
' Recording stopped at 10:11:31.47.
End Sub
-
Jun 13th, 2013, 12:09 AM
#28
Re: Help with GoTo statements and looping
I'm having trouble relating the code in the 'recording' to the VB Code. There's no sign of a Loop or an If statement. I'm not sure what has been 'recorded'.
-
Jun 13th, 2013, 12:50 AM
#29
PowerPoster
Re: Help with GoTo statements and looping
He means saved to disk, when he means recorded. But that's from the old C60 and C90 audio tapes that were used as storage on the older versions of PCs that were like the Commodore C64, years ago...
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 13th, 2013, 12:52 AM
#30
PowerPoster
Re: Help with GoTo statements and looping
Everything is Remmed out, so that it is totally ignored can you please post the whole source code??? And also name the Controls that you are using, so that I can code in Notepad and then send you the following source code...
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 13th, 2013, 12:54 AM
#31
PowerPoster
Re: Help with GoTo statements and looping
How can the Recording be stopped at a certain level or positon only that is set as default when the end-user is operating the program??? Because say that the end-user ends the program, immideately when the program is executed into action. Say a second or less after it runs???
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 13th, 2013, 12:56 AM
#32
PowerPoster
Re: Help with GoTo statements and looping
Have the keycodes be called in MouseDown or either KeyPress handlers of the Form or UserControl would be nice and also very fast to work with, so that you don't have any slow downs when working with the program on a very old computer, (Single Core) or even a high processing core(Dual, Triple or even Quad could be counted as being high processing like in Windows 8.00)
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 13th, 2013, 12:59 AM
#33
PowerPoster
Re: Help with GoTo statements and looping
By the way I still cannot be able to find out what this kind of program really still does, right. Because there isn't very much process comments to read, but they are commands rather commented out so that the IDE doesn't execute them. Which is totally wrong, due to the fact that isn't good programming.
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 13th, 2013, 01:03 AM
#34
Re: Help with GoTo statements and looping
@TheiMp: OP is using a Product called 'Reflection' which, amongst other things, allows them to emulate certain types of Terminal Devices and to 'screen scrape' information from other applications running on various operating systems. It uses a High Level Language which at some point is translated into something like VB, that code, in turn is translated into code that actually executes. The problem OP is having is 'bespoking' the code to perform the actions they wish to .
It has absolutely nothing to do with Magnetic Tape Cassettes, Keycodes, MosueDown events, Forms or User Controls.
-
Jun 13th, 2013, 09:45 AM
#35
Thread Starter
Junior Member
Re: Help with GoTo statements and looping
Sorry I thought you wanted a recording of what I wanted it to do. That was me just going through the motions without using the script. Basically we use a command line driven menu system that handles user accounts. It's structured as follows:
*******************
User: Last, First M
Default Portal: Randomportalname (I'd like for the script to stop when it knows it is in this field, but it doesn't stop and performs .Transmit CR, it adds a "y" entry into the Secondary Menus field and loops itself)
Select Secondary Menus:
Needsdeleted1
Needsdeleted2
Needsdeleted3
So on and so forth
(Cursor starts here)
*******************
I'm currently using
Code:
Sub TestGoTo()
On Error GoTo ErrorHandler
Const NEVER_TIME_OUT = 0
Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[
ESC = Chr(Reflection2.ControlCodes.rcESC)
With Session
StartLoop:
.TransmitTerminalKey rcVtUpKey
If .StatusBar = "" Then
GoTo ExitLoop
Else
.TransmitTerminalKey rcVtSelectKey
.TransmitTerminalKey rcVtRemoveKey
.Transmit CR
.StatusBar = ""
.Transmit "Y"
.StatusBar = ""
.Transmit CR
End If
GoTo StartLoop
ExitLoop:
.Transmit CR
.Transmit CR
ErrorHandler:
Session.MsgBox Err.Description, vbExclamation + vbOKOnly
End With
End Sub
This part of the recording seems to be the problem for me, I think:
Code:
.WaitForString " " & ESC & "[15;3H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
' Press CursorUp (Move the cursor up one line).
.TransmitTerminalKey rcVtUpKey
' The following string was not unique:
' .WaitForString ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = "Waiting for Prompt: Default Portal:"
.WaitForString " " & ESC & "[11;17H" & ESC & "[0m" & ESC & "[1m", NEVER_TIME_OUT, rcAllowKeystrokes
.StatusBar = ""
' Press VtSelect (Select key).
.TransmitTerminalKey rcVtSelectKey
I think the underlined portion is preventing the script from noticing the "Default Portal:" menu because it comes immediately afterwards.
I really appreciate your patience with me on this.
-
Jun 14th, 2013, 01:06 AM
#36
PowerPoster
Re: Help with GoTo statements and looping
This type of Source Code that the OP is using looks quite much like the QBAISC source code that I used to write Cash Registers with, back in 2000. That was a very long time ago, in deed it was!!
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 15th, 2013, 12:55 AM
#37
Re: Help with GoTo statements and looping
Have you tried removing the 'StatusBar = ""' statements ?
should
Code:
If .StatusBar = "" Then
be
Code:
If .StatusBar <> "" Then
?
-
Jun 15th, 2013, 01:05 AM
#38
PowerPoster
Re: Help with GoTo statements and looping
What kind of Control is StatusBar really from??? I guess that it's coming from them CommonControl SP6 for Visual Basic, right then???
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Jun 15th, 2013, 01:08 AM
#39
Re: Help with GoTo statements and looping
No, it's not a VB Control, it's a Property of the Session Object which in turn is specific to the Application OP is using.
-
Jun 15th, 2013, 01:40 AM
#40
PowerPoster
Re: Help with GoTo statements and looping
And then the Session Object, which is some sort of ActiveX Control Object, right. I'm just trying to get my feet into this again. But then that was something long ago, that didn't have any kind of Controls, at that...
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|