Hi All,

Is it possible in vfp to declare an public array (so that the array is visible anywhere in the application) and then define its dimensions at a later stage (when I know what the size of the array is going to be)?

Something like redim in visual basic...

Regards.

Re: Defining the dimensions of an array by Eric

Eric
Sat Jun 26 05:53:13 CDT 2004

Hello, sm!
You wrote on Sat, 26 Jun 2004 00:30:01 -0700:

s> Is it possible in vfp to declare an public array (so that the array is
s> visible anywhere in the application) and then define its dimensions at a
s> later stage (when I know what the size of the array is going to be)?

s> Something like redim in visual basic...

Yes, simply issue the PUBLIC ARRAY again.

Try this:
<vfp_code>
* declare first time
PUBLIC ARRAY myArray[1]
myArray[1] = "Hello"
?ALEN(myArray) && 1
* declare second time
PUBLIC ARRAY myArray[2]
myArray[2] = "World"
?ALEN(myArray) && 2
?myArray[1] + " " + myArray[2]
</vfp_code>
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Re: Defining the dimensions of an array by sm

sm
Sat Jun 26 06:13:01 CDT 2004

Thanks

"Eric den Doop" wrote:

> Hello, sm!
> You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
>
> s> Is it possible in vfp to declare an public array (so that the array is
> s> visible anywhere in the application) and then define its dimensions at a
> s> later stage (when I know what the size of the array is going to be)?
>
> s> Something like redim in visual basic...
>
> Yes, simply issue the PUBLIC ARRAY again.
>
> Try this:
> <vfp_code>
> * declare first time
> PUBLIC ARRAY myArray[1]
> myArray[1] = "Hello"
> ?ALEN(myArray) && 1
> * declare second time
> PUBLIC ARRAY myArray[2]
> myArray[2] = "World"
> ?ALEN(myArray) && 2
> ?myArray[1] + " " + myArray[2]
> </vfp_code>
> --
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
>
>
>

Re: Defining the dimensions of an array by Rush

Rush
Sat Jun 26 09:16:56 CDT 2004

You needn't declare it a second time; I think DIMENSION is the command that
he's looking for.

- Rush

"Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
news:uaZbJv2WEHA.2840@TK2MSFTNGP11.phx.gbl...
> Hello, sm!
> You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
>
> s> Is it possible in vfp to declare an public array (so that the array is
> s> visible anywhere in the application) and then define its dimensions at
a
> s> later stage (when I know what the size of the array is going to be)?
>
> s> Something like redim in visual basic...
>
> Yes, simply issue the PUBLIC ARRAY again.
>
> Try this:
> <vfp_code>
> * declare first time
> PUBLIC ARRAY myArray[1]
> myArray[1] = "Hello"
> ?ALEN(myArray) && 1
> * declare second time
> PUBLIC ARRAY myArray[2]
> myArray[2] = "World"
> ?ALEN(myArray) && 2
> ?myArray[1] + " " + myArray[2]
> </vfp_code>
> --
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
>
>



Re: Defining the dimensions of an array by Lie

Lie
Tue Sep 20 21:42:02 CDT 2005

if we declare array with DIMENSION command, is it a public variable? so we
need not to declare 'PUBLIC DIMENSION myarr[10]' , enough with 'DIMENSION
myarr[10]'?
i am totally new in vfp. trying to convert vfp 3.0 to vfp 5.0, and after
making few lines code changes, it's successfully converted to vfp 5.0.
now trying to convert vfp 5.0 to vfp 7.0/9.0, but have error in declaring
public dimension variables, prompt it's unknown variable.

Thanks




"Rush Strong" wrote:

> You needn't declare it a second time; I think DIMENSION is the command that
> he's looking for.
>
> - Rush
>
> "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
> news:uaZbJv2WEHA.2840@TK2MSFTNGP11.phx.gbl...
> > Hello, sm!
> > You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
> >
> > s> Is it possible in vfp to declare an public array (so that the array is
> > s> visible anywhere in the application) and then define its dimensions at
> a
> > s> later stage (when I know what the size of the array is going to be)?
> >
> > s> Something like redim in visual basic...
> >
> > Yes, simply issue the PUBLIC ARRAY again.
> >
> > Try this:
> > <vfp_code>
> > * declare first time
> > PUBLIC ARRAY myArray[1]
> > myArray[1] = "Hello"
> > ?ALEN(myArray) && 1
> > * declare second time
> > PUBLIC ARRAY myArray[2]
> > myArray[2] = "World"
> > ?ALEN(myArray) && 2
> > ?myArray[1] + " " + myArray[2]
> > </vfp_code>
> > --
> > Eric den Doop
> > www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
> >
> >
>
>
>

Re: Defining the dimensions of an array by Fred

Fred
Tue Sep 20 22:20:25 CDT 2005

You don't need dimension at all if you do PUBLIC myarray[10].

