Passing Args

Cableguy

Expert
Licensed User
Hi, anyone tryed to pass args from one basic4ppc app to another....I don't understand exactly how to catch the args....
 

stbi

Member
Licensed User
Hi, anyone tryed to pass args from one basic4ppc app to another....I don't understand exactly how to catch the args....
You catch the args with the array args. args(0) is the first parameter, args(1) the second etc, and arraylen(args) returns the number or arguments.
It's documented with a sample in the online help, Basics - Command Line Arguments.
 

dzt

Active Member
Licensed User
I didn't tested it but it should work like the following.

At caller App
shell("prog.exe", "arg1 arg2 arg3")

At called app
msgbox(arg(0)) 'shows "arg1"
...
 

Cableguy

Expert
Licensed User
Hi guys...

After my litle fiasco when sharing the backup utility....I've came back to the IDE...

Strangely enought the code works on the IDE when simulated args in the command line are passes usingt the integrated command line args simulater...
But it doesn't work when I try to pass from another project...

The Shell command should be something like "Shell("Backup.exe","thefilename")

Here are the two files:
 

Attachments

Last edited:

Cableguy

Expert
Licensed User
No, im not passing the full path, just the filename without the extension...

I believe to have it sorted out now....I will keep this updated....

BTW: could you please delete the thread on "share your creations"?, theres no point on keeping it untill Im 200% sure this works....
 

RandomCoder

Well-Known Member
Licensed User
CableGuy originally wrote:
BTW: could you please delete the thread on "share your creations"?, there's no point on keeping it until I'm 200% sure this works....
Is this the thread that backed up B4PPC source code???

I could have swore that I saw a thread started by you but am now unable to find it.
My intention was to have a look at it when I got chance and then maybe modify it so that it only save the last 5 backup's so as to save some disk space.

Regards,
RandomCoder.
 

Cableguy

Expert
Licensed User
You saw right...
But the code I posted strangely enought wasn't working as it should when passing the args from another app...I have it sorted out and working but I'm embarassed to the point of not being to crazy of reposting....Still....
 

Cableguy

Expert
Licensed User
Ok...
Now that I've sorted out what was wrong with my first attemp at passing args, another question pops out:

How can we deternine if any arg was passed?

I need my app to determine the course of action by detecting if any arg was passed or not...If it was passed then execute the main funcion if no args were passed then execute a few secondary ones...

Being Args an array I tryed the Args.count...wasn't recognized by the designer...
Is there any incomvinient in declaring the Args array in the globals?
 

Cableguy

Expert
Licensed User
Second Time You Help me today with 100% success...I was using count as Args is an ArrayList, it just didn't cross my mind to see it as a normal array!!!!lol
 

horatio

Member
still confused

i tried the 'sender.exe,receiver.exe' programs and they work fine on the desktop. how do you get them to work on the ppc though. i've looked at other threads relating to args and the help file but i'm not getting anywhere. thanks for your efforts
 

horatio

Member
This is what i get:-

An unexpected error has occurred in Receiver.exe.
Select Quit and then restart this program, or select Details for more information.

Sender.exe
TypeLoadException
Could not load type System.Windows.Forms.Form from assembly System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=B77A5C561934E089.

The same error message regardless of which program i run. I run everything from my documents in the device root folder.
 

horatio

Member
no joy

ok, no problem, what am I doing wrong now? When I run 'sender.exe', I get nothing happening, when I run 'receiver.exe', I get 'indexoutofrangeexception' error message. Presumably this is because 'receiver.exe' wasn't meant to be run as a stand alone app but rather as an executable linked to 'sender.exe'. Would it be possible to see the source code for these exes or was it the same as before just compiled for device not desktop?
 

agraham

Expert
Licensed User
I got the same results as you. The attached stuff works on the device. The problem was the path to Receiver.exe which seems to work differently on the desktop to the device. Just specifying the filename on the desktop defaults the path to the application directory and works. On the device it seems to need AppPath added to the filename together with a backslash in order to work.:confused:

EDIT : I forgot to save the amended Sender.sbp before making the zip file. I've attached it separately, discard the one in the zip. Sorry!
 

Attachments

Last edited:
Top