Shell function

I am very new to XOJO. I am try to run an application of a shell function, as shown below:

Var fff As FolderItem
fff = Folderitem.ShowSelectFolderDialog

dim sh as new shell
dim f as FolderItem
dim ss as string
f=new folderitem(“C:\foldername\prog,exe”)

if f <> nil then
if f.Exists then
messagebox"File not found"
end if

Sorry - I hadn’t not finished.

The application seems to run but it needs to read files from the c:\foldername, which are their. But xojo say the files are not found.

What am I doing wrong.

Thanks in advance.

Thanks in advance

Hi Zak,

seen this video?
perhaps this helps you.

Thanks Roger. Not quite what I am look for. The application shelled out (prop,exe) generates a text file, which xojo has to read in and populate labels, graphs etc.

The process is repeated but we don’t re-shell prog.exe. It stays running in teh back ground picking up input text files and generate output text for populating controls in xojo.

What I don’t understand is why prog.exe does not read data files present on that folder?

I can do this in VB6 and also VB dot net.

Any help will be appreciated. Thanks

So, your shell creates a text file and that text file is what you want to read into your program?
After reading it in it needs to set a label or something else?
is that correct?

There are many files involved and read by prog.exe. One input text file is generated by xojo for prog,exe before shelling. When prog.exe has finished it generates an output text file for xojo to read and has to update xojo forms (labels, graphs etc., although prog,exe is still running in the back ground waiting for a next input text file from xojo).

Inputs are entered by to user via text boxes, sliders, etc. until the use decides to end the application via an end button.

This is an engine simulator and did it all in VB6. I would like to do this in XOJO but prog.exe does not find the files it needs but they are there in that folder?

Ok, so prog.exe gives you an text file and xojo has to read that in.
Well, what you can do is read that file in with xojo.
You don’t need the shell for that.
All you have to know is the full path and the name to that text file.
The code from you quistion, does that work?
If you want only to keep prog.exe on the background, there is an easy way.
see the video.

Thanks for that - I can read and write text files from XOJO. But want to shell out the application prog.exe rather than starting it separately, which I have not tried yet.

When I shell prop.exe it starts reading files but it can’t find them? Why, when I have set the folder where prog.exe and data files reside on the disk it, it can find the data files?

Thanks for any help!

Guessing, I would say that this prog.exe is assuming the default directory to be the one it ran from. That is likely true when you run it manually, but won’t necessarily be true when running it from a shell.

You might instead try FolderItem.Open or determine if there is a way to tell prog.exe more precisely where to look for files.

1 Like

I just tried it but got an error

Window1.PushButton2.Action, line 6
There is no class with this name
var f as

Have I done this correctly? Kindly advise. Thanks

Try this & see if it works.

dim sh as new shell
dim f as FolderItem
dim ss as string
f=new folderitem(“C:\foldername\prog,exe”)
ss=“c: && cd \foldername && prog,exe”

if f <> nil then
if f.Exists then
messagebox"File not found"
end if


Yep! That worked. Thanks very much indeed.

However, it keep bring up the folder dialog box. I would have thought that it would return to the main form, as a button action on this form starts the process.

i tried fff = Folderitem.ShowSelectFolderDialog(“full folder name”) it does’nt like that

Window1.PushButton2.Action, line 2
Too many arguments: got 1, expected only 0.
fff = Folderitem.ShowSelectFolderDialog("****\simulator\NPSS_Style-BetaL\GenexB")

Sorry about ****


I am sorry - there was an error on my part. When I run it correctly your method does work and XOJO does returned to the main screen.

When I come to compile it, which I can’t do at present. then I only need:


And I need not any of the folder stuff - just the application name?

Kindly confirm. Thanks

If your application is installed in the same folder as prog.exe then that will be the current folder so you won’t need to cd before executing prog.exe.

Yes, all applications and data files reside on the same folder.

Brilliant support!! Thanks