FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Running a program with mixed parameters
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Running a program with mixed parameters
Posted: Thu Jul 03, 2014 04:44 PM
I need to execute a program from within my program. Normally this is not a problem, but for some reason the parameters issue is giving me some problems.

The normal command line call would be in this format:

The usage syntax for executing ABCUpload.exe is:
ABCUpload.exe <user_name> <password> <license_key> <xml_file> [-DELZIP]

Example:
ABCUpload.exe ABCLoginAccount@abc.com secretp@ssw0rd ABCDEF90-1234-5678-90AB-CDEF12345678 "C:\ABCFolder\MyDatas.xml

The user name, password, and license key are all drawn from data files, so I need to substituted variables. I have tried to implement the code as follows:

Code (fw): Select all Collapse
FUNCTION ABCupload

  LOCAL dfcall := cPath + "ABCUpload.exe "
  LOCAL dfuser, dfpass, dflicn, dffull
  LOCAL dffile :=  cpath + "MyData.xml "
  LOCAL dfxtnd := '-DELZIP >> logfile.txt'
  
  // Get the stored values
    oDcf := tdata():new(, cPath + "dForce\dfsetu" )
    oDcf:use()
    oDcf:goto( 1 )

  // Set the values and create the execute string
    dfuser := TRIM(oDcf:dfssid) + SPACE(1)
    dflicn := TRIM(oDcf:dfskey) + SPACE(1)
    dfpass := TRIM(oDcf:dfpass) + SPACE(1)
  dffull := dfcall + dfuser + dfpass + dflicn + '"' + dffile + '"' + dfxtnd
  
  oDcf:close( ) 

  // Now execute the transmission
  MsgInfo( dffull )
  nResult := WaitRun( dffull )  
  MsgInfo( nResult )

RETURN NIL


dffull displays what appears to be a proper formatted string. However, nResult returns -1 and the logfile is not created.

Am I handling the formatting of this string correctly ?

Thanks.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Running a program with mixed parameters
Posted: Thu Jul 03, 2014 10:13 PM
There is no way the example could match the string you are making. There is only 1 " in your example and you are inserting 2 " into the formatted string you are making.

I would also check the spaces after the filename.
Try this

Code (fw): Select all Collapse
FUNCTION ABCupload

  LOCAL dfcall := cPath + "ABCUpload.exe"
  LOCAL dfuser, dfpass, dflicn, dffull
  LOCAL dffile :=  cpath + "MyData.xml"
  LOCAL dfxtnd := '-DELZIP >> logfile.txt'
 
  // Get the stored values
    oDcf := tdata():new(, cPath + "dForce\dfsetu" )
    oDcf:use()
    oDcf:goto( 1 )

  // Set the values and create the execute string
    dfuser := TRIM(oDcf:dfssid)
    dflicn := TRIM(oDcf:dfskey)
    dfpass := TRIM(oDcf:dfpass)
  dffull := dfcall +' '+ dfuser +' '+ dfpass +' '+ dflicn +' '+ '"' + dffile + '"' +' '+ dfxtnd
 
  oDcf:close( )

  // Now execute the transmission
  MsgInfo( dffull )
  nResult := WaitRun( dffull ) 
  MsgInfo( nResult )

RETURN NIL
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Running a program with mixed parameters
Posted: Thu Jul 03, 2014 10:51 PM

Thanks Gale,

Actually the Example was wrong. I've now got everything working correctly.

Tim

Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Running a program with mixed parameters
Posted: Fri Jul 04, 2014 06:01 PM

Cool, I knew you would do it.

Continue the discussion