2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
argument in function
#383621
09/22/11 18:26
09/22/11 18:26
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
hi, here is my code : function mfj(a) { if (a==0) { ja1+=a;ja2+=a;ja3+=a;ja4+=a;ja5+=a;ja6+=a;ja7+=a;ja8+=a;ja9+=a;ja10+=a; } }
it would be nice if i could write it easier.. i know use simple argument, but its a little more complicated here. for automate the jaX+=a list, i could do smt like i=0; while (i<=10) { ja(i)+=a;i++; }
but it can't work this way.. right ? does anyone have a solution for do this thing ? (like the second quote but working) thanks
|
|
|
Re: argument in function
[Re: ayks]
#383622
09/22/11 18:50
09/22/11 18:50
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Reconsider if you really don't want to use an array in this case.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: argument in function
[Re: WretchedSid]
#383623
09/22/11 19:04
09/22/11 19:04
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
you can do it like this
var ja[10];
...
i=0;
while (i<10) // another thing: This has to be i<10 not i<=10
{
ja[i] +=a;
i++;
}
you could also do it with for(){} ...but this should work, too but in your first code: if(a == 0) [...] ja1 += a; [...] - does this really make sense?! and be a bit careful... the first var in this array is ja[0] - not ja[1]
POTATO-MAN saves the day! - Random
|
|
|
Re: argument in function
[Re: Kartoffel]
#383638
09/22/11 22:14
09/22/11 22:14
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
Oh, i see.. the array was the solution. I'm so dumb.. i use array for all my "gauge" like "chronograph" but I didnt use them for this case.. First I thought it couldnt work because i needed to do the same thing with ja1.visible=on;ja2.visible=on;ja3.visible=on;ja10.visible=on; and I think its not that simple in this case, but this is another problem. I hope i will find a solution with that way. edit : looks unaccessible with strings instead of variables Anyway, i'll try it right now and i guess there will be no problem. Thanks for your 2 answers and for the detailed code and the tip.
Last edited by ayks; 09/22/11 23:00.
|
|
|
Re: argument in function
[Re: ayks]
#383758
09/25/11 02:25
09/25/11 02:25
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
Excuse to ask again for help, but i need to do the same thing, instead of its ja1.visible=on;ja2.visible=on;ja3.visible=on; Its more complicated since its not only variable.. and all the "ja" are panels.. I can't make an array of panels. Can anyone tell me the method i have to look for ? thanks
|
|
|
Re: argument in function
[Re: ayks]
#383769
09/25/11 08:33
09/25/11 08:33
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
You sure can create an array of panels like you can with every data type. What makes you think that its not possible?
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: argument in function
[Re: ayks]
#383822
09/25/11 21:31
09/25/11 21:31
|
Joined: Sep 2009
Posts: 155 France
ayks
OP
Member
|
OP
Member
Joined: Sep 2009
Posts: 155
France
|
Hi again, I advanced a bit, now i have this : TEXT string_array = // create an array of string with a text { strings = 20; string = ("j1","j2", "j3", "j4"); layer=15; flags = VISIBLE; } which is an array of string. now i need it to work : string_array.string[0].visible=off; but it don't. 2 questions : - Is this the good way for doing an array of string ? - If yes, can i have a tip for make the last quote work ? thanks
Last edited by ayks; 09/25/11 21:33.
|
|
|
Re: argument in function
[Re: PadMalcom]
#383827
09/25/11 23:02
09/25/11 23:02
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
2: You can make a TEXT object visible or not, but not each single string in it. That's not correct, there's a function esp. for this purpose: txt_set(in)visible(TEXT* text,var index number of string starting at 0);
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|