[Gambas-user] method $load , any wiki for explain it ?

Tobias Boege taboege at ...626...
Sun Jun 5 23:10:17 CEST 2016


On Mon, 06 Jun 2016, zainudin ahmad wrote:
> > Is this what you are looking for?
> 
> No
> 
> doing : $ gbc3 -v /tmp/test
> 
> the project contain Main form (without any code). I get the result :
> 
> ------------------------------------------------------------------------
> Compiling Main.class...
> Inherits Form
> 
> 
> Private Sub {$load}()       << (what I mean)
> 
>   With Me
>     .MoveScaled(0,0,64,64)
>   End With
> 
> End
> 
> Adding class Form Unused Exported
> 
> Switching class Form to Used
> CLASS Main
> CLASS INHERITS Form
> 
> Static size : 0 octets
> Dynamic size : 0 octets
> 
> Private Procedure $load()
> 
> Compiling @init()...
> 
> 0000 :  1000            RETURN (0)
> 
> Compiling @new()...
> 
> 0000 :  B802            PUSH FUNCTION $load
> 0001 :  1C00            CALL (0)
> 0002 :  1A01            DROP (1)
> 0003 :  1000            RETURN (0)
> 
> Compiling $load()...
> 
> 0000 :  1500            PUSH ME
> 0001 :  0E00            POP CTRL 0
> 0002 :  0100            PUSH LOCAL 0
> 0003 :  0400 0000       PUSH UNKNOWN MoveScaled
> 0005 :  F000            PUSH QUICK 0
> 0006 :  F000            PUSH QUICK 0
> 0007 :  F040            PUSH QUICK 64
> 0008 :  F040            PUSH QUICK 64
> 0009 :  1C04            CALL (4)
> 0010 :  1A01            DROP (1)
> 0011 :  1002            RETURN (2)
> 
> 0 local(s) 1 control(s) 6 stack
> 
> OK
> 

This is a (very) hidden method added by the compiler when it processes
Form files. As you can see, it is automatically called first thing in the
constructor and is responsible for creating and initialising all the
controls inside the form and setting the form's properties. It basically
applies all the things you did in the IDE's graphical form editor.

I doubt it is documented anywhere, but the function name is hardcoded into
the compiler. I also don't know off the top of my head if there are other
hidden functions like this. In any case, you should be fine if you follow
a sensible naming scheme :^)

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list