Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,170 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Question about execute() #324320
05/20/10 12:41
05/20/10 12:41
Joined: Aug 2005
Posts: 238
Caermundh Offline OP
Member
Caermundh  Offline OP
Member

Joined: Aug 2005
Posts: 238
Ok, so the manual states that execute() is for "executing an engine function or variable assignment from a character sequence." - I take it that this means i can only use execute() to change engine variables (like camera.clip) and not other variables (like var my_var;). Is this a correct assumption? Also is there some way to change the value of my_var with an execute() type function during runtime?

Re: Question about execute() [Re: Caermundh] #324336
05/20/10 13:19
05/20/10 13:19
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Your assumption is right. You can change self-defined variables with var_for_name. See http://www.conitec.net/beta/var_for_name.htm.

EDIT@widi: Haha! tongue


Always learn from history, to be sure you make the same mistakes again...
Re: Question about execute() [Re: Caermundh] #324344
05/20/10 13:32
05/20/10 13:32
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
This is correct. Also in the manual:

For altering script variables, use var_for_name.

inkey(TEST_STR);
if (13 == result) var_for_name(TEST_STR);


EDIT: with my tests if var_vor_name works, Uhrwerk was faster...

Last edited by Widi; 05/20/10 13:33.
Re: Question about execute() [Re: Widi] #324464
05/20/10 23:29
05/20/10 23:29
Joined: Aug 2005
Posts: 238
Caermundh Offline OP
Member
Caermundh  Offline OP
Member

Joined: Aug 2005
Posts: 238
Ok, so i tried:

function* function_ptr(var my_var);

function my_func(var my_var)
{ <code>
}

function main()
{ STRING* exec_str = " ";
str_cpy(exec_str,"function_ptr = ");
str_cat(exec_str,"my_func");
var_for_name(exec_str);
if(function_ptr)
{ function_ptr(1);
}
}

This does not work. function_ptr gets set to NULL instead of the function. Can you not use var_for_name to reassign function pointers? You can only use it to change var type variables, i guess?

Re: Question about execute() [Re: Caermundh] #324467
05/20/10 23:59
05/20/10 23:59
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Yes, your are right. You can changed fixed, i.e. var variables and Strings. I have never tested it with int or double variables. Just try it. For calling functions you can use http://www.conitec.net/beta/engine_getscript.htm.


Always learn from history, to be sure you make the same mistakes again...
Re: Question about execute() [Re: Uhrwerk] #324517
05/21/10 13:23
05/21/10 13:23
Joined: Aug 2005
Posts: 238
Caermundh Offline OP
Member
Caermundh  Offline OP
Member

Joined: Aug 2005
Posts: 238
Alright! engine_getscript() did the trick....almost. heh

I tried:

STRING* my_str = "my_func";
void* myfuncptr(var my_var);

function my_func(var my_var)
{ <code>
}

function main()
{ myfuncptr = engine_getscript(_chr(my_str));
if(myfuncptr)
{ myfuncptr(1);
}
}

It turns out that engine_getscript specifically requires a char* array, a STRING* doesnt work (engine_getscript returns NULL if you use a STRING*) so I had to use _chr() to convert the STRING* to char*

Re: Question about execute() [Re: Caermundh] #324523
05/21/10 13:48
05/21/10 13:48
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You can just use "engine_getscript(my_str->chars);" for this purpose.


Always learn from history, to be sure you make the same mistakes again...

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

Gamestudio download | chip programmers | 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