I made a macro to sort a report that i can edited in VB. it works 98% of the time. r8002 is what i want it to find in this part of the macro. the only time this macro does not work is if there is not any r8002 to find and it stops. I want it to skip to the next part. is there any way i can make it say
"if you do not see this"( .WaitForEvent rcEnterPos, "30", "0", 6, 53)
than skip to the line that say (.TransmitANSI "top" )
this is just a chunk of the macro i have noted where it stops and where i would like it to jump to. is there an easy way i can do this?
If anyone can help thanks. - .TransmitANSI "f r8002 prev"
-
.TransmitTerminalkey rcIBMNewLineKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 6, 53 (it stops here)
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 7, 2
-
.TransmitTerminalkey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.waitForDisplayString "===>", "30, 4, 10
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 9
-
.waitForDisplayString "******","30", 5, 2
-
.TransmitTerminalkey rcIBMHomeKey
-
.TransmitANSI "top" (I want it to jump to here)
-
.TransmitTerminalkey rcIBMEnterKey
9 3084 -
If .WaitForEvent rcEnterPos, "30", "0", 6, 53 = SomeReturnValue Then
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 7, 2
-
.TransmitTerminalkey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.waitForDisplayString "===>", "30, 4, 10
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 9
-
.waitForDisplayString "******","30", 5, 2
-
.TransmitTerminalkey rcIBMHomeKey
-
End IF
-
.TransmitANSI "top"
-
.TransmitTerminalkey rcIBMEnterKey[/quote]
-
Does waitforevents return anything?
If it does can you not just use If Then Else...???
"If .WaitForEvent rcEnterPos, "30", "0", 6, 53 = SomeReturnValue Then"
"30", "0", 6, 53 is a cursor position i think that is what it is waiting for so would
If .WaitForEvent rcEnterPos,= "30", "0", 6, 53 then
and if it did not = "30", "0", 6, 53 it would junp to the line after end if?
can i start a line with "if"?
thanks its a little clealer
i thinking about what you said about then else does this look like it would work? does "if" and "else" have to be on there own line? how important is spacing? on some examples i see the lines after "if" and "else" are indented? if this will work i think i am starting to understand if not i am lost :) - .TransmitANSI "f r8002 prev"
-
.TransmitTerminalkey rcIBMNewLineKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
- if
-
.WaitForEvent rcEnterPos,= "30", "0", 6, 53 then
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 7, 2
-
.TransmitTerminalkey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.waitForDisplayString "===>", "30, 4, 10
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitTerminalkey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalkey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 9
-
.waitForDisplayString "******","30", 5, 2
-
.TransmitTerminalkey rcIBMHomeKey
- else
-
.TransmitANSI "top"
-
end if
-
.TransmitTerminalkey rcIBMEnterKey
It is standard practice to indent the lines of code that are dependent on an IF condition. In other words... - If <condition> Then
-
Do something
-
Else
-
Do something different
-
End If
To split the condition from the actual IF though, I believe you would have to use the line continuation character (_), such as... - If _
-
.WaitForEvent rcEnterPos,= "30", "0", 6, 53 Then
However, I fail to see what purpose this serves, apart from the purely cosmetic one of making the lines a bit shorter.
thanks but still having trouble I will start from the beginning to make it easier.
I made a macro to sort a form and it works fine as long as every thing that it searches for is there to find. If not it times out waiting for an event. I do not know VB, The only reason I put the [ ] around [rcEnterPos, "30", "0", 6, 53] was because every time it hit a , or " it gave me an error "expected then or goto".
An if I do get the punctuation so the lines do not turn red it highlights ".WaitForEvent" and says "argument not optional" what I am trying to do is after it searches for "R8002" and does not find it that it continues after the ELSE line without a time out. The argument i was trying to do is If waitforevent is = to the cursor Position Then continue to the next line and if not goto the line after Else. The reason I put the if statment where i did is because this is where it turns yellow in debug mode after the time out.
IF statement starts on line 107
ELSE on line 144
if it helps
waitForEvent = (event as long,TimeOut as String, Duration As Long Col As Long)
rcEnterPos = cursor enters Position - Sub FidSort124()
-
'
-
' Generated by the Reflection Macro Recorder on 08-04-2007 23:02:52.74
-
' Generated by Reflection for IBM for Windows 10.0.244
-
'
-
With Session
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMTabKey
-
.TransmitANSI "csr "
-
.TransmitTerminalKey rcIBMHomeKey
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "f ""end of order filling"""
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 6, 16
-
.WaitForDisplayString "-", "30", 6, 9
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 8, 2
-
.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 9
-
.WaitForDisplayString "******", "30", 5, 2
-
.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "top"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "sort 45"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 16, 2
-
.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "f r8000"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 6, 53
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMUpKey
-
.TransmitTerminalKey rcIBMUpKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 11
-
.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMPf8Key
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "f r8002 prev"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
If _
-
.WaitForEvent = [rcEnterPos, "30", "0", 6, 53] Then
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 7, 2
-
.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "bottom"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitANSI "dd"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 5, 9
-
.WaitForDisplayString "******", "30", 5, 2
-
Else _
-
:.TransmitTerminalKey rcIBMHomeKey
-
.TransmitANSI "top"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "sort 124"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMNewLineKey
-
.TransmitTerminalKey rcIBMTabKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitTerminalKey rcIBMRightKey
-
.TransmitANSI "FidSort "
-
.TransmitANSI (Now)
-
.TransmitTerminalKey rcIBMHomeKey
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "save"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "prn 1 s8"
-
.TransmitTerminalKey rcIBMEnterKey
-
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
-
.WaitForEvent rcEnterPos, "30", "0", 4, 15
-
.WaitForDisplayString "===>", "30", 4, 10
-
.TransmitANSI "=9.onfbrat"
-
.TransmitTerminalKey rcIBMEnterKey
-
End If
-
End With
-
End Sub
do i have to put something after the then to make it goto the next line? or does it just know to do that?
the only other way i can think of is to try is GOTO statement but from what a read it is not good to use them?
is there any other simple ways to make jumps in lines other than if, then. else?
what about if waitForEvent = true then. do i have to put a goto after then or will it just go to the next line?
Sorry, I haven't really been following this thread, largely because so much of the syntax looks unfamiliar. I'm not familiar with WaitForEvent and so on. What version of VB are you using, and what does all this relate to? In other words, what is a "Session" object?
Um... actually, you said that it was a macro. In what product?
As for the If/Then business, VB (or any language which includes this structure) will automatically follow the appropriate path through an IF...ELSE...END IF block. If the IF condition is True, it will execute the code following THEN. Otherwise, it will execute the code (if any) following ELSE. It will always either the True block or, if present, the False block. There is no need to "tell it" to go on to the next statement.
I suspect any confusion may arise from the nature of the WaitForEvent function (or method, or whatever it is). To judge from it's name, it will stop and wait for an event to occur. If that event never occurs, then maybe it will continue to wait forever. However, with parameters called "Timeout" and "Duration", it seems as though you should be able to control that. Most likely, if it times out, that is when you would hit the False condition and thus execute the Else block.
Most languages support a number of statements which control the flow of execution (or "make jumps in lines").
The main ones which come to mind, with some examples, would be... - Branching
- Looping
- For...Next
- For Each...Next (not the same thing, at all)
- Do While...Loop
- Do Until...Loop
- While...Wend
The GOTO statement should rarely be required, and is widely seen as a sign of poor, or at least lazy, programming.
"The Reflection object name (Application vs session)
In versions of Reflection prior to 7.0, all methods and properties acted on the
Application object. The newer Session object is now used in all help programming examples. However, if you are creating and/or maintaining Reflection Basic scripts,
you should continue to use Application for the Reflection object name."
not sure what that means but it came out of the manual.
I'm using VB6.
The product is Reflection for IBM.
It says in the manual
Programming language elements that are common to all implementations of BASIC include:
•Data types, variable and constants, and arrays (declared with Dim and Const)
•Operators and expressions (such as +, -, *, /, Not, Like, and Or)
•User-defined functions and procedures (Sub and Function)
•Control structures and loops (such as For ... Next, Do ... Loop, and If ... Then ... Else)
Additional concepts in VBA and stand-alone Visual Basic include:
•Objects
•Forms
•Events
So i think it would work if i knew how to "declare" it with a Dim or Const.
if you could give me an example using my code that would be great.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Matthew Sims |
last post by:
Python Newbie here. This is my first time learning object-oriented
programming and trying to break out of the usual Korn/Perl/PHP style
of programming. Having some difficulty understand some items....
|
by: Jim Bunton |
last post by:
New to MySql:
I can't seem to get a grab on what is a schema and what is a database
So I have seen! the 'Mysql' Database and the Test Database
I'm runninng the database Administrator and thinking...
|
by: jalkadir |
last post by:
By jump I mean ending unexpectedly.
The program below, like the jumping beens, has an unusual behaviour.
When the noted lines are not present the program terminates
disregarding the rest of the...
|
by: Pupeno |
last post by:
Hello,
I want to jump over a method in the class hierarchy, that is: If I have
class A(object), clas B(A), class C(B) and in C, I want a method to do
exactly what A does but not what B does in...
|
by: spamtrap |
last post by:
Mostly for testing reasons I'd like to see if it makes sense to chose
the following approach for just-in-time compilation of shaders for a
renderer:
Seeing as the shaders themsefs consist mostly...
|
by: Chris Lasher |
last post by:
Hi all,
I have a simple script:
---
#!/usr/bin/env python
a = 1
b = 2
|
by: Steve |
last post by:
Hi there,
I'm having a problem with a webpage where hoving over the top navigation
links causes my footer to jump up to the centre of the page! It only
happens with IE7, and works fine with the...
|
by: Prisoner at War |
last post by:
Hi, People,
Is it possible to have an "empty" or "dummy" <a href***without***
the browser jumping back up the page??
I have a hyperlink that doesn't point to another document, but is used
to...
|
by: prathna |
last post by:
Hi I have this following code
<script> function displayFields() { document.getElementById('Label12').style.display = 'none'; document.getElementById('Label13').style.display =...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |