Re: Declaring Custom Types as Variables in FoxPro by Dan
Dan
Mon Jan 22 13:24:38 CST 2007
Xbase scoping rules have changed only trivially in the last 20 years.
PUBLIC variables are available for the life of the application.
PRIVATE variables are available in the procedure that creates them, and all
called procedures.
LOCAL variables are available only in the procedure that creates them.
Object references are stored in memory variables that follow the scoping
rules, above.
Dan
"Michiel Baird" <michielbaird@gmail.com> wrote in message
news:1169493560.842969.217700@m58g2000cwm.googlegroups.com...
> Thanks But how do i know if something is in scope ??
>
>
>
> Anders Altberg wrote:
>> VFP does not enforce strict typing. A variable takes it's type from
>> whatever
>> value you assign to it.
>> If you create a variable which references an object you have an object
>> variable.
>> oExcel = CreateObject('Excel.Application')
>>
>> As long as oExcel is in scope, it lets you access any part of the Excel
>> object hierarchy.
>>
>> -Anders
>>
>> "Michiel Baird" <michielbaird@gmail.com> skrev i meddelandet
>> news:1169469943.930670.165560@m58g2000cwm.googlegroups.com...
>> > No you are bright! What i mean is this within VB or Delphi I do not
>> > need to ReDefine the type simply because I allready defined it within
>> > the ocx. I can just define the VARIABLE by pointing to the ocx.>
>> > Dim Statement as OCXPROJECTNAME.Createdtype
>> >
>> > So even if VFP does not support types cant u still create the variable
>> > out of the ocx within VFP???
>> > Sorry bout the santex mistakes in my last message!!
>> >
>> >
>> >
>> > Dan Freeman wrote:
>> >> I must not be too bright either because I have NO idea what you just
>> >> said,
>> >> and no idea what you're after any more. <s>
>> >>
>> >> Dan
>> >>
>> >> "Michiel Baird" <michielbaird@gmail.com> wrote in message
>> >> news:1169411410.715369.46040@11g2000cwr.googlegroups.com...
>> >> > The reason I need to do this is because the foxPro Programmer who
>> >> > is
>> >> > using the ocx is not very bright implementing single structures
>> >> > variables will not work simply because he doesnt know how and he
>> >> > doesnt
>> >> > understand data at all. Is it then at all posible to define a
>> >> > variable
>> >> > out of a class within an OCX or DLL if it really becomes nessasary
>> >> > witch contains the variable type which would then have allready been
>> >> > created? For example I can import libraries into delphi and simply
>> >> > define the variable refrencing to the library! But thanks for all
>> >> > the
>> >> > help so far I have a backup idea if this doesnt work. to define
>> >> > MultiProperty Objects for the guy and writing the functions to split
>> >> > all the single parameters into these objects which he can then use.
>> >> >
>> >> >
>> >> >
>> >> > Dan Freeman wrote:
>> >> >> As I said before, VFP does not support VB's TYPEDEF. That is a
>> >> >> construct
>> >> >> that is very unique to VB.
>> >> >>
>> >> >> A VB program that only accepts a VB type definition as a parameter
>> >> >> has
>> >> >> intentionally limited itself to only being callable by other VB
>> >> >> programs.
>> >> >> We
>> >> >> see this all the time with OCX controls that are created primarily
>> >> >> for
>> >> >> use
>> >> >> in VB. They just don't work in other programming languages because
>> >> >> they
>> >> >> use
>> >> >> language constructs (like TYPEDEF) that are not supported outside
>> >> >> of
>> >> >> VB.
>> >> >> And
>> >> >> the authors HATE us for pointing out their oversight. LOL
>> >> >>
>> >> >> There are actually a ton of VB "wrapper" controls written to
>> >> >> encapsulate
>> >> >> the
>> >> >> ill-behaving controls and translate from what VFP can send to what
>> >> >> VB
>> >> >> expects.
>> >> >>
>> >> >> Since you created the OCX, you can fix that. Accept an untyped
>> >> >> object
>> >> >> as
>> >> >> a
>> >> >> parameter instead, and read properties out of that passed object.
>> >> >> You'll
>> >> >> be
>> >> >> passing a single parameter so that limit goes right off the table.
>> >> >>
>> >> >> Having said that, visit www.universalthread.com and do a library
>> >> >> search
>> >> >> for
>> >> >> struct.vcx, which will let you create a more traditional STRUCT.
>> >> >> That
>> >> >> *might* work here, but if it does I suspect it will be little more
>> >> >> than a
>> >> >> happy accident. <g>
>> >> >>
>> >> >> Dan
>> >> >>
>> >> >> "Michiel Baird" <michielbaird@gmail.com> wrote in message
>> >> >> news:1169401404.665728.247090@m58g2000cwm.googlegroups.com...
>> >> >> > The Problem really is that i need to use the type as a fixed
>> >> >> > parameter
>> >> >> > within a function call of an ocx because i have trouble
>> >> >> > with the 24 parameter limit. Will it recognise the object as the
>> >> >> > Type
>> >> >> > I defined within the OCX.
>> >> >> >
>> >> >> >
>> >> >> > Dan Freeman wrote:
>> >> >> >> Foxpro does not support types, but all they really are is an
>> >> >> >> object
>> >> >> >> with
>> >> >> >> a
>> >> >> >> bunch of properties declared.
>> >> >> >>
>> >> >> >> If you need to pass it as a parameter, create an object and add
>> >> >> >> a
>> >> >> >> bunch
>> >> >> >> of
>> >> >> >> parameters to it. Pass that object around, and anywhere you need
>> >> >> >> to
>> >> >> >> set
>> >> >> >> or
>> >> >> >> read the properties you'll use exactly the same syntax you'd use
>> >> >> >> in
>> >> >> >> VB.
>> >> >> >>
>> >> >> >> oParameter = Createobject("custom")
>> >> >> >> With oParameter
>> >> >> >> .Addproperty("Param1")
>> >> >> >> .Addproperty("Param2")
>> >> >> >> Endwith
>> >> >> >>
>> >> >> >> Do YourFunction WITH oParameter
>> >> >> >>
>> >> >> >> Dan
>> >> >> >>
>> >> >> >>
>> >> >> >> "Michiel Baird" <michielbaird@gmail.com> wrote in message
>> >> >> >> news:1169387073.222819.242230@v45g2000cwv.googlegroups.com...
>> >> >> >> >I used VB6 to Create an OCX within this ocx I Created a Custom
>> >> >> >> >Type:
>> >> >> >> >
>> >> >> >> > Public Type TRdrOptions
>> >> >> >> > Option1 As Boolean
>> >> >> >> > Option2 As Boolean
>> >> >> >> > Option3 As Boolean
>> >> >> >> > Option4 As Boolean
>> >> >> >> > Option5 As Boolean
>> >> >> >> > Option6 As Boolean
>> >> >> >> > Option7 As Boolean
>> >> >> >> > Option8 As Boolean
>> >> >> >> > End Type
>> >> >> >> >
>> >> >> >> > In the vb test application i can easily declare a varible to
>> >> >> >> > that
>> >> >> >> > type:
>> >> >> >> >
>> >> >> >> > Dim Options As C100_OCX.TRdrOptions
>> >> >> >> >
>> >> >> >> > This is now a recognised variable!!!
>> >> >> >> >
>> >> >> >> > I am not a foxPro Programmer but that is what the Application
>> >> >> >> > will
>> >> >> >> > be
>> >> >> >> > written in:
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > How do u define a varible to a type within the OCX in foxPro
>> >> >> >> > as i
>> >> >> >> > Have
>> >> >> >> > done in the VB Example Above:
>> >> >> >> > I Need to use the because of the 24 Parameter Restriction in
>> >> >> >> > foxPro
>> >> >> >> >
>> >> >> >
>> >> >
>> >
>