Page 1 of 1
Passing arguments ZGE Application
Posted: Mon Nov 03, 2014 5:36 pm
by Lupo
Hi all,
(Trying to get back to dev...)
Is it possible to pass arguments to an Zge generated aplication?
(Is it available on all platforms?)
Thanks,
Luis.
Posted: Mon Nov 03, 2014 6:05 pm
by Kjell
Hi Lupo,
Lupo wrote:Is it possible to pass arguments to an Zge generated aplication?
There's currently no property / functionality built-in to determine which arguments have been passed when executing a standalone. However, it's pretty simple to pull off yourself. Here's a example for Windows ( attached is a build + batch + shortcut for C:\Test.exe ).
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" NoSound="1">
<OnLoaded>
<ZExternalLibrary ModuleName="kernel32" Source="string GetCommandLineA(){}"/>
<ZExpression Expression="Foo.Text = GetCommandLineA();"/>
</OnLoaded>
<OnRender>
<RenderText Name="Foo" Scale="0.25" StretchY="2"/>
</OnRender>
</ZApplication>
Lupo wrote:Is it available on all platforms?
Not exactly sure what the functions are called on Linux / OS X, but i'm sure each platform has its own equivalent.
Would be nice if a cross-platform solution gets built-in though
K
Posted: Mon Jul 20, 2015 12:34 am
by Imerion
How would I go about to extract data from two different passed arguments into two strings?
The data I get comes in this form : gjapi_username=NAME gjapi_token=TOKEN
And I need to have NAME in one string and TOKEN in another.
Posted: Mon Jul 20, 2015 12:54 am
by Imerion
Maybe I solved it.
Code: Select all
string InputString = GetCommandLineA();
int FindUser = indexOf("name=", InputString, 0);
int FindUserEnd = indexOf("gjapi_token", InputString, 0);
FindUser += 5;
FindUserEnd -= 1;
UserName = subStr(InputString, FindUser, FindUserEnd - FindUser);
int FindToken = indexOf("token=", InputString, 0);
int FindTokenEnd = length(InputString);
FindToken += 6;
UserToken = subStr(InputString, FindUser, FindTokenEnd - FindToken);