Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (rki), 405 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
advideLong & script #480671
06/25/20 17:07
06/25/20 17:07
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

I have one script where I generate rules
Code
scritp gen.c

function run()
{
  	assetList("Assets4");
        string cSymbol=strx(Asset,"/","");
	Script = strf("AlfaEE_%s",cSymbol);

     ...
        vL = adviseLong(PATTERN+FAST,0,
}


and in second - where I use rules from first (gen.c). But I cannot get, if second script use this rules or not
Code
script second.c
function run()
{
  	assetList("Assets4");
        string cSymbol=strx(Asset,"/","");
	Script = strf("AlfaEE_%s",cSymbol);


I change name the script to:
Script = "AlfaEE_error";

but I dont see any error and script second.c runnign without problem. But no open any order.




Last edited by Grat; 06/25/20 17:16.
Re: advideLong & script [Re: Grat] #480672
06/25/20 21:14
06/25/20 21:14
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Never use Script = strf(), chances of failure are about 100%. Use a real char buffer instead.

Re: advideLong & script [Re: Grat] #480673
06/26/20 05:40
06/26/20 05:40
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Ok,

I have rules from GEN.c store in:
AlfaEE_GBPUSD_GBPUSD.c

Now, I run second script with this:
cSymbol=strx(Asset,"/",""); // GLOBAL var
string cPom=strf("AlfaEE_%s",cSymbol);
Script = cPom;
printf("\nUse script %s",Script);

and in the LOGFILE I don't any problem.

I change the this:
string cPom=strf("eeeAlfaEE_%s",cSymbol);
Script = cPom;

and also not get any problem in the log file.


Is a possible get any info, which rules load in the script?

Re: advideLong & script [Re: Grat] #480674
06/26/20 13:21
06/26/20 13:21
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
You didn't do what I said to do. You did not create a char buffer. Take a look at this code and its output:
Code
void main(void){
	string a = strf("apple");
	string b = a;
	char c[20];
	strcpy(c,a);
	string d = c;
	printf("\na1: %s",a);
	printf("\nb1: %s",b);
	printf("\nc1: %s",c);
	printf("\nd1: %s",d);
	int i;
	for(i=0;i<100;i++){
		strf("banana%d",i);
	}
	printf("\na2: %s",a);//undefined behavior (bad)
	printf("\nb2: %s",b);//undefined behavior (bad)
	printf("\nc2: %s",c);//defined behavior (good)
	printf("\nd2: %s",d);//defined behavior (good)
}

/*output:
a1: apple
b1: apple
c1: apple
d1: apple
a2: banana99
b2: banana99
c2: apple
d2: apple
*/
Note that a and b were ruined, whereas c and d remained intact.

By the way, strx() also returns temporary pointers, so you can expect similar problems.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1