Apart from a Dimension array_var[x,y] is there another means that a
variable can be defined as an array?



thanks

pete

Re: Array definition by Stefan

Stefan
Tue Apr 10 02:06:19 CDT 2007


"Peter Huish" <huish@ozemail.com.au> schrieb im Newsbeitrag
news:MPG.2085da53f0ae1b6e9896ac@news.easynews.com...
>
> Apart from a Dimension array_var[x,y] is there another means that a
> variable can be defined as an array?

What do you want to do?
You can for example declare a local array
Local laMyArray[1]
Local Array laMy2ndArray[3,4]

Or spontaneously create an undeclared one
Select * From customers Into Array aUndeclared

Also the native A*() functions, like AClass(), AUsed() etc., will create a
result array...



hth
-Stefan




--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------



Re: Array definition by Zeke

Zeke
Tue Apr 10 03:22:15 CDT 2007


"Peter Huish" <huish@ozemail.com.au> wrote in message
news:MPG.2085da53f0ae1b6e9896ac@news.easynews.com...
>
> Apart from a Dimension array_var[x,y] is there another means that a
> variable can be defined as an array?
>
>
>
> thanks
>
> pete

You can create it with sql:
select * from xxx into array array_var

creates an array on the fly.



Re: Array definition by Anders

Anders
Tue Apr 10 03:52:20 CDT 2007

The command DECLARE can be used instead of DIMENSION.
Array properties are created with
object.AddProperty('xx(5,4)')
But to redimension this array you use DIMENSION object.xx(10,4)
To add a property at design time in a form's menu Form->New Property, you
just enter the property's name as
newpropertyname(5,1)
-Anders

"Peter Huish" <huish@ozemail.com.au> wrote in message
news:MPG.2085da53f0ae1b6e9896ac@news.easynews.com...
>
> Apart from a Dimension array_var[x,y] is there another means that a
> variable can be defined as an array?
>
>
>
> thanks
>
> pete



Re: Array definition by Peter

Peter
Tue Apr 10 16:41:20 CDT 2007

>
> What do you want to do?

I have a line of code:

lcinstruct = Thisform.lcinstruct that is throwing an error Objects
cannot be assigned to arrays (Error 1942) intermittently on seemingly
only Windows XP systems and I am trying to isolate it

As I have mentioned in a previous post, the Thisform.lcinstruct is
initialised as either a memo field read from a table or it is set to ''

I am encountering the Error 1942 in some instances and also in other
instances the Thisform.lcinstruct is becoming empty after previously
having content. It seems that in moving form the form variable to the
local variable and back these error situations are being set up.

The problems are both intermittent and I am yet to produce them in my
development environment. I am using VFP 7



thanks

pete

Re: Array definition by Olaf

Olaf
Wed Apr 11 07:36:01 CDT 2007

> lcinstruct = Thisform.lcinstruct that is throwing an error Objects
> cannot be assigned to arrays (Error 1942) intermittently on seemingly

So it seems, lcinstruct is an array at that time.

if type("lcinstruct",1)="A"
set step on
endif
lcinstruct = Thisform.lcinstruct

Do you declare lcinstruct by
LOCAL lcinstruct?

It may be a variable with private scope
being defined outside of your code.

You may set a conditional breakpoint
with the condition type("lcinstruct",1)="A"
and thereby find out, when that array
is created.

The error is a bit misleading, as you can
store objects in array elements:

DIMENSION la(2)
la(2)=CREATEOBJECT("custom")
? la(2).name

*But what fails is:
la=CREATEOBJECT("custom")

Bye, Olaf.

Re: Array definition by Peter

Peter
Wed Apr 11 14:16:48 CDT 2007


> > lcinstruct = Thisform.lcinstruct that is throwing an error Objects
> > cannot be assigned to arrays (Error 1942) intermittently on seemingly
>
> So it seems, lcinstruct is an array at that time.
>
> if type("lcinstruct",1)="A"
> set step on
> endif
> lcinstruct = Thisform.lcinstruct

The problem is occurring at a customer's site where I don't have access
so I don't believe that I can use the debugger.

> Do you declare lcinstruct by
> LOCAL lcinstruct?

No I don't.

> It may be a variable with private scope
> being defined outside of your code.

I have done a fairly full search of the application and not found
anywhere where the variable is defined so it is a bit of a mystery.


thanks

pete

Re: Array definition by Olaf

Olaf
Thu Apr 12 08:19:45 CDT 2007


>> Do you declare lcinstruct by
>> LOCAL lcinstruct?
>
> No I don't.
then you should do that or at least
reject any variable of that name to
come from outside:

Here's how that could cause your error:

dimension lcinstruct(2)
myproc()

procedure myproc()
*local lcinstruct
lcinstruct = createobject("custom")
endproc

Run that, then uncomment the local
statement and rerun.

It's recommended to declare all your
variables, so your program isn't influenced
from outside world and does not influence the
outside world.

Take a look at the help chapters about
LOCAL, PRIVATE and variable scope
in general.

Bye, Olaf.