Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Array Conundrum
Message
 
To
11/04/2005 14:58:01
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01003455
Message ID:
01003465
Views:
21
This message has been marked as the solution to the initial question of the thread.
I know I have probably done this before, but I cannot locate any similar code. I have an array like so:
>
>myarray(1,1) ="Driver1 Violation1"
>myarray(1,2) ="Driver1 Violation2"
>myarray(1,3) ="Driver1 Violation3"
>myarray(1,4) ="Driver1 Violation4"
>myarray(1,5) ="Driver1 Violation5"
>myarray(1,6) ="Driver1 Violation6"
>myarray(1,7) ="Driver1 Violation7"
>myarray(1,8) ="Driver1 Violation8"
>myarray(1,9) ="Driver1 Violation9"
>myarray(1,10)="Driver1 Violation10"
>myarray(2,1) ="Driver2 Violation1"
>myarray(2,2) ="Driver2 Violation2"
>myarray(2,3) ="Driver2 Violation3"
>myarray(2,4) ="Driver2 Violation4"
>myarray(2,5) ="Driver2 Violation5"
>myarray(2,6) ="Driver2 Violation6"
>myarray(2,7) ="Driver2 Violation7"
>myarray(2,8) ="Driver2 Violation8"
>myarray(2,9) ="Driver2 Violation9"
>myarray(2,10)="Driver2 Violation10"
>
>I need to redimension this to 2,20 IF 1,11 -> 1,20 do not exist. The idea is to allow for 20 violations for Driver1, Driver2, etc (however many rows there are). I need to do this so it ends up like so:
>
>myarray(1,1) ="Driver1 Violation1"
>myarray(1,2) ="Driver1 Violation2"
>myarray(1,3) ="Driver1 Violation3"
>myarray(1,4) ="Driver1 Violation4"
>myarray(1,5) ="Driver1 Violation5"
>myarray(1,6) ="Driver1 Violation6"
>myarray(1,7) ="Driver1 Violation7"
>myarray(1,8) ="Driver1 Violation8"
>myarray(1,9) ="Driver1 Violation9"
>myarray(1,10)="Driver1 Violation10"
>myarray(1,11) =""
>myarray(1,12) =""
>myarray(1,13) =""
>myarray(1,14) =""
>myarray(1,15) =""
>myarray(1,16) =""
>myarray(1,17) =""
>myarray(1,18) =""
>myarray(1,19) =""
>myarray(1,20) =""
>myarray(2,1) ="Driver2 Violation1"
>myarray(2,2) ="Driver2 Violation2"
>myarray(2,3) ="Driver2 Violation3"
>myarray(2,4) ="Driver2 Violation4"
>myarray(2,5) ="Driver2 Violation5"
>myarray(2,6) ="Driver2 Violation6"
>myarray(2,7) ="Driver2 Violation7"
>myarray(2,8) ="Driver2 Violation8"
>myarray(2,9) ="Driver2 Violation9"
>myarray(2,10)="Driver2 Violation10"
>myarray(2,11) =""
>myarray(2,12) =""
>myarray(2,13) =""
>myarray(2,14) =""
>myarray(2,15) =""
>myarray(2,16) =""
>myarray(2,17) =""
>myarray(2,18) =""
>myarray(2,19) =""
>myarray(2,20) =""
>
>There must be a simple way to check for the existance of myarray(1,11) without it returning .T. if the array is currently dimensioned myarray(2,10) and (2,1) exists? Then of course, once I can successfully determine that myarray(1,11)-myarray(1,20) do not exist, I need to redimension it without shifting the values to the wrong row and column. I am obviously forgetting something basic here but I cannot think what it is.
>
>TIA,
>Tracy


May be:
count_elements = ALEN(myarray)
DECLARE new_array[count_elements/10,20]
FOR main_loop = 1 TO count_elements/10
    FOR sub_loop = 1 TO 20
       new_array[main_loop,sub_loop] = IIF(sub_loop < 11,myarray[(main_loop-1)*10+sub_loop],'')
    ENDFOR
NEXT
_______________________________________________________________
Testing displays the presence, not the absence of bugs.
If a software application has to be designed, it has to be designed correctly!
_______________________________________________________________
Vladimir Zografski
Systems Analyst
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform