Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
!empty statement issue in arrays
Message
From
09/05/2011 09:25:45
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01509826
Message ID:
01510041
Views:
71
I often say arrays are abused in VFP. Cursors are just as fast. I find that code using arrays is harder to follow and maintain. I shudder looking at the code you posted here. Furthermore VFP does have have many native array functions.

>>You have to define what "empty array" means in your case.
>>
>>>I have an array the I have populated with values. When I go to test the array to see if it is empty, the "!empty" statements doesn't behave correctly. My array has values, and it should execute the "IF" statement code. Here is my code below:
>>>
>>>
>>>if !empty(a__generic)
>>>	append from array a__generic   && this should execute, because a__generic has values
>>>endif
>>>
>>>
>>>
>>>the append from array should have executed. Is there a different way I should test to see if the array is filled or empty?
>>>
>>>thanks
>>>Nick
>
>Hi Sergey,
>
>I move a lot of values into my array called a__generic by doing the following:
>
>
>if somethingistrue 
>     a__generic(bb, 1) = a__reqmain(cntr, 1)		&& move mainkey
>endif
>
>
>I want to test to see if the array a__generic got populated values or if the a__generic array is empty meaning no values are in the array. If the array is empty then a__generic(1,1) will have a value type of ".F."
>
>here is what my code is doing:
>
>
>		if empty(a__reqsub) && bring in information from main table, there is no fms done yet
>				zzxm = alen(a__reqmain, 1) 	&& return number of rows in an array
>				for cntr = 1 to zzxm
>						a__generic(cntr, 1) = a__reqmain(cntr, 1)		&& move mainkey
>						a__generic(cntr, 2) = a__reqmain(cntr, 2)		&& move subkey
>						a__generic(cntr, 3) = a__reqmain(cntr, 3)		&& move empty order date
>						a__generic(cntr, 4) = {}						&& move paid date
>						a__generic(cntr, 5) = a__reqmain(cntr, 4)		&& move zero to req #
>						a__generic(cntr, 6) = a__reqmain(cntr, 5)		&& move vendor
>						a__generic(cntr, 7) = a__reqmain(cntr, 6)		&& move description
>						a__generic(cntr, 8) = a__reqmain(cntr, 7)		&& move zero to est amt
>						a__generic(cntr, 9) = a__reqmain(cntr, 8)		&& move paid amt (instead of actual)
>						a__generic(cntr, 10) = a__reqmain(cntr, 9)		&& move po #
>						a__generic(cntr, 11) = 0					    && move fms month
>						if cntr < zzxm									&& check to see if loop is terminating 
>					   		dimension a__generic(alen(a__generic, 1) + 1, alen(a__generic, 2)) &&increase array by 1 row
>					   endif
>
>				endfor
>
>				if !empty(a__generic)
>					append from array a__generic   && ======================= <<< this is I append if not empty array
>				endif
>
>
>I am trying to append the array if it is not empty. The problem is that my array has values and the "if !empty(a__generic)" statement keeps claiming the array "a__generic" is empty.
>
>thanks
>nick
Previous
Reply
Map
View

Click here to load this message in the networking platform