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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUN command 3

Status
Not open for further replies.

linousa

IS-IT--Management
Mar 8, 2013
79
0
0
US
Trying to run external application, but all I get is that MS-DOS window blink once, here is my code:
Code:
cXFile = "C:\Program Files\abc\xyz.exe"
Run &cXFile
 
Code:
OpenFile('c:\Program File\abc\xyz.exe')

FUNCTION openfile(tcFile)

	IF EMPTY(tcFile)
		RETURN
	ENDIF

	IF NOT FILE(tcFile)
		MESSAGEBOX("File [ " + ALLTRIM(tcFile) + " ] cannot be located.  Please try again.",16,"Open file")
		RETURN
	ENDIF

	DECLARE INTEGER ShellExecute IN shell32.DLL ;
		INTEGER hndWin, ;
		STRING cAction, ;
		STRING cFileName, ;
		STRING cParams, ;
		STRING cDir, ;
		INTEGER nShowWin

	ShellExecute(0,"open",tcFile,"","",1)
ENDFUNC


Ez Logic
Michigan
 
Thank you. When I run this code by itself, it is fine, but when I am trying to use it in IF statement, it fails with "An IF | ELSE | ENDIF statement is missing" compile error. Where do I store user-defined functions? Are they should be in a specific place?
Code:
If gcGood

	helpFile("'c:\Program File\abc\xyz.exe'")

Function helpFile(tcFile)
If Empty(tcFile)
	Return
Endif

If Not File(tcFile)
	Messagebox("File [ " + Alltrim(tcFile) + " ] cannot be located.  Please try again.",16,"Open file")
	Return
Endif

Declare Integer ShellExecute In shell32.Dll ;
	INTEGER hndWin, ;
	STRING cAction, ;
	STRING cFileName, ;
	STRING cParams, ;
	STRING cDir, ;
	INTEGER nShowWin

ShellExecute(0,"open",tcFile,"","",1)
Endfunc
	
Endif
 
The functions need to be outside of the IF/ENDIF
Code:
If gcGood
    helpFile("'c:\Program File\abc\xyz.exe'")
endif

Function helpFile(tcFile)
...
 
This is what I have tried first and this is what I am getting -
untitled_lzglch.png
 
If gcGood
HelpFile(.....)
Endif

Function HelpFile()
etc..
etc..
EndFunc

Ez Logic
Michigan
 
Are you putting the function Helpfile() inside a method?
on a form?

Put it in your main PRG , assuming you have Set procedure to Main.prg additve

or do this:

Create a method on your form call it "HelpFile"

Paste the code of the function (without the Function/EndFunc start/end)

and then do this:

If gcGood
Thisform.HelpFilee(...)
endif


Ez Logic
Michigan
 
If you're calling Helpfile inside a method of a class, and you only need the function in that class, make it another method of the same class, and then call it as This.HelpFile(...)

Tamar
 
Finally, it worked though using method option, thank you! [thumbsup2]
[SOLVED]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top