Normal Topic @Shell vs CreateAProcess ( ) (Read 1465 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
@Shell vs CreateAProcess ( )
Jul 6th, 2012 at 1:46pm
Print Post Print Post  
Code
Select All
var vSuccess as Int


vSuccess = @Shell ("C:\Program Files\docPrint Pro v5.0\doc2pdf.exe" -i "C:\Users\Naik\Google Drive\FonDocuments\01419-20120624-0000037.doc" -o C:\Sesame2\Records\01419-20120624-0000037.pdf )

CreateAProcess ("C:\Program Files\docPrint Pro v5.0\doc2pdf.exe" -i "C:\Users\Naik\Google Drive\FonDocuments\01419-20120624-0000037.doc" -o C:\Sesame2\Records\01419-20120624-0000037.pdf )
 



The above commands uses external program to convert .doc file to .pdf file and it takes about 15 seconds to complete the process... kind of slow. The command to follow this use the created file to combine with other pdf file.

In the above code, @Shell ( ) command does not work. I do not know why? CreateAProcess ( ) command works fine. The problem is CreateAProcess ( ) is asynchronous command and sbasic does not wait until the command is completed and the resultant file is used with sbasic commands to follow. The only way, it will work if I put Loiter ( ) command or some routine to see that the file is created before sBasic command executes.

My question is:  Why does @Shell ( ) command fail to work here? How can I make it work?

Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @Shell vs CreateAProcess ( )
Reply #1 - Jul 6th, 2012 at 1:49pm
Print Post Print Post  
Just from a brief glance, it looks like both suffer from string construction problems. Instead of passing the string to a function, build it in a string variable and display it with Writeln.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @Shell vs CreateAProcess ( )
Reply #2 - Jul 6th, 2012 at 1:54pm
Print Post Print Post  
Code
Select All
vSuccess = @Shell ( @chr (34) + "C:\Program Files\docPrint Pro v5.0\doc2pdf.exe" + @Chr (34) + " -i " + @chr (34) +  vString + @chr (34) +  " -o "  +  vNewPDFFile )
CreateAProcess ( @chr (34) + "C:\Program Files\docPrint Pro v5.0\doc2pdf.exe" + @Chr (34) + " -i " + @chr (34) +  vString + @chr (34) +  " -o "  +  vNewPDFFile )


 



Above is the exact command. @Shell ( ) does not work, while CreateAProcess ( ) works.

vString has space in there, that is why put into quotes while the vNewPDFFile does not have any space in there.

  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @Shell vs CreateAProcess ( )
Reply #3 - Jul 6th, 2012 at 1:55pm
Print Post Print Post  
If you print it to a Writeln window and cut&paste it into a command line, does it work?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @Shell vs CreateAProcess ( )
Reply #4 - Jul 6th, 2012 at 2:15pm
Print Post Print Post  
Yes, it works as the commandline either in the Dos shell as well as through Run.  I am using Windows 7.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: @Shell vs CreateAProcess ( )
Reply #5 - Jul 6th, 2012 at 5:22pm
Print Post Print Post  
Odd. @Shell calls "system()" (a C function) that in turn passes the command to a command line shell window (hence the "black box" window that appears).

Can you make other commands work?

Have you tried using @RedirectProcess?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged