Home > Archive > dBASE Questions and Answers > July 2005 > Passing Command Line Parameters into App









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Passing Command Line Parameters into App
john marshall

2005-07-15, 9:23 am


Can someone give me a start on passing parameters from the commandline through to the running app?

I want to be able to run reports from the command line, and set different startup options. For example, to run a unattended nighttime report ....

Appexe /D 20050713 /R 2

This might pass the date to report on and which report number. Any suggestions?

Thanks,

JM
Simone Bartoccioni

2005-07-15, 9:23 am

Use PARAMETES in the startup program of your app

For example:

parameters myAppParam
.....
.....
.....



Ciao

Simone



"john marshall" <john. marshall@mainstreetp
rinceton.com> ha scritto nel
messaggio news:RaWjTPUiFHA.2024@news-server...
>
> Can someone give me a start on passing parameters from the commandline
> through to the running app?
>
> I want to be able to run reports from the command line, and set different
> startup options. For example, to run a unattended nighttime report ....
>
> Appexe /D 20050713 /R 2
>
> This might pass the date to report on and which report number. Any
> suggestions?
>
> Thanks,
>
> JM



john marshall

2005-07-15, 11:23 am

I think you misunderstood the question, I want to pass the parameters from the operating system when running the .exe

PrintReport.exe admin

(like the old %1, %2 parameters in batch files)

Such an example would direct a change in the operations once the program opens, in this case to launch the admin setup screen on open.

JM





Simone Bartoccioni <mediabyte DOT tiscali DOT it> Wrote:

> Use PARAMETES in the startup program of your app
>
> For example:
>
> parameters myAppParam
> ....
> ....
> ....
>
>
>
> Ciao
>
> Simone
>
>
>
> "john marshall" <john. marshall@mainstreetp
rinceton.com> ha scritto nel
> messaggio news:RaWjTPUiFHA.2024@news-server...
>
>


David Kerber

2005-07-15, 11:23 am

In article <EvOsTHViFHA.1768@news-server>,
john. marshall@mainstreetp
rinceton.com says...
> I think you misunderstood the question, I want to pass the parameters from the operating system when running the .exe
>
> PrintReport.exe admin
>
> (like the old %1, %2 parameters in batch files)


That still works (better, in fact, because there are more scripting
commands available in the later versions of Windows than we ever had in
DOS), if you want to start your program from a batch file. Or you can
put the command-line parameters in the shortcut properties and plot the
shortcut on your desktop or wherever.


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
john marshall

2005-07-15, 11:23 am


But how do you then grab them inside dBase?

JM


David Kerber Wrote:

> In article <EvOsTHViFHA.1768@news-server>,
> john. marshall@mainstreetp
rinceton.com says...
>
> That still works (better, in fact, because there are more scripting
> commands available in the later versions of Windows than we ever had in
> DOS), if you want to start your program from a batch file. Or you can
> put the command-line parameters in the shortcut properties and plot the
> shortcut on your desktop or wherever.
>
>
> --
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).


Ken Mayer [dBVIPS]

2005-07-15, 1:23 pm

john marshall wrote:
> Can someone give me a start on passing parameters from the commandline through to the running app?
>
> I want to be able to run reports from the command line, and set different startup options. For example, to run a unattended nighttime report ....
>
> Appexe /D 20050713 /R 2
>
> This might pass the date to report on and which report number. Any suggestions?


This topic is discussed in the online help for dBASE ...

Ken

--
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase
David Kerber

2005-07-15, 1:23 pm

In article <mvIqZVViFHA.444@news-server>,
john. marshall@mainstreetp
rinceton.com says...
>
> But how do you then grab them inside dBase?


Like Simone said, use the "Parameters" statement.

.....

--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
john marshall

2005-07-16, 3:23 am


I cannot get it to work. I have a test file called controltest.exe.

I have a parameter following it 12345. I also tried '12345'.

In the form On Open I have 'Paramerters temp1'

I tried to assign the passed number into an entryfield:

form.entryfield1.value := temp1

The error says: Expecting logical.


Any thoughts?

JM





David Kerber Wrote:

> In article <mvIqZVViFHA.444@news-server>,
> john. marshall@mainstreetp
rinceton.com says...
>
> Like Simone said, use the "Parameters" statement.
>
> ....
>
> --
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).


Rick Miller

2005-07-16, 3:23 am


Hello John,

john marshall <john. marshall@mainstreetp
rinceton.com> wrote in
news:J0KObXXiFHA.2024@news-server:

>
> I cannot get it to work. I have a test file called

controltest.exe.
----

