Reflections WRQ VBA

Robertson1995

Board Regular
Joined
Apr 1, 2009
Messages
117
I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
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$(rcCR)
ESC = Chr$(rcESC)
With Session
.Transmit "bts_status mc800bts877" & CR
' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
Exit Sub
ErrorHandler:
.MsgBox Err.Description, vbExclamation + vbOKOnly
End With
' Recording stopped at 09:04:44.83.
End Sub
 
Well first of, after we have created the class, we will be using that for sending text and terminalkeys.

So after we have instantiated the object, we can use it to send the text.

Code:
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect

myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
myReflection.TransmitText "Test2", 22, 16 'This sends the text to loc 22,16


set myReflection = Nothing 
End Sub

Actually The function is coded so that you do not have to issue the row x column where you want to send the text, if you omit this information, it will just send it to the current cursor location. But if you do give this data, the function TransmitText will move the cursor for you. My idea is to move alle the nitty-gritty code away into the class, making it easier to code up to the class, and more readable as well. You could also easily expand the class with a new function to move the cursor, and I indeed have such a function in my own "parser"-class (well in algoritm terms, it is more like a broker-pattern class, but thats not important). But I thought it would be much better to write the class you need as my class is part of a 60.000 line project, so theres loads of functions which you will probably not have any use for.

