why do i get this error when compiling?

Sep 14, 2016 at 00:10
400浏览
2 Replies
会员从Oct 23, 2012开始   349帖子
Sep 14, 2016 at 00:10
Im making a closeall button and im stuck on this issue..

void criarlabelControl (string nome,string texto, color cor,int x,int y,int size,int corner=1){
if (nome!='PairLabel')int soma=y+30; else int soma=y; <------ where soma is declared.
ObjectDelete(nome);
ObjectCreate(nome,OBJ_LABEL,0, 0, 0);
ObjectSetText(nome,texto,size, 'tahoma', cor);
ObjectSet(nome, OBJPROP_CORNER, corner);
ObjectSet(nome, OBJPROP_XDISTANCE, x);
ObjectSet(nome, OBJPROP_YDISTANCE, soma); <---- its saying its undeclared but it is above
if you follow the flock like sheep you always end up stepping in shit!
会员从Aug 20, 2009开始   266帖子
Sep 14, 2016 at 02:07 (已编辑 Sep 14, 2016 at 02:12)
Try this..........


void criarlabelControl (string nome,string texto, color cor,int x,int y,int size,int corner=1){
int soma=0;
if (nome!='PairLabel') soma=y+30; else soma=y;
ObjectDelete(nome);
ObjectCreate(nome,OBJ_LABEL,0, 0, 0);
ObjectSetText(nome,texto,size, 'tahoma', cor);
ObjectSet(nome, OBJPROP_CORNER, corner);
ObjectSet(nome, OBJPROP_XDISTANCE, x);
ObjectSet(nome, OBJPROP_YDISTANCE, soma);

With the new #strict property, variables that are declared within a nest only have scope within that nest. So for example if you use :-
for(int x=10;x>-;x--){do this..............}

You will find you cannot access x later in the function because it loses scope. Presumably same applies to an if nest.
Wealth Creation Through Technology
会员从Oct 23, 2012开始   349帖子
Sep 14, 2016 at 13:34
Worked thanks!
if you follow the flock like sheep you always end up stepping in shit!
登录 / 注册 to comment
You must be connected to Myfxbook in order to leave a comment
*商业用途和垃圾邮件将不被容忍,并可能导致账户终止。
提示:发布图片/YouTube网址会自动嵌入到您的帖子中!
提示:键入@符号,自动完成参与此讨论的用户名。