0

I am trying to call an Array in Personal Communication (iSeries etc) I have a script that should

Open the query screen
Run query 1
Wait for query 1 to finish
Run query 2

etc

In any other VB situation, I would use

Dim qryArray() as string = {“salesrep1”, “salerep28”, “salepay34”, “prod_inv_1”}

But here it keeps telling me Expected end of statement

Is there something obvious I'm doing wrong here?

Secondly I need to know how to call an Array as a SendKeys

'Open Query
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "2" 'Run
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys 'Query Name Goes Here
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[field+]" 'Next
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "techops" 'Library
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[field+]" 'To top
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[enter]" 'Go to query
    autECLSession.autECLOIA.WaitForInputReady
autECLSession.autECLPS.SendKeys "[pf3]" 'Exit to run query
Badja
  • 840
  • 1
  • 6
  • 29
  • is this .net or vba? `qryArray=array("one","two","three")` is the vba way – Nathan_Sav Feb 21 '19 at 15:19
  • vba I believe. If I try this, it says `qryArray` is undefined – Badja Feb 21 '19 at 15:26
  • you still need to dimension the array, so `Dim a() As Variant : a = Array("a", "b", "c")` for example. – Nathan_Sav Feb 21 '19 at 15:31
  • Thanks. I worked it out. Do you know how to use SendKeys to send an Array Value within a Do:Loop? – Badja Feb 21 '19 at 15:32
  • `for each v in myarray:application.sendkeys(cstr(v)):next v` – Nathan_Sav Feb 21 '19 at 15:43
  • It looks like I can't dimension the array as it will always say `Expected End of Statement`. So when I try and `SendKeys` it will tell me there is a `type mismatch` – Badja Feb 21 '19 at 15:44
  • The previous way will say expected end of statement?? – Nathan_Sav Feb 21 '19 at 15:58
  • I haven't tried your `for each` yet as I'm not sure how they operate. Can this be used inside a Do:Loop, until the Array has been completed? If so, what does `cstr` do? And instead of application: I would be using `autECLSession.autECLPS.` Is that right? – Badja Feb 21 '19 at 16:01
  • Okay. I have that working by just removing the last `v` from `next`. But now it just prints out all my query names at once, rather than printing it out, running, waiting, going to the next one and printing out the second name – Badja Feb 21 '19 at 16:21
  • 1
    You need to pause between sending, paced by the terminal. https://stackoverflow.com/a/33310031/3175562 – Mike Feb 22 '19 at 01:09

1 Answers1

0

So with help from Natha_Sav, here is the working answer:

For each v in qryArray
'Then we are opening the query, running it, closing it and waiting for the message to confirm
'snippet:
autECLSession.autECLPS.SendKeys "2" 'Run
   autECLSession.autECLPS.SetCursorPos 8, 26
autECLSession.autECLPS.SendKeys(cstr(v)) 'send query name
   autECLSession.autECLPS.SetCursorPos 9, 28
'autECLSession.autECLPS.SendKeys "salesrep1" 'This would be the equivalent
'then close the library etc 
'run the query
next
Badja
  • 840
  • 1
  • 6
  • 29