Passing arguments ZGE Application

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Lupo
Posts: 76
Joined: Wed Sep 09, 2009 6:21 pm
Location: Montevideo, Uruguay

Passing arguments ZGE Application

Post 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.
Close, but not there yet.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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 :wink:

K
Attachments
Test.zip
(32.99 KiB) Downloaded 411 times
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Post 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.
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Post 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);
Post Reply