Home   Help Search Login Register  

Author Topic: Seems simple, but i can't figure it, please help ...  (Read 565 times)

0 Members and 1 Guest are viewing this topic.

Kinnon

  • Guest
lo all,

i'm not exactly new to OFP scripting but it has been a while, my problem is this :

I have one script that calls another with a single numeric variable being the only passed parameter :

_i = 0
_total = Count MyArray

#loop

          ...
         
          [_i] exec "script.sqs"        <----------- This is the bugger !

          _i = _i + 1

          ?(_i < _total):goto "loop"

exit

So, it looks simple enough but for some reason my '_i' variable is being transmuted to a group, (West Alpha Black), !

But only when it calls the other script, if i keep track of it within the calling script it's value/type doesn't change.

Any input will be greatly appreciated.

thx




Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Seems simple, but i can't figure it, please help ...
« Reply #1 on: 18 Apr 2004, 16:40:34 »
Have you tried changing _i to a global variable, I mean, use i instead of _i.

I think local variables are confined to the script they are created in.


Planck
I know a little about a lot, and a lot about a little.

Offline Jezuro

  • Members
  • *
  • Hookah 4 lyfe!
    • Jezuro's ArmA Workshop
Re:Seems simple, but i can't figure it, please help ...
« Reply #2 on: 18 Apr 2004, 20:19:01 »
Have you tried changing _i to a global variable, I mean, use i instead of _i.

I think local variables are confined to the script they are created in.


Planck

Nope. You can call other scripts using local variables of the "root" script. They're copied into the called script too. Then it's up to you - you can make the variable local also for the called script or make it global there.

Kinnon: Maybe you're getting the variable in the called script wrong. Are using this? :

_var = (_this select 0)

Because if you use only

_var = _this

it may cause some troubles.
If you're correct in this, post here the start of the called script. Maybe is something wrong there (?)
"We are Her salvation, and through Her command we shall live forever. I will not die. Not here. Not now. Never!!!"

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Seems simple, but i can't figure it, please help ...
« Reply #3 on: 18 Apr 2004, 20:30:06 »
Thanks for that Jezuro, I'll make a note of that for future reference.

Scribbles hastily in his notepad

 ;D


Planck
I know a little about a lot, and a lot about a little.

Kinnon

  • Guest
Re:Seems simple, but i can't figure it, please help ...
« Reply #4 on: 24 Apr 2004, 19:33:15 »
Thanks, people, will try using 'this select 0' as was only using 'this'.