How do I save a variable assigned to another variable?

393 Views Asked by At

I have this code to execute a command, and after I move to a certain row on the screen in a 3270 PCOM Host emulator with VBScript, I want to get the position of the current row, so I call:

'Save the current Line
LigneEnCours= autECLSession.autECLPS.CursorPosRow

Suppose that the cursor is now at row 7, so LigneEnCours = 7

After that I execute this code:

'Execute a command called 'My Command' that I put in line 24 column 12
autECLSession.autECLPS.SetText <My Command>, 24, 12
autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]"   

When I call autECLSession.autECLPS.SetText 'My Command', 24, 12, the cursor moves to line 24 and column 12. So autECLSession.autECLPS.CursorPosRow returns 24.

After that I call this:

'Puting the cursor in the saved current line
 autECLSession.autECLOIA.WaitForInputReady 60
 autECLSession.autECLPS.SetCursorPos LigneEnCours, 2

At that moment, LigneEnCours contains 24 and not 7 as I expected.

Why, and how to solve that please?

1

There are 1 best solutions below

1
On

Don't know about the rest but if this is regular vbscript and your autECLSession.autECLPS is the equivalent of WScript.CreateObject("WScript.Shell") your sendkeys line has to be

autECLSession.autECLPS.SendKeys "{ENTER}"

EDIT: after your own edit: seems like your LigneEnCours contains an object and not a value, try Regis suggestion or something like LigneEnCours = autECLSession.autECLPS.CursorPosRow * 1 or LigneEnCours = "" & autECLSession.autECLPS.CursorPosRow, whichever doesn't give an error