If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Acessing Dynamic Array elements by number

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-04, 12:21
majicm majicm is offline
Registered User
 
Join Date: Aug 2004
Location: UK
Posts: 9
Acessing Dynamic Array elements by number

Hi all...

I know you can access normal array elements using the myarray[1] type of syntax, but is it possible to access the elements of a dynamic array using the same type of syntax?

I.e instead of dynArr["name"] use dynArr[2] ?

Thanks foir the help! Thought I'd accessed them this way before but now it doesn't seem to work!

Cheers!
Reply With Quote
  #2 (permalink)  
Old 10-18-04, 12:27
Maroonotmoron Maroonotmoron is offline
Registered User
 
Join Date: Sep 2003
Location: Dallas
Posts: 182
A little juggling

keys in dynamic arrays are always strings instead of integers but you can get around it with a little juggling:

Say you have a dynamic array "lottastuff" with 12 elements,

you need to add a fixed string array variable say "lskeys"

Now you load the elements from lottastuff into lskeys with

lottastuff.getkeys(lskeys).

At this point lskeys[1] = the first element in lottastuff
lskeys[2] = the second element in lottastuff etc.

Now to address an element in lottastuff directly using integers you simply use

lottastuff[lskeys[3]] which would be the value of the third element in lottastuff[].
Reply With Quote
  #3 (permalink)  
Old 10-18-04, 17:21
majicm majicm is offline
Registered User
 
Join Date: Aug 2004
Location: UK
Posts: 9
Thanks very much, didn't think of it that way...

I got round what I was doing, albeit in a crappy way.. But it wasn't a very nice project I was working on and was glad to finish it heh

Thanks again!
Reply With Quote
  #4 (permalink)  
Old 10-18-04, 20:11
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
The order in which keys appear in a DynArray (e.g. with forEach) may change at any time. There is no concept of "ordering" of a dynamic array.

Likewise, in an ordinary Array, there is no concept of keys.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
  #5 (permalink)  
Old 10-20-04, 11:53
Maroonotmoron Maroonotmoron is offline
Registered User
 
Join Date: Sep 2003
Location: Dallas
Posts: 182
Actually the "order" of the keys don't change. There is no concept of "order." But a virtual order can be established using a standard array as a proxy.

The solution to the problem is not found in answering the question asked, but in understanding it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On