Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Parameters from external applications 3

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
MU
hi guys,

i have a .lbx (a ticket layout) and a .prg file with just 3 lines to print that ticket . I'v made a .exe file (including the .prg and .lbx files). My vfp .exe is run by an external .net application. It is all working fine but ,,,,, now i want my .exe to be able to read parameters passed from that .net application. How is that done .. can anyone help.

thankx
Vijay
 
Put PARAMETERS clause in your main PRG.
Keep in mind that ALL parameters will be STRING.
Other way is to create COM server and the use its properties to have what you want.

Borislav Borissov
VFP9 SP2, SQL Server
 
Just to add word to Borislav's answer ....

The PARAMETERS statement needs to be the very first line of your main program (apart from comments). It should include a list of variable names. These variables will then receive the values passed by the calling program.

For example, if the caller is passing a customer name and a customer ID, your statement might look like this:

[tt]PARAMETERS lcName, lcID[/tt]

lcName will then contain the name, and lcID will contain the ID. Both values will be stored as strings.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I would probably put the parameters you want into a text file, and pass a reference to that text file to the VFP application
it can then read them, and you can add to them if you like.

Remember that VFP has a number of preconfigured parameters, with one or two useful gaps, P, I, F, S and J being the ones I use commonly.

So, if your .net program can pass parameters you might pass -Fc:\temp\myconfig.txt and then put your parameters in c:\temp\myconfig.txt as lines
then your VFP program can read them by either position or by using a fixed length prefix (to make your file human readable too).
The example below looks to take the first line of the file specified and use it as m.MyPassedValue:

Code:
PARAMETERS m.PARAM1
private m.Param1, m.MyPassedValue
m.MyPassedValue = ""
IF LEFT(UPPER(m.PARAM1),2) = "-F" 
  m.Paramfile = RIGHT(m.PARAM1,LEN(m.PARAM1)-2)
  IF MyFile(m.ParamFile)
    m.MyPassedValue = MLINE(FileToStr(m.ParamFile),1)
  ENDIF
ENDIF


FUNCTION MYFILE
	PARAMETER m.FILENAME
	PRIVATE m.FILENAME,m.RETVAL
	m.RETVAL = .F.
	IF ADIR(TMPDIRFILES,m.FILENAME) > 0
		m.RETVAL= .T.
	ENDIF
	RETURN(m.RETVAL)




Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Griff, command line options and parameters are not the same, the VFP runtime will swallow -F and other command line options, before the main prg is called with parameters following the options. Eg I start mytest.exee -Bfox.bmp "Paramter", then the main,,prg doesn't see -Bfox.bmp as first parameter. So you can ignore the possibility your EXE is called with options additional to parameters, they will be preprocessed and not forwarded to your own code.

Bye, Olaf.
 
ok thankx guys ... i'll try it out and let you know .... ooh and thankx Griffmg .... i'v tried receiving values into a txt file and then reading from the txt file ... but for some reason ... i have to avoid that.

thankx alot
 
The big question is whether or not your VFP EXE is constantly running and needs to receive the external parameters 'on the fly' or will the VFP EXE be launched each time parameters need to be passed.

If the VFP EXE will be launched each time parameters need to be passed - then the above advice about putting the parameters into the launching command line will work.

But that will not work if the VFP EXE needs to work on parameters passed 'on the fly'.

For that you will need to use another method of passing the parameters such as the text file Griff mentioned above. In that way the VFP EXE can 'interrogate' the text file to see if something is there and use it. Once done using it, it should clear out or flag the parameters so that they would not be used again.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top