Question Display Stmt Requires A Frame

davidvilla

Member
Hi,
I am trying to use a display statement for a fill-in variable attribute.
Code:
define variable mychar as char no-undo.
disp mychar:name mychar:type
But this gives me error - Could not find mychar in a frame. Try qualifying the reference with an IN FRAME phrase. (3566).
So, i used a frame and it worked. But why does this behave like this?

Code:
define variable mychar as char no-undo.
disp mychar
This works without a frame.

What is the reason that 'disp mychar' and 'disp mychar:name' behave differently?
 

RealHeavyDude

Well-Known Member
For one: Variables are not objects - you can compare them with the primitive types in other languages like Java. Therefore they don't have attributes and therefore you get a compiler error when you try to access attributes like name and type. These attributes are associated with a widget - which is an user interface object that might be linked to a variable.

Secondly: In a Progress ABL session any display requires a frame. Even if you don't explicitly code it, the compiler will automatically generate a default one for you with default characteristics. By doing so, the widgets will also be created for you automatically and then you may access these widgets and work with their attributes. Variables are always referenced in the code solely with the name that you defined in the define statement. Widgets can either be referenced via their name ( which will be the same when created automatically by the compiler ) or a accessed via their handle ( pointer to the object in memory ). IMHO, there is a common misunderstanding that variables are widgets. They are not.

As much as I love the ABL it hides so many things from the developer. There is a lot of stuff the compiler and the AVM take care of "in the background" for the developer that "magically" works in most cases. But, in some cases - like the examples you describe - it does help quite a bit when you understand how things work.

Heavy Regards, RealHeavyDude.
 
Top