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.
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")
Are you passing the full path?
If there are spaces in the path you should add chr(34) (quotes) before and after it.
Attached is a small desktop executable that shows the arguments it received.
This is the code:
B4X:
Sub Globals
End Sub
Sub App_Start
for i = 0 to ArrayLen(args())-1
msgbox("Arg(" & i & "): " & args(i))
next
End Sub
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.
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....
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?
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
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
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.
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?
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.
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!