DIMENSION is just a keyword that allows you to redimension an existing array
or create a new one in the default scope, which is usually PRIVATE.

--
Fred
Microsoft Visual FoxPro MVP


"Lie" <Lie@discussions.microsoft.com> wrote in message
news:C937F1C0-47DD-4064-BCB1-ED00B6F2C25A@microsoft.com...
> if we declare array with DIMENSION command, is it a public variable? so we
> need not to declare 'PUBLIC DIMENSION myarr[10]' , enough with 'DIMENSION
> myarr[10]'?
> i am totally new in vfp. trying to convert vfp 3.0 to vfp 5.0, and after
> making few lines code changes, it's successfully converted to vfp 5.0.
> now trying to convert vfp 5.0 to vfp 7.0/9.0, but have error in declaring
> public dimension variables, prompt it's unknown variable.
>
> Thanks
>
>
>
>
> "Rush Strong" wrote:
>
>> You needn't declare it a second time; I think DIMENSION is the command
>> that
>> he's looking for.
>>
>> - Rush
>>
>> "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
>> news:uaZbJv2WEHA.2840@TK2MSFTNGP11.phx.gbl...
>> > Hello, sm!
>> > You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
>> >
>> > s> Is it possible in vfp to declare an public array (so that the array
>> > is
>> > s> visible anywhere in the application) and then define its dimensions
>> > at
>> a
>> > s> later stage (when I know what the size of the array is going to
>> > be)?
>> >
>> > s> Something like redim in visual basic...
>> >
>> > Yes, simply issue the PUBLIC ARRAY again.
>> >
>> > Try this:
>> > <vfp_code>
>> > * declare first time
>> > PUBLIC ARRAY myArray[1]
>> > myArray[1] = "Hello"
>> > ?ALEN(myArray) && 1
>> > * declare second time
>> > PUBLIC ARRAY myArray[2]
>> > myArray[2] = "World"
>> > ?ALEN(myArray) && 2
>> > ?myArray[1] + " " + myArray[2]
>> > </vfp_code>
>> > --
>> > Eric den Doop
>> > www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
>> > VFP8
>> >
>> >
>>
>>
>>



Re: Defining the dimensions of an array by Lie

Lie
Wed Sep 21 01:52:01 CDT 2005

Thanks, have changed it and no error in compilation.

another problem is variable declaration:
in vfp 5.0, declaration below has no problem:
PUBLIC row N(3)

but in vfp 7.0, always prompt syntax error.
is it possible not to change it? any other setting/tool to do conversion and
compilation successfully?

Thanks

"Fred Taylor" wrote:

> You don't need dimension at all if you do PUBLIC myarray[10].
>
> DIMENSION is just a keyword that allows you to redimension an existing array
> or create a new one in the default scope, which is usually PRIVATE.
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>
> "Lie" <Lie@discussions.microsoft.com> wrote in message
> news:C937F1C0-47DD-4064-BCB1-ED00B6F2C25A@microsoft.com...
> > if we declare array with DIMENSION command, is it a public variable? so we
> > need not to declare 'PUBLIC DIMENSION myarr[10]' , enough with 'DIMENSION
> > myarr[10]'?
> > i am totally new in vfp. trying to convert vfp 3.0 to vfp 5.0, and after
> > making few lines code changes, it's successfully converted to vfp 5.0.
> > now trying to convert vfp 5.0 to vfp 7.0/9.0, but have error in declaring
> > public dimension variables, prompt it's unknown variable.
> >
> > Thanks
> >
> >
> >
> >
> > "Rush Strong" wrote:
> >
> >> You needn't declare it a second time; I think DIMENSION is the command
> >> that
> >> he's looking for.
> >>
> >> - Rush
> >>
> >> "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
> >> news:uaZbJv2WEHA.2840@TK2MSFTNGP11.phx.gbl...
> >> > Hello, sm!
> >> > You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
> >> >
> >> > s> Is it possible in vfp to declare an public array (so that the array
> >> > is
> >> > s> visible anywhere in the application) and then define its dimensions
> >> > at
> >> a
> >> > s> later stage (when I know what the size of the array is going to
> >> > be)?
> >> >
> >> > s> Something like redim in visual basic...
> >> >
> >> > Yes, simply issue the PUBLIC ARRAY again.
> >> >
> >> > Try this:
> >> > <vfp_code>
> >> > * declare first time
> >> > PUBLIC ARRAY myArray[1]
> >> > myArray[1] = "Hello"
> >> > ?ALEN(myArray) && 1
> >> > * declare second time
> >> > PUBLIC ARRAY myArray[2]
> >> > myArray[2] = "World"
> >> > ?ALEN(myArray) && 2
> >> > ?myArray[1] + " " + myArray[2]
> >> > </vfp_code>
> >> > --
> >> > Eric den Doop
> >> > www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
> >> > VFP8
> >> >
> >> >
> >>
> >>
> >>
>
>
>

Re: Defining the dimensions of an array by Bernhard

