Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open a file using Run command

1,808 views
Skip to first unread message

Somnath

unread,
May 13, 2009, 9:05:15 AM5/13/09
to
Hi,

PB 11.5 on Vista Business / XP SP2 / XP SP3

We have a blob column that is used to save documents attached to various
records. These documents can be any type of document i.e. Word, Excel, Zip,
PPT, PSD, HTML anything. We save the name of the file in a vachar and the
actual file in a blob. The client needs to open the file from the app in 1
click without saving in any folder. Presently the user saves the file to a
folder and then opens the file by double clicking on Windows Explorer. So,
now we need to open the file straighaway. I am now saving the file to the
Windows Temp folder using selectblob and filewrite operations. However, then
I though I will just open the file using: RUN("somefile.txt") but this does
not work. I have tried all the following commands and dont know how to make
it work:

run("c:\windows\temp\somefile.txt")
run("start c:\windows\temp\somefile.txt")

I know I can use run("notepad c:\windows\temp\somefile.txt") but that will
not help as in case of say an Autocad document it will then not work. I find
I can type "c:\windows\temp\somefile.txt" in the Windows Run command (both
in Vista and XP) and it works. But the PB run command fails to execute and
returns -1.

What is wrong? Can you please tell me how to get it working?

Thanks in advance,

Somnath

JMR

unread,
May 13, 2009, 10:02:02 AM5/13/09
to
Have you tried with ShellExecute ? (Windows API)

FUNCTION long ShellExecuteA (ulong hWnd, &
string Operation, string lpFile, string lpParameters, &
string lpDirectory, long nShowCmd) LIBRARY "shell32.dll"
&
ALIAS FOR "ShellExecuteA;Ansi"


Your code should be something like:

ll_mode = 3
ls_path = ""
ls_file = gs_appdir + "c:\windows\temp\myfile.txt"
ls_params = ""
ls_cmd = "open"
ll_ret = ShellExecuteA(Handle(This) , ls_cmd , ls_file ,
ls_params , ls_path , ll_mode)
if not(ll_ret < 0 or ll_ret > 32) then
msgBox(gs_appname,"Open failed for file " + ls_file +
"~nReturn code = " + string(ll_ret),Information!,Ok!)
end if

Roland Smith [TeamSybase]

unread,
May 13, 2009, 11:43:26 AM5/13/09
to
Try this example on my website:
http://www.topwizprogramming.com/freecode_runandwait.html

"Somnath" <junka...@somedomain.com> wrote in message
news:4a0ac58b@forums-1-dub...

0 new messages