Home   Help Search Login Register  

Author Topic: Retrieving an array index?  (Read 1954 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Retrieving an array index?
« on: 23 Nov 2004, 23:17:40 »
Is it possible to retrieve the index of an item within an array?
urp!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Retrieving an array index?
« Reply #1 on: 23 Nov 2004, 23:23:05 »
There's a tute about that. Check ed depot, look for "variables and arrays in OFP" or something similar.

:beat: *Gets Shot* :beat:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Retrieving an array index?
« Reply #2 on: 23 Nov 2004, 23:39:05 »
No, the array tut covers everything but my question.  I want to know if there is any way to retrieve the position of an item in an array without having to search the whole pissing array element by element.
 
If I can do this:

MyArray set [3, "OPFL array handling is crap"]

Why is there not a corresponding "get" command that will return an array index?

e.g.
Index = get [MyArray,"OPFL array handling is crap"]


There's a tute about that. Check ed depot, look for "variables and arrays in OFP" or something similar.

:beat: *Gets Shot* :beat:

urp!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Retrieving an array index?
« Reply #3 on: 23 Nov 2004, 23:56:28 »
isn't there a in command? Like

? ("OPFL array handling is cool" in array1) : hint "It's in the tute, I think."

:beat: *Gets Shot* :beat:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Retrieving an array index?
« Reply #4 on: 24 Nov 2004, 00:01:50 »
the "in" command simply returns true or false...
urp!

Offline Blanco

  • Former Staff
  • ****
« Last Edit: 24 Nov 2004, 00:28:27 by Blanco »
Search or search or search before you ask.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Retrieving an array index?
« Reply #6 on: 24 Nov 2004, 00:32:23 »
Thanks for the function link, but this was what I was trying to avoid, having to search the whole array for each element.  I guess it can not be done in a more straight forward way.
urp!

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Retrieving an array index?
« Reply #7 on: 24 Nov 2004, 02:19:56 »
This is an interesting one.   Reading the original question, I know for a certain fact that the answer is yes.    However, I have no idea whatsoever of how to do it.    Regular readers of my posts (if any) will appreciate that this summarises my scripting non-skill beautifully.

It is frequently the case that OFP code will do what you want, but is a little inelegant.   In such cases it is necessary to make a judgement call as to whether you can stomach the inelegance or not.   Not, of course, means abandoning the whole misssion/addon/idea.

It would seem, in this case, that your options are to

1) abandon the whole thing

2) go with GB's function (he's a good lad, it probably works)

3) invent your own better, faster, sexier, cooler function
Plenty of reviewed ArmA missions for you to play

Korax

  • Guest
Re:Retrieving an array index?
« Reply #8 on: 24 Nov 2004, 03:21:39 »
Or, get spend $200 and get VBS, it has a 'find' command which is exactly what you want :P

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Retrieving an array index?
« Reply #9 on: 24 Nov 2004, 07:56:08 »
Excsue my ignorance, but what is VBS?

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Retrieving an array index?
« Reply #10 on: 24 Nov 2004, 08:11:18 »
*points @ THobson and laughs

u dont know whats VBS :wow:

its OFP military version thats all ::)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Retrieving an array index?
« Reply #11 on: 24 Nov 2004, 15:18:58 »
LCD - are you a lawyer?

You answered the question, the answer was complete, accurate and totally useless to me.  Well actually not quite.   ;) So apart from googling VBS what can I do to find out more?
« Last Edit: 24 Nov 2004, 15:19:51 by THobson »

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Retrieving an array index?
« Reply #12 on: 24 Nov 2004, 15:23:17 »
VBS = OFP with better graphics and 100 times more expensive.

Kinda like art. Except the other way round. The uglier it gets, the more it costs.

:beat: *Gets Shot* :beat:

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Retrieving an array index?
« Reply #13 on: 24 Nov 2004, 15:50:41 »
dmpkatra:  I detect a value judgement creeping in.

Your damned banana give me real problems at work - I just had someone commenting on what serious work I was involved with!!

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Retrieving an array index?
« Reply #14 on: 24 Nov 2004, 16:03:22 »
ROFL. I have actually been thinking of changing it. But I thought a name change was dramatic enough. If I would take away OFPECs favorite banana all hell would break loose. ;D

:beat: *Gets Shot* :beat: