Jump to content

Need help in getting parameters from command line


Recommended Posts

Hello,

I have referred one of the sample program created by someone to open 5250 session using EHLAPI function. I am able to get into the screen but my requirment is to pass account number from command line and query the screen with account number.

following is my code where am accepting parameteres:

include <Array.au3>

#include <GUIConstantsEx.au3>

Global $dataSrting1 = " "

ReadCmdLineParams(); am calling this function to get the input parameter from command line.

Func ReadCmdLineParams()

$value= 0

for $i = 1 to $cmdLine[0]; $cmdline[0] gives you total no of parameters passed to program

select

case $CmdLine[$i] <> " "

if $i == $CmdLine[0] Then

$dataSrting1 = $cmdLine[1]

EndIf

EndSelect

Next

endfunc

following is the function code which navigates me to the screen

setInputFieldText("Menu","1")

sendCR(); is used to pass Enter button

sendText("2")

sendCR()

sendText("1")

sendCR()

sendText("2")

sendCR()

sendText("1")

sendCR()

sendtext('$dataSrting1'); this code is not working as account number from command line is not getting passed from $datastring1

sendCR()

I am calling my progrm from command prompt as below

C:\Documents and Settings\anantkulkarni\Desktop>test.exe 8029639

C:\Documents and Settings\anantkulkarni\Desktop>test.exe "8029639"

C:\Documents and Settings\anantkulkarni\Desktop>test.exe param1 "8029639"

none of the above three are working, my application is getting started but the place where I am passing this account number is not working properly. I meant I can not search the screen with account number as8029639.

Any help in this is greatly appreciated. I know this is very basic question and I bet have gone through all the help contents and other forum threads to get solution but unfortunately did not get any soution.

Note: I have compiled by application test.exe by pressing (ctrl+F7)

Kindly let me know if you need more details.

Thanking in advance.

Regards,

Anant

Link to comment
Share on other sites

Hi,

Welcome to the AutoIt forum :)

I see a couple of mistakes in your script.

Note that the equal sign is automatically handled in AutoIt, meaning that you need only one to assign or to check equality.

$i == $cmdLine[0] ;makes no sense, == is only valid for strings (case sensitive).
$i = $CmdLine[0] ;better

Fortunately it's not a problem since AutoIt is not a typed variable language.

Where it's critical, it's when you pass a variable as a string in parameter, you need to pass the variable itself.

sendtext($dataSrting1)

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

I would recommend not to use Send but one of the Control* functions. They are much more reliable.

Which program do you try to automate?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...