quite simple actually, just get a pointer to the actual form element
in the object method just call:
OBJECT GET POINTER (object current)
you can even go one further und just put all that into the form method:
If (Form event code=On Data Change)
$p_entry:=OBJECT Get pointer(Object with focus)
If ((Type($p_entry)=Is text) | (Type($p_entry)=Is alpha field))
$p_entry->:=Trim($p_entry->)
End if
End if
careful here, you will need to switch to OBJECT GET POINTER(Object with focus)
as you are not in the objects method anymore...
HTH
Alex
> Am 29.04.2020 um 07:55 schrieb Chris Belanger via 4D_Tech
> <[email protected]>:
>
> Generic programming of vars on a form is very complicated when one uses
> object attributes for the data source.
>
> For example, on screen you make a simple text input object named “enCompany”.
> It’s data source is Form.en_Company.Name ( i.e. [Company]Name )
>
> In ‘classic 4d”, where the data source would be [Company]Name, one can code
> its script:
> TRIM ( Self )
>
> And TRIM would simply take a POINTER, and you can perform operations on the
> data that the user typed into that field. (Such as trim off leading &
> trailing spaces).
>
> But with OBJECT NOTATION, that is all screwed up.
> You cannot get a PTR to, for instance, an object named ‘enCompany’ whose data
> source is Form.en_Company.Name
> So the script for it cannot be generic.
> It would seem to make sense to be able to do something like:
>
> TRIM ( Form Event.objectName ) — and have some way to actually do anything
> with what the user typed into this element on-screen.
>
> You can’t use TRIM ( Self ) because Self is nil
>
> And v18r3 does not even have a solution to this in its documentation.
>
> It seems we should have some way of getting the user-input data of a screen
> element even if we are using object notation.
>
> We would expect, at the least, something like OBJECT Get Value ( ObjectName
> ) and OBJECT Set Value ( Object Name ) but no!
>
> Any input? Wait for version 20 of 4D?
>
> - Chris
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************