If the form is the 1st file of controltest.exe,
You could try using code in the top of the form
file similar to an example below.

Hope it helps,
Rick Miller

-----------------------------------------------
// example 1.
// header code.
parameters p1, p2, p3, p4
local f
f = new myForm()
f.entryfield1.value := p1
f.open()
return
// end of example 1.

-----------------------------------------------

// example 2.
// header code.
parameters p1, p2, p3, p4
local f
f = new myForm()
f.temp1 = p1
f.open()
return
// end of header code.

function form_onOpen
form.entryfield1.value := form.temp1
return

// end of example 2.
-----------------------------------------------

John Marshall

2005-07-16, 7:23 am

I looked at that, but there is a line reading 'PARAMETER bModal'. Is this a different parameter (reserved word) or can I just add additional parameters to it?


JM

Rick Miller Wrote:

>
> Hello John,
>
> john marshall <john. marshall@mainstreetp
rinceton.com> wrote in
> news:J0KObXXiFHA.2024@news-server:
>
> controltest.exe.
> ----
>
> If the form is the 1st file of controltest.exe,
> You could try using code in the top of the form
> file similar to an example below.
>
> Hope it helps,
> Rick Miller
>
> -----------------------------------------------
> // example 1.
> // header code.
> parameters p1, p2, p3, p4
> local f
> f = new myForm()
> f.entryfield1.value := p1
> f.open()
> return
> // end of example 1.
>
> -----------------------------------------------
>
> // example 2.
> // header code.
> parameters p1, p2, p3, p4
> local f
> f = new myForm()
> f.temp1 = p1
> f.open()
> return
> // end of header code.
>
> function form_onOpen
> form.entryfield1.value := form.temp1
> return
>
> // end of example 2.
> -----------------------------------------------
>


Rick Miller

2005-07-16, 11:23 am


"John Marshall" <john. marshall@mainstreetp
rinceton.com> wrote in message
news:7j6SanfiFHA.1796@news-server...
> I looked at that, but there is a line reading 'PARAMETER bModal'. Is this

a different parameter (reserved word) or can I just add additional
parameters to it?
----

bModal is not a reserved word.
bModal would come into play if You were
starting the form with:
do myform with true
which would open the form with the readModal() method.
If You want the form to open readModal,
replace the f.open() in the examples with f.readModal().

The area of code that contains bModal
(also known as the boot strap code)
is re-written whenever the form designer
is used to make a change to the form.
In other words, putting Your parameters on the
same line as parameter bModal would cause
Your parameters to be deleted whenever the
form is changed with the form designer.

That is the reason for placing code to handle Your
parameters above the:
** END HEADER -- do not remove this line

Hope it helps,
Rick Miller


Bowen Moursund [DataTech]

2005-07-19, 11:24 am

> Can someone give me a start on passing parameters from the
> commandline through to the running app?


The classic example from Steve Koterski:

Pass character values from the command line surrounded by single quotes.
Numeric values will have no delimiters, date values in French brackets, and
logical values with the dots but no delimiters. Each parameter would be
separated by a space. For example, using the code below...

* PARMS.PRG
PARAMETERS cText1, cText2, nNum, dDate, bLogical
? cText1
? cText2
? nNum
? dDate
? IIF(bLogical, 'Yes', 'No')
WAIT
RETURN

...you would invoke this program with a command such as:

PARMS.EXE 'text1' 'text2' 334 {03/20/94} .T.

--
Bowen Moursund
DataTech
Consulting & Development
http://www.bmmnet.us




Carlos A. Pereira [APKomp]

2005-07-19, 8:24 pm

Dear John Marshall

You will have problems if you pass more than one parameter
Pass only one parameter and then,
decompose that parameter in several parameters.
See example.

Carlos Pereira
APKomp, LDA.
Charter Member: 100 0259
(of the no more available dBASE Gold Subscription)

