Gamestudio Links
Zorro Links
Newest Posts
Zorro 3.01 recoded MMI function issue
by 11honza11. 06/13/26 11:40
How to select between IB accounts by script?
by Jack_Zodiac. 06/12/26 23:17
Zorro tutorial ideas?
by pr0logic. 06/12/26 13:36
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/12/26 08:50
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
Z9 getting Error 058
by k_ivan. 06/10/26 14:38
ZorroGPT
by TipmyPip. 06/10/26 13:07
Z12 live performance
by alx. 06/09/26 20:42
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (1 invisible), 2,327 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
passing a string in from the command line #128784
05/09/07 01:00
05/09/07 01:00
Joined: Apr 2007
Posts: 5
J
jlsf2 Offline OP
Newbie
jlsf2  Offline OP
Newbie
J

Joined: Apr 2007
Posts: 5
I'd like to pass a string in from the command line but am not sure of the format or what type of variable is created.

I'm assuming it is something like: -d var1,"foobar"

But when I try to access it as either a string or STRING, I get run-time errors.

Anyone know how this is supposed to be used?

Thanks.

Re: passing a string in from the command line [Re: jlsf2] #128785
05/09/07 01:29
05/09/07 01:29
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
I don't know if this would work (I only have Commercial). But if you have Professional, then you might be able to make a string containing the COMMAND paramaters in the WINDOW WINSTART function, and use a str_cpy command to copy the command line parameters from the string to the WINSTART function.

If this isn't what you are trying to do, let me know.


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: passing a string in from the command line [Re: MrCode] #128786
05/09/07 03:04
05/09/07 03:04
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
I dunno if strings work and from the manual it seems it can take integer/float
values only.So you could try :-

-d var1

...

IFDEF var1;
{
str_cpy(my_str,"foobar");
}

I haven't tried it,but let me know if it works !
Secondly,how can a value given by -d be directly
accesed via C-script ?


I like good 'views' because they have no 'strings' attached..
Re: passing a string in from the command line [Re: zazang] #128787
05/09/07 14:45
05/09/07 14:45
Joined: Apr 2007
Posts: 5
J
jlsf2 Offline OP
Newbie
jlsf2  Offline OP
Newbie
J

Joined: Apr 2007
Posts: 5
Ok, a couple of replies:

MrCode:
Isn't the COMMAND feature used to pass command-line arguments to the app after the WINSTART has completed?
Not sure I see how to pass Windows command-line arguments into the WINSTART function.
I do have Pro version, so if I could pass to the WINSTART and then pass to the regular app, that would be great, but I don't see it...

zazang:
Your example would work, but I don't know what the string value will be; "foobar" is just an example -> the string could be anything.

As for using the variables directly, you just treat them as if they have been declared. So, for -d var1,5
if ( var1 == 5 ) { ... }
works fine without any other declarations for var1.

Re: passing a string in from the command line [Re: jlsf2] #128788
05/09/07 16:16
05/09/07 16:16
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
Thanks..This way of adding vars from the environment could be helpful !
Yeah I too wonder if strings can be directly passed like vars through command line

Re: passing a string in from the command line [Re: zazang] #128789
05/09/07 16:46
05/09/07 16:46
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
In general you could pass arbitrary things to trough the command line by passing c-script instructions and then executing via the "execute" instruction at the beginning of your main function. You could then pass "str_cpy(MyString,"Hello World!")" to the command line and that would initialize the string MyString with "Hello World!".


Always learn from history, to be sure you make the same mistakes again...
Re: passing a string in from the command line [Re: Uhrwerk] #128790
05/09/07 22:42
05/09/07 22:42
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline
User
MrCode  Offline
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
That's basically what I just said:

Quote:


you might be able to make a string containing the COMMAND paramaters in the WINDOW WINSTART function, and use a str_cpy command to copy the command line parameters from the string to the WINSTART function






Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: passing a string in from the command line [Re: MrCode] #128791
05/09/07 23:25
05/09/07 23:25
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
No, it isn't. Your solution is fixed to strings while the method I suggested would allow to execute arbitrary code.


Always learn from history, to be sure you make the same mistakes again...
Re: passing a string in from the command line [Re: Uhrwerk] #128792
05/10/07 02:49
05/10/07 02:49
Joined: Nov 2003
Posts: 1,659
San Francisco
JetpackMonkey Offline
Serious User
JetpackMonkey  Offline
Serious User

Joined: Nov 2003
Posts: 1,659
San Francisco
My dog passed a string once

Re: passing a string in from the command line [Re: Uhrwerk] #128793
05/10/07 03:57
05/10/07 03:57
Joined: Apr 2007
Posts: 5
J
jlsf2 Offline OP
Newbie
jlsf2  Offline OP
Newbie
J

Joined: Apr 2007
Posts: 5
Not sure I understand. Is this using the WINSTART function?
Or, is the string to pass to execute() being passed via the regular command-line arguments?

I've never used WINSTART and the help file has very little info and no examples for this.

Thanks.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1