PxPlus User Forum

Main Board => Discussions => Programming => Topic started by: Jeffrey Ferreira on October 17, 2022, 11:06:23 AM

Title: Associative Arrays
Post by: Jeffrey Ferreira on October 17, 2022, 11:06:23 AM
Hello All,

If I have a small associative array of items like this
INSTALL_ITEM_ARRAY["INS1"]=1
INSTALL_ITEM_ARRAY["INS2"]=1
INSTALL_ITEM_ARRAY["INS3"]=1

 If I check to see if item is in the array it adds that item to array with a value of 0.
Question -> Is there a way i can check the array without it adding it to array. Is this taking up room in memory ...
if i'm checking a few million invoices lines - i dont want to run into an error 31

I know i can use a memory file but the associative array is quite convenient.

thanks

jeff
Title: Re: Associative Arrays
Post by: Mike King on October 17, 2022, 11:25:49 AM
Have you tried

X = DIM(INDEX INSTALL_ITEM_ARRAY["INSx"])

The DIM(INDEX) will return you the index for the selected item or zero if not in the array.  It will not add the elelment.

Title: Re: Associative Arrays
Post by: Jeffrey Ferreira on October 17, 2022, 11:32:11 AM
Thanks Mike
that is exactly what i am looking for.

jeff