-1

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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • `Constants` need to be declared before you run a script, you can't change them or set them during the run. `LigneEnCours` should contain the value of your current row at the time you set it, regardless of what the session changes to. Are the `**` supposed to be part of the code or are you trying to go for emphasis? – Dave Apr 25 '17 at 10:30
  • Thanks for your reply, the ** are just for code clarification. – Nouali Yahya Apr 25 '17 at 10:38
  • So, what exactly is the problem with the code (ignoring the `**`s, I suggest you remove those as they're not needed)? – Dave Apr 25 '17 at 10:44
  • The problem is that I want to save the current position of the cursor, but my variable LigneEnCours point ok the new value of the autECLSession.autECLPS.CursorPosRow that is changing dynamically in the code – Nouali Yahya Apr 25 '17 at 10:49
  • 1
    Try LigneEnCours = CInt(autECLSession.autECLPS.CursorPosRow) to make sure that LigneEnCours is really only a value. It should not change by itself if it is a value. – Regis Desrosiers Apr 25 '17 at 10:54
  • 1
    @NoualiYahya What are you using VBScript in?, for example, where does the `autECLSession` object come from? Is it a COM component or a specific hosted environment that gives you access to these objects? A little context would be useful. – user692942 Apr 25 '17 at 13:21
  • Yes it is a specefic hosted environmeng from IBM – Nouali Yahya Apr 25 '17 at 13:41

1 Answers1

-1

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

peter
  • 41,770
  • 5
  • 64
  • 108
  • Thanks for your reply, no the problem is not there, the ENTER does work correctly. Maybe I have not explained my problem correctly. So I will try again. – Nouali Yahya Apr 25 '17 at 11:47