Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Invoking a perl script
Message
From
14/03/2005 13:30:17
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00994810
Message ID:
00995606
Views:
11
I would use createprocess for this, but I think you could also use shellexecute. Here is a simple example:

Assumes perl.exe is in c:\perl\bin and a the sample.pl script below is in c:\perl\scripts

sample.pl
print "Please type in either heads or tails: ";

#The <STDIN> is the way to read keyboard input
$answer = <STDIN>;
chomp $answer;

while ( $answer ne "heads" and $answer ne "tails" ) {
	print "I asked you to type heads or tails. Please do so: ";
	$answer = <STDIN>;
	chomp $answer;
}

print "Thanks. You chose $answer.\n";
print "Hit enter key to continue: ";

#This line is here to pause the script
#until you hit the carriage return
#but the input is never used for anything.
$_ = <STDIN>;

if ( $answer eq "heads" ) {
	print "HEADS! you WON!\n";
} else {
	print "TAILS?! you lost. Try again!\n";
}
vfp runperl.prg
declare long ShellExecute in "shell32.dll" long hwnd, string lpszOp, ;
                    string lpszFile, string lpszParams, ;
                    string lpszDir, long nShowCmd

declare long GetDesktopWindow in"win32api"

local hDCScreen

hDCScreen = GetDesktopWindow()

IF ShellExecute( hDCScreen, "open","c:\perl\bin\perl.exe","c:\perl\scripts\sample.pl","",1) <= 32
	=MESSAGEBOX("Could not load perl.")
ENDIF
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform