Subject Re: Save the datalinks
From Tom <IHaveNoEmail@ddress>
Date Sat, 29 Aug 2020 17:04:20 -0400
Newsgroups dbase.getting-started

Never mind ...

Staring at the code for too ling plus typos will cause that. All fixed now.

Thanks anyway,
Tom

On 8/29/20 2:19 PM, Tom wrote:
> Hi all,
>
> Been fooling with this for a while and cannot get the syntax straight.
> Maybe you can help.
>
> Basic idea:
>
> // Now: save all 4 object datalinks and then remove them so
> // objects are no longer datalinked ...
> form.aLinks = new array()
> form.aLinks.add(form.CDATA.GETRECORDID.dataLink)
> form.aLinks.add(form.CDATA.GETUSERID.dataLink)
> form.aLinks.add(form.CDATA.GETGROUPNAME.dataLink)
> form.aLinks.add(form.CDATA.GETSUBGROUPVALUE.dataLink)
> *
> form.CDATA.GETRECORDID.dataLink = null
> form.CDATA.GETUSERID.dataLink = null
> form.CDATA.GETGROUPNAME.dataLink = null
> form.CDATA.GETSUBGROUPVALUE.dataLink = null
> *
> // Later: return all object datalinks so all objects are again
> datalinked ...
> form.CDATA.GETRECORDID.dataLink = form.aLinks[1]
> form.CDATA.GETUSERID.dataLink = form.aLinks[2]
> form.CDATA.GETGROUPNAME.dataLink = form.aLinks[3]
> form.CDATA.GETSUBGROUPVALUE.dataLink = form.aLinks[4]
> *
> The above works as expected but entails a lot of typing.
> *
> Been trying to use Mervyn's getObject function (see below). Obtaining
> form.objects array works to perfection. However, I cannot generate the
> form.aLinks array as above.
>
> Your help would be appreciated. So will Akshat I would venture to say.
>
> Tom
>
> function getObjects
>        //The routine will start with the object
>        //passed as a parameter. If no parameter
>        //is passed it will start with the form
>        parameters xObject
>        private oRef
>        local oParent
>        if type('form.objects') = "U"
>           form.objects = new array()
>        endif
>        oParent = iif( type( "xObject" ) == "O", xObject, form )
>        oRef = oParent.first
>        do
>           // form and container
>           if type( "oRef.first" ) == "O"
>              class::getObjects( oRef )
>           endif
>           // recurse up the tree and get each parents name
>           if not oRef.baseClassName == "FORM"
>              o = oRef
>              cName = oRef.name
>              do while true
>                 if type("o.Parent")=="U"
>                    exit
>                 endif
>                 try
>                 cName = o.Parent.name + "." + cName
>                 catch(exception e)
>                 endtry
>                 o = o.Parent
>              enddo
>              form.objects.add(oRef)
>           endif
>           // next object
>           if type("oRef.before") # "U"
>              oRef = oRef.before
>           else
>              return
>           endif
>        until oRef == oParent.first
>        return form.objects
>
>
>     function form_onOpen()
>        clear
> form.alinks = new array()
>        ***** Alternative code which can handle containers
>        class::getObjects()
>        for n = 1 to form.objects.size
>      if "GET" $ form.objects[n].name
>      form.alinks.add( ??? ) // how do I obtain the datalink value ???
>      endif
> ***         if form.objects[n].classname = 'PUSHBUTTON'
> ***            form.objects[n].onClick := class::Pushbutton_onClick
> ***         endif
>        next
>        return
>