Question How To Get Fill-in Value Through Handle

Ferry Huang

New Member
DEFINE VARIABLE vInt AS INTEGER FORMAT "9,999".
vInt = 1234.
DISPLAY vInt WITH FRAME f.
vInt = 5678.
DEFINE VARIABLE h AS HANDLE.
h = vInt:HANDLE.
MESSAGE vInt:INPUT-VALUE vInt.
MESSAGE h:INPUT-VALUE.

Above code will display on message area as below :
1234 5678
1234

My question is how to get value 5678 through HANDLE h?

Thank you.
 

Osborne

Active Member
Before MESSAGE h:INPUT-VALUE. you need to display vInt again or set the SCREEN-VALUE:

DISPLAY vInt WITH FRAME f.
/* or */
ASSIGN vInt:SCREEN-VALUE = "5678".
 

Ferry Huang

New Member
thanks for your reply Osborne,
but that is not what I want, the point is I want to access SCREEN-VALUE or INPUT-VALUE using HANDLE also want to access the REAL VALUE of a variable using HANDLE.
hope that you understand.
 

Osborne

Active Member
I do not think that accessing the real value of a variable is possible using handle and you have to access the variable itself for that. I think the only solution is to have a temp-table with records for each variable and their real values and access the real value using BUFFER-FIELD and BUFFER-VALUE.
 

RealHeavyDude

Well-Known Member
Variables are not objects. Therefore you can only statically reference them in your code and they do not have attributes you can query - because there are none. You can compare them with the primitive types in other programming languages.

If you want to be able to use attributes you can either use an existing type ( for example a Fill-In which is an object ) or you roll your own object providing the functionality you need.

Probably something like this might do for you:
Code:
  define variable myHandle  as handle  no-undo.
  do with frame {&frame-name}:
  assign myHandle = FILL-IN-1:handle.
  end.
.

Heavy Regards, RealHeavyDude.
 

Ferry Huang

New Member
thanks RealHeavy,

can we compare a HANDLE is a memory address of variables?
just like in C++ we can get the real value of a variable using pointer.
 

RealHeavyDude

Well-Known Member
That's what a handle exactly is: A pointer to the address in memory where an object resides.

Still you need to be aware: Plain variables are not objects - they are primitive types and you can only statically reference them by their name in your code. Whenever you display a variable the AVM automatically creates the widget ( which is an object ) for you. The view-as phrase determines which type of widget is created. Of that widget you might then access the handle attribute either by knowing its name or by doing a widget tree walk on the frame it is located on.

Heavy Regards, RealHeavyDude.
 
Code:
DEFINE VARIABLE vInt AS INTEGER FORMAT "9,999".
vInt = 1234.
DISPLAY vInt WITH FRAME f.

vInt = 5678.
DEFINE VARIABLE h AS HANDLE.
h = vInt:HANDLE.
MESSAGE vInt:INPUT-VALUE vInt.
MESSAGE ENTRY(1,STRING(vInt)).

Try this..I don't know if this will work. :)
 

Ferry Huang

New Member
thanks Carlo, but I need to get the real value not screen-value of variable vInt through handle h.

i think there is a way to access those real value, maybe using pointer or something else ???
 

RealHeavyDude

Well-Known Member
Are you familiar with the concept of screen buffer and record buffer in the ABL?

The concept with variable and widget associated with them is similar. There are statements like display and assign to copy the value from one to the other. Since a variable is not an object you can only reference it manually. Attributes like screen-value are associated with the widget. The display statement copies the value from the variable into the screen-value of the widget. The assign statement copies the value of the screen-value into the variable. Just like with database records and record buffers.

The "real" value of the variable and the screen-value of the widget may differ. Plus, you need to be aware that the screen-value is a character data type. You need to assign the variable ( widget ) in order to make sure that they are equal or you statically reference the variable by it's name.

If you really want to be able to access the variable dynamically you need to roll your own object that wraps ( boxes ) the primitive type.

Heavy Regards, RealHeavyDude.
 

Osborne

Active Member
Something like this would appear to do what you want, but it would mean having temp-table fields instead of variables to accomplish it:
Code:
DEFINE VARIABLE h AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.

DEFINE TEMP-TABLE ttVars NO-UNDO
    FIELD vInt AS INTEGER FORMAT "9,999".

CREATE ttVars.
ttVars.vInt = 1234.
DISPLAY ttVars.vInt WITH FRAME f.
ttVars.vInt = 5678.

h = ttVars.vInt:HANDLE.
hField = BUFFER ttVars:BUFFER-FIELD(h:NAME).

MESSAGE ttVars.vInt:INPUT-VALUE ttVars.vInt.
MESSAGE h:INPUT-VALUE hField:BUFFER-VALUE.
 
Top