--------------------------------------------------
****** mailing * mailing.prg
********************
********************
***********
* programa inicial (configura directorias, impressao,...)
* Este programa tem um parametro de entrada.
* O seu conteudo é passado para 4 variaveis:
* /1 a da directoria partilhada
* /2 a da não partilhada/temporária
* /3 a do path
* /4 a do .mem com todas as var. de memoria
* Sample:
* MAILING.EXE "/1 s:\apkomp\mainFolder
/2 c:\apkomp\tempFolder
/3
c:\apkomp\auxFolderA
,c:\apkomp\auxFolder
b,c:\apkomp\auxFolde
rC /4
c:\apkomp\tempFolder
\mailing.mem"
*...
********************
********************
********************
****************
****
PARAMETERS wparametro
***
IF TYPE("wparametro")<>"C"
wparametro=SPACE(0)
ENDIF
wconfdire=SPACE(0)
wparametr1=SPACE(0) && drive e directoria partilhada (subparametro entre
/1 e /2 ou /1 e /3 ou /1 e /4 ou /1 e fim)
IF AT("/1",wparametro)>0
wparametr1=SUBSTR(wp
arametro,AT("/1",wparametro)+2)
IF AT("/2",wparametr1)>0
wparametr1=LEFT(wpar
ametr1,AT("/2",wparametr1)-1)
ENDIF
IF AT("/3",wparametr1)>0
wparametr1=LEFT(wpar
ametr1,AT("/3",wparametr1)-1)
ENDIF
IF AT("/4",wparametr1)>0
wparametr1=LEFT(wpar
ametr1,AT("/4",wparametr1)-1)
ENDIF
wparametr1=LTRIM(RTR
IM(wparametr1))
ENDIF
wparametr2=SPACE(0) && drive e directoria não partilhada (subparametro
entre /2 e /3 ou /2 e /4 ou/2 e /1 ou /2 e fim)
IF AT("/2",wparametro)>0
wparametr2=SUBSTR(wp
arametro,AT("/2",wparametro)+2)
IF AT("/3",wparametr2)>0
wparametr2=LEFT(wpar
ametr2,AT("/3",wparametr2)-1)
ENDIF
IF AT("/4",wparametr2)>0
wparametr2=LEFT(wpar
ametr2,AT("/4",wparametr2)-1)
ENDIF
IF AT("/1",wparametr2)>0
wparametr2=LEFT(wpar
ametr2,AT("/1",wparametr2)-1)
ENDIF
wparametr2=LTRIM(RTR
IM(wparametr2))
ENDIF
wparametr3=SPACE(0) && path/rota (subparametro entre /3 e /1 ou /3 e /2
ou /3 e /4 ou /3 e fim)
IF AT("/3",wparametro)>0
wparametr3=SUBSTR(wp
arametro,AT("/3",wparametro)+2)
IF AT("/1",wparametr3)>0
wparametr3=LEFT(wpar
ametr3,AT("/1",wparametr3)-1)
ENDIF
IF AT("/2",wparametr3)>0
wparametr3=LEFT(wpar
ametr3,AT("/2",wparametr3)-1)
ENDIF
IF AT("/4",wparametr3)>0
wparametr3=LEFT(wpar
ametr3,AT("/4",wparametr3)-1)
ENDIF
wparametr3=LTRIM(RTR
IM(wparametr3))
ENDIF
wparametr4=SPACE(0) && qual é o fich mem (subparametro entre /4 e /1 ou
/4 e /2 ou /4 e /3 ou /4 e fim)
IF AT("/4",wparametro)>0
wparametr4=SUBSTR(wp
arametro,AT("/4",wparametro)+2)
IF AT("/1",wparametr4)>0
wparametr4=LEFT(wpar
ametr4,AT("/1",wparametr4)-1)
ENDIF
IF AT("/2",wparametr4)>0
wparametr4=LEFT(wpar
ametr4,AT("/2",wparametr4)-1)
ENDIF
IF AT("/3",wparametr4)>0
wparametr4=LEFT(wpar
ametr4,AT("/3",wparametr4)-1)
ENDIF
wparametr4=LTRIM(RTR
IM(wparametr4))
ENDIF
*
IF EMPTY(wparametr1)=0
wparametr1=SET("DIRECTORY")
ENDIF
IF EMPTY(wparametr2)=0
wparametr2=SET("DIRECTORY")
ENDIF
IF EMPTY(wparametr3)=0
wparametr3=SET("PATH")
ENDIF
IF EMPTY(wparametr4)=0
wparametr4=""
ENDIF
********************
********************
********************
****************
****
_app. allowDEOExeOverride=
.F.
********************
********************
********************
****************
****
* definicao de procedimentos gerais
SET PROCEDURE TO apkudf.prg ADDITIVE
....
....
....
--------------------------------------------------

"john marshall" <john. marshall@mainstreetp
rinceton.com> escreveu na mensagem
news:RaWjTPUiFHA.2024@news-server...
>
> Can someone give me a start on passing parameters from the commandline

through to the running app?
>
> I want to be able to run reports from the command line, and set different

startup options. For example, to run a unattended nighttime report ....
>
> Appexe /D 20050713 /R 2
>
> This might pass the date to report on and which report number. Any

suggestions?
>
> Thanks,
>
> JM



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com