So I guess my concepts are reuseability and abstraction. You still following?
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The hard Disk got Busted ! :(... well have to start all over again due to which i was not able to come online and was getting backup systems ...so Now finially i got a Dedicated System...
well what i have did till now is ...
Created Class Modules
Name changed from Class1 to ReflectionClass
Changed instancing to Private
Copied Code and inserted in ReflectionClass
&
copied the below given code and added in module 1
Code:
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
Set myReflection = Nothing
End Sub
The ThisWorkBook Code Sheet is empty...

When i Execute TestOwnClass it Open Reflection and connects it automatically but is not Transmitting f9 key

So what should i do about it!..
and sorry for a delay bro...
 
Upvote 0
in start when the Reflection Opens via excel and gets connected the cursor moves to the given location as in coding it gives error! cause the 1st Main Screen executes via f9 key & cursor move hangs the Screen gives this error X <- X ->
1st step after reflection is connected f9 key should execute so that it the next screen should appear...
 
Upvote 0
Allright, lets see if I can direct you through your snapshots

First of to send a PF9, as discussed earlier you just need to use the SendTerminalKey function. so Lets say we got our class instantiated with

Code:
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect 'Connect to the mainframe

'THIS IS WHERE OUR BATCH CODE IS GOING TO BE

Set myReflection = Nothing
End Sub

So at the line in all caps you issue a

Code:
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key

Afterwards it seems you are submitting the command "50.7.13" at location 23,16 (After MENU OPTION: ). The code we made earlier can du this by first submitting the text to location 23,16 and then sending Enter. So if I am getting the flow correctly you need to run this after the PF9

Code:
    myReflection.TransmitText "50.7.13", 23, 16
    myReflection.SendTerminalKey rcIBMEnterKey

Then looking at your next snapshot I can see that the CTR number is entered at location 3,11 (see the lower right corner). If we say that you keep your CTR number in column A and row 1 you can find the value of this in the Cells function, ie Cells (RowIndex, ColumnIndex). So Cells(1,1) is equivalent to A1. If you then need to send another Enter the following should be sufficient

Code:
    myReflection.TransmitText Cells(1, 1), 3, 11
    myReflection.SendTerminalKey rcIBMEnterKey

So then we get to the SEAL panel (and I'm allready lost :) ) but I think you want to copy a value from column B to position 4,11, so lets try with

Code:
    myReflection.TransmitText Cells(1, 2), 4, 11
    myReflection.SendTerminalKey rcIBMEnterKey

Thereby we copy in the text from B1 to 4,11.

So in short this is the whole code for login to one container inserted

Code:
    myReflection.SendTerminalKey rcIBMPf9Key 'The first F9 panel
    
    
    myReflection.TransmitText "50.7.13", 23, 16 
    myReflection.SendTerminalKey rcIBMEnterKey 'Then put in 50.7.13 and send an enter key
    
    myReflection.TransmitText Cells(1, 1), 3, 11
    myReflection.SendTerminalKey rcIBMEnterKey ' Insert value of A1 and send enter
    
    myReflection.TransmitText Cells(1, 2), 4, 11
    myReflection.SendTerminalKey rcIBMEnterKey ' Insert value of B1 and send enter

I'm guessing you need to loop this for a list of containers, but I don't know which steps to loop, but I hope this can get you started?
 
Upvote 0
1st of all thanks for your reply bro and secondly you must be getting confused cause the file that i managed to upload has 3 screen shots missing so if you can provide me with your email address so that i can upload....or for that i has to go to my cousins place so that i can upload the excel file again

yes i need a loop for a list of containers...and the range is dynamic....its not fixed!!
 
Upvote 0
3 screen shots details after pressing f9 the next screen asks for a numeric key 1 and enter then the login password screen appears after entering the login and password the cursor moves to Menu Option: we can directly place 50.7.13 to move to the seal screen or press enter to go to menu screen and then place 50.7.13....
i can email you the excel file bro
 
Upvote 0
well we need to Loop the container and seal phase !!..till the last seal number found in the excel sheet...as the list is dynamic
 
Upvote 0
Disclaimer: I'm not actually near an editor, so I cannot proof-read my code, I'm going a bit by memory :)

Well the first 4 screenshots are kinda trivial by now, I'll just include them for ease of reading as they are actually quite straight forward with the functions we have allready made...

The function SendTerminalKey is what sends F9 keys and enter, etc.
The function TransmitText sends normal text to the screen.


So To send the F9 (Screenshot 1):
Code:
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key

To send the 1 and press enter (Screenshot 2):
Code:
myReflection.TransmitText "1", 5, 13 'Insert 1 at location 5,13
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue

Inserting User and ID (Screenshot 3):
Code:
myReflection.TransmitText "USER", 18, 33 'Change the USER to your USER-ID
myReflection.TransmitText "PASSWORD", 18, 33 'Change the PASSWORD to your PASSWORD and also change to the correct location
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue

Calling the right screen/panel (Screenshot 4):
Code:
myReflection.TransmitText "50.7.13", 23, 16 'Put the text 50.7.13 at the command line
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue

This is where the actual fun begins... This is some pseudo-code for how I see your process:


For Each ContainerLine
Insert ContainerNum at Location 3,11
Send EnterKey
Insert SealNum at Location 4,11
Send EnterKey
Next ContainerLine

So Lets get this into some real Code, I've put the comments in after the '

Code:
Dim lng_ContainerIterator as long 'This is to keep track of which line in the Sheet we are processing
Dim lng_LastContainerRow as long 'This var will hold the last container row


lng_LastContainerRow = ActiveSheet.Cells(ActiveSheet.Rows.count, "A").End(xlUp).Row 'This finds the first cell with content starting from the buttom and up, should also be the last cell in a range without empty rows.




'I assume your data start at row 2 and theres columng headers in row 1
For lng_ContainerIterator = 2 to lng_LastContainerRow
	myReflection.TransmitText Cells(lng_ContainerIterator,"A"), 3, 11 'Send the content of column A in the current row to 3,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
	myReflection.TransmitText Cells(lng_ContainerIterator,"B"), 4, 11 'Send the content of column B in the current row to 4,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
next lng_ContainerIterator 'Do it again with the next row

This should loop the Container actions untill we get to the last line.

If this was my project though here's some thoughts I would prob. take into consideration


  1. I would start the batch-program at the Insertion of the Container Num, this is so that I do not have to be at the login screen to start the program, to me this gives it a bit more flexibility, plus another co-worker could also run it, as he just need to log in and go to the right panel/screen to start it.
  2. I would also code in some protection to ensure that I only insert text into the right panels/screens. I would use the text allready on the screen to make sure I am on the panel I expect to be on before doing anything.

Hope this can help you further along
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,830
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top