Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Mike Yearwood
  Where is Mike Yearwood?
 Toronto
 Canada
 Mike Yearwood
 To: Tony Vignone
  Where is Tony Vignone?
 St Augustine
 Florida - United States
 Tony Vignone
 Tags
Subject: RE: Passing arrays to procedures
Thread ID: 268401 Message ID: 268615 # Views: 33 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Tuesday, July 13, 2010 3:39:32 PM         
   


> >
> >
> >
> > It's a great programming language, however there are ways to do stuff and then there are others, some are better then others but as in any other programming language (it's about programming in general not about language) some ingenuity is required.
> >
> > So please, son't insult before more programmers confirm you a certain lankness in vfp's capabilities.
> >
> > The previous posters have shown you ways to accomplish your desired result on your ambiguous description of the problem. (You need a method or a standalone function / procedure ?!)
> >
> > Here's an example of a function that accepts either a variable array or a form's property and objref to that form
> >
> >
> > *-- the function 
> > Function MyArrayHandler( tArrayOrPropery, toForm)
> > 
> > 	*-- test if a variable array was recieved
> > 	If Type("tArrayOrPropery",1)="A" Then
> > 
> > 		External Array tArrayOrPropery	&& prevents compilation errors
> > 
> > 		*-- do your stuff with array sent by reference
> > 		Wait Window "array variable rows :: "+Transform(Alen(tArrayOrPropery,1))
> > 
> > 	Else
> > 
> > 		*-- test if function recieved a property name and a referece to the form
> > 		If Vartype(m.toForm)="O" And Vartype(tArrayOrPropery)="C"  And Pemstatus(m.toForm,tArrayOrPropery,5) Then
> > 
> > 			lcAHandler = "toForm."+tArrayOrPropery
> > 			
> > 			*-- either us &lcAHandler or Acopy to a local array and use that
> > 			*Local Array laTest[1]
> > 			*Acopy(&lcAHandler,laTest)
> > 
> > 			Wait Window "array property rows :: " + Transform(Alen(&lcAHandler))
> > 
> > 		Else
> > 
> > 			Wait Window "no array and (no objoct or no propery)"
> > 
> > 		Endif
> > 
> > 
> > 	Endif
> > 
> > 
> > Endfunc
> > 
> > 
> > *-- usage
> > *-- pass variable array by reference
> > MyArrayHandler(@laLocal)
> > *-- pass form propery and obj ref to form
> > MyArrayHandler("aTest",thisform)
> > 

>
> Thank you for your well informed reply. What I meant by poor language is that you cannot pass arrays is some circumstances. One should be able to always pass an array in a well formed language! Yes, you can always get around it (which I was having difficulty doing). But this language requires one to remember more tricks to get around simple things that seems to be necessary. If I could have simply passed an array like in all other languages I have used, I would not have to remember or think up tricks or ask you very knowledgeable people how to get around it.
>
> There is another problem I run into often and that's how to tell if an array is empty. Since the lowest subscript is 1 and not 0 this is ambiguous
>
>
dimen myarray(1)
> myarray(1) = 0
> ?empty(myarray)    && true  (This is not correct since I just filled the array with 0!!)
> 

>
> Tony

http://fox.wikis.com/wc.dll?Wiki~X2ISARRAY~VFP

Mike Yearwood
Microsoft MVP Visual FoxPro 2008, 2009
We have enough youth. We need a fountain of smart!
There may be many ways to skin a cat, but there are very few right ways to do it.

ENTIRE THREAD

Passing arrays to procedures Posted by Tony Vignone @ 7/11/2010 6:46:56 PM
RE: Passing arrays to procedures Posted by Samir H. @ 7/11/2010 7:15:34 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/12/2010 6:52:53 PM
RE: Passing arrays to procedures Posted by Borislav Borissov @ 7/11/2010 7:19:17 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/12/2010 6:51:23 PM
RE: Passing arrays to procedures Posted by Mike Yearwood @ 7/13/2010 3:38:03 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/14/2010 6:39:43 PM
RE: Passing arrays to procedures Posted by Anil Sharma @ 7/11/2010 7:31:36 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/12/2010 6:55:23 PM
RE: Passing arrays to procedures Posted by Eduard @ 7/11/2010 10:34:31 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/12/2010 7:02:24 PM
RE: Passing arrays to procedures Posted by Samir H. @ 7/12/2010 7:28:19 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/13/2010 3:08:33 AM
RE: Passing arrays to procedures Posted by Samir H. @ 7/13/2010 3:48:58 AM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/13/2010 4:33:38 AM
RE: Passing arrays to procedures Posted by Tamar Granor @ 7/12/2010 10:48:02 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/13/2010 3:07:39 AM
RE: Passing arrays to procedures Posted by Koen Piller @ 7/12/2010 11:37:18 PM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/13/2010 3:02:01 AM
RE: Passing arrays to procedures Posted by Koen Piller @ 7/13/2010 4:07:34 PM
RE: Passing arrays to procedures Posted by Samir H. @ 7/13/2010 5:56:25 PM
RE: Passing arrays to procedures Posted by Koen Piller @ 7/13/2010 8:43:23 PM
RE: Passing arrays to procedures Posted by Mike Yearwood @ 7/13/2010 10:36:16 PM
RE: Passing arrays to procedures Posted by Samir H. @ 7/14/2010 4:42:58 AM
RE: Passing arrays to procedures Posted by Mike Yearwood @ 7/14/2010 5:57:12 AM
RE: Passing arrays to procedures Posted by Samir H. @ 7/14/2010 7:22:33 AM
RE: Passing arrays to procedures Posted by Mike Yearwood @ 7/14/2010 7:13:43 PM
RE: Passing arrays to procedures Posted by Koen Piller @ 7/14/2010 10:21:59 AM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/14/2010 6:59:18 PM
RE: Passing arrays to procedures Posted by tushar @ 7/13/2010 6:02:24 AM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/14/2010 7:00:41 PM
RE: Passing arrays to procedures Posted by Mike Yearwood @ 7/13/2010 3:39:32 PM
RE: Passing arrays to procedures Posted by Christian Tabligan @ 7/14/2010 4:46:09 AM
RE: Passing arrays to procedures Posted by Samir H. @ 7/14/2010 4:54:22 AM
RE: Passing arrays to procedures Posted by Christian Tabligan @ 7/14/2010 5:48:51 AM
RE: Passing arrays to procedures Posted by Tony Vignone @ 7/15/2010 3:06:02 AM