Bernhard
Wed Sep 21 05:06:04 CDT 2005

Hi Lie schrieb:

> another problem is variable declaration:
> in vfp 5.0, declaration below has no problem:
> PUBLIC row N(3)
>
> but in vfp 7.0, always prompt syntax error.

In earlier versions this line defined 2 variables: one called "row" and an array
called "n" with 3 elements. Foxpro silently added the missing comma.
In newer versions Foxpro complains about the missing comma. You must correct
this in your sources like that:
PUBLIC row, n(3)

But maybe you wanted ROW to be of type N(3). This kind of type definition is
only used when creating tables. Variables in Foxpro are not explicitly typed.
In newest versions of Foxpro there is a way to announce a type for the variable:
PUBLIC row AS n(3)
But also then, the variable accepts values of all types.
This typing is "only" useful to support intellisense and sometimes necessary for
com objects.

Regards
Bernhard Sander

Re: Defining the dimensions of an array by Fred

Fred
Wed Sep 21 10:33:06 CDT 2005

Are you tring to define two variables, (row and an array named N with 3
elements)? You can't specify a variable type in VFP like that if what
you're trying to do is get a numeric type variable that's 3 wide, that only
applies to fields in a table.

If it's supposed to be 2 variables, you need a comma separating them:

PUBLIC row, n(3)

You really shouldn't make such extensive use of PUBLIC type variable in
Visual FoxPro, it's a very bad habit that can lead to debugging problems.
Use properties of _SCREEN if absolutely necessary to have a global scope or
just properties of the form that requires these values.

--
Fred
Microsoft Visual FoxPro MVP


"Lie" <Lie@discussions.microsoft.com> wrote in message
news:A647D961-32C8-48B2-BF97-DBFBF6903278@microsoft.com...
> Thanks, have changed it and no error in compilation.
>
> another problem is variable declaration:
> in vfp 5.0, declaration below has no problem:
> PUBLIC row N(3)
>
> but in vfp 7.0, always prompt syntax error.
> is it possible not to change it? any other setting/tool to do conversion
> and
> compilation successfully?
>
> Thanks
>
> "Fred Taylor" wrote:
>
>> You don't need dimension at all if you do PUBLIC myarray[10].
>>
>> DIMENSION is just a keyword that allows you to redimension an existing
>> array
>> or create a new one in the default scope, which is usually PRIVATE.
>>
>> --
>> Fred
>> Microsoft Visual FoxPro MVP
>>
>>
>> "Lie" <Lie@discussions.microsoft.com> wrote in message
>> news:C937F1C0-47DD-4064-BCB1-ED00B6F2C25A@microsoft.com...
>> > if we declare array with DIMENSION command, is it a public variable? so
>> > we
>> > need not to declare 'PUBLIC DIMENSION myarr[10]' , enough with
>> > 'DIMENSION
>> > myarr[10]'?
>> > i am totally new in vfp. trying to convert vfp 3.0 to vfp 5.0, and
>> > after
>> > making few lines code changes, it's successfully converted to vfp 5.0.
>> > now trying to convert vfp 5.0 to vfp 7.0/9.0, but have error in
>> > declaring
>> > public dimension variables, prompt it's unknown variable.
>> >
>> > Thanks
>> >
>> >
>> >
>> >
>> > "Rush Strong" wrote:
>> >
>> >> You needn't declare it a second time; I think DIMENSION is the command
>> >> that
>> >> he's looking for.
>> >>
>> >> - Rush
>> >>
>> >> "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
>> >> news:uaZbJv2WEHA.2840@TK2MSFTNGP11.phx.gbl...
>> >> > Hello, sm!
>> >> > You wrote on Sat, 26 Jun 2004 00:30:01 -0700:
>> >> >
>> >> > s> Is it possible in vfp to declare an public array (so that the
>> >> > array
>> >> > is
>> >> > s> visible anywhere in the application) and then define its
>> >> > dimensions
>> >> > at
>> >> a
>> >> > s> later stage (when I know what the size of the array is going to
>> >> > be)?
>> >> >
>> >> > s> Something like redim in visual basic...
>> >> >
>> >> > Yes, simply issue the PUBLIC ARRAY again.
>> >> >
>> >> > Try this:
>> >> > <vfp_code>
>> >> > * declare first time
>> >> > PUBLIC ARRAY myArray[1]
>> >> > myArray[1] = "Hello"
>> >> > ?ALEN(myArray) && 1
>> >> > * declare second time
>> >> > PUBLIC ARRAY myArray[2]
>> >> > myArray[2] = "World"
>> >> > ?ALEN(myArray) && 2
>> >> > ?myArray[1] + " " + myArray[2]
>> >> > </vfp_code>
>> >> > --
>> >> > Eric den Doop
>> >> > www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By
>> >> > VFP8
>> >> >
>> >> >
>> >>
>> >>
>> >>
>>
>>
>>