Dynamically get/set any attribute of any widget

badidi

New Member
Hi,

Is it possible to get an attribute of a widget like this:

Code:
MESSAGE DYNAMIC-GET-ATTRIBUTE(Fill-IN-1:HANDLE, "SCREEN-VALUE").
In other words, I have a handle and a character variable that includes an attribute's name.

Code:
DEF VAR hObj AS HANDLE.
DEF VAR sAttr AS CHAR.

hObj = FILL-IN-1:HANDLE.
sAttr = "SCREEN-VALUE". /* I can get this from user input for examle.*/
MESSAGE DYNAMIC-GET-ATTRIBUTE(hObj, sAttr). /* Is this possible? Is there a way to do this? */
Thank you,
Baris.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
yes. the call object lets you do the following dynamically -

invoke internal, external proc, or function with diff parameters

get/set attributes

invoke methods


you can find references in the -

4gl reference doc, handles reference chapter

it's also briefly mentioned in the programming handbook, using dynamic browses chapter. hth
 

badidi

New Member
joey.jeremiah said:
yes. the call object lets you do the following dynamically

Can you explain it, give an example please? I couldn't find it on help. There is a statement, "CALL", but it is for call C functions.

Notice: I use Progress V9.1C.

Thanks,
Baris
 
GUI Progress / Progress OpenEdge

This is example syntax for assigning properties/attributes to Widgets.
/* set */
DO WITH FRAME {&FRAME-NAME}
handle:Attribute / handle:property = VALUE . /* dependent upon attribute setting eg YES/NO, 'CharValue', INTEGER */
END. /* frame */

/* get - reverse */
DO WITH FRAME {&FRAME-NAME}
charVar = handle:Attribute / handle:property
END. /* frame */
 

badidi

New Member
mpowell_esq said:
/* set */
DO WITH FRAME {&FRAME-NAME}
handle:Attribute / handle:property = VALUE . /* dependent upon attribute setting eg YES/NO, 'CharValue', INTEGER */
END. /* frame */
Sorry but you could not understand me. I am not beginner. My question is about getting/setting attributes dynamically. See the example in my question again please.
 

Serj HAMMER

Junior Racer
Dynamic "handle" or dynamic "attribute"?

Hallo, badidi.
Are You mean "dynamic" about widget-handle value or about attribute name? In other words, do You want dynamicaly get widgets or You want dynamicaly get attributes from one widget:

do i = 1 to 3: hdl:screen-value = "0123". end.

OR

do i = 1 to 3: hdl:attr = val. end.

where attr = ["screen-value", "name", "private-data"]
?
 

joey.jeremiah

ProgressTalk Moderator
Staff member
bad luck, i've looked it up in the product update bulletin doc, it's listed under 9.1d enhancements.

and btw, so can you. you can download the docs @psdn.com, and there are plenty of examples about, well, everything.

here's another option, though, it's not as elegant.

<snippet>

function dynGetAttr returns char ( phObj as handle, pcAttr as char ):

case pcAttr:

when "screen-value" then return phObj:screen-value.
when "format" then return phObj:format.
when "width" then return string( phObj:width ).

end case. /* pcAttr */

end function. /* getAttr */



define var x as char no-undo.

x = "Hello World".

display x format "x(12)" with frame a.

message
dynGetAttr( x:handle, "screen-value" ) skip
dynGetAttr( x:handle, "format" ) skip
dynGetAttr( x:handle, "width" )
view-as alert-box.

</snippet> hth
 

Marian EDU

Member
Code:
function fGetAttribute
returns character
  ( hWidget as handle,
    cAttribute as character ) :

  define variable hCall  as handle     no-undo.
  define variable cRet   as character  no-undo.

  create call hCall.

  hCall:in-handle = hWidget.
  hCall:call-type = get-attr-call-type.
  hCall:call-name = cAttribute.
  hCall:invoke no-error.
  cRet = string(hCall:return-value).
  hCall:clear.
  delete object hCall.

  return cRet.

end function.
 
To get/set attributes and call methods, try:

form with frame f1 title "Frame 1".
def var c1 as char view-as combo-box inner-lines 10.


function f_attribute returns char (
inp_inhandle as char,
h_inhandle as handle,
inp_attr as char,
inp_action as char,
inp_param as char,
inp_type as char,
inp_datatype as char):

define variable call_action as int no-undo.
define variable hCall as handle no-undo.
define variable return_attr as char no-undo.
define variable param_loop as int no-undo.
define variable param_type as char no-undo.
define variable param_datatype as char no-undo.
if inp_action = "get" then call_action = get-attr-call-type.
if inp_action = "set" then call_action = set-attr-call-type.
create call hCall.
if inp_inhandle <> "" then hCall:in-handle = inp_inhandle no-error.
else if valid-handle(h_inhandle) then hcall:in-handle = h_inhandle.
hcall:call-type = call_action.
hCall:call-name = inp_attr.
if hcall:call-name = inp_attr then do:
hCall:NUM-PARAMETERS = num-entries(inp_param,"|").
do param_loop = 1 to num-entries(inp_param,"|"):
if param_loop <= num-entries(inp_type,"|") then
param_type = entry (param_loop,inp_type,"|").
else
param_type = "char".
if param_loop <= num-entries(inp_datatype,"|") then
param_datatype = entry (param_loop,inp_datatype,"|").
else
param_datatype = "input".
hCall:set-parameter( param_loop, param_type, param_datatype, entry (param_loop,inp_param,"|")).
end.
hCall:invoke no-error.
return_attr = hCall:return-value.
delete object hcall.
return return_attr.
end.
else return "".
end function.
display c1 with frame f1.
f_attribute ("session", ?, "numeric-format", "set","american", "","").
message
f_attribute ("session", ?, "date-format", "get", "", "","") skip
f_attribute ("session", ?, "numeric-format", "get", "", "","") skip
f_attribute ("", frame f1:handle, "title", "get", "", "","") skip
f_attribute ("this-procedure", ?, "get-signature", "get","f_attribute", "","") skip(1)
view-as alert-box.
/* To show two parameters - equivalent to c1:insert ("One",1). */
f_attribute ("", c1:handle in frame f1, "insert", "get","One|1", "character|integer","").
f_attribute ("", c1:handle in frame f1, "insert", "get","Two|2", "character|integer","").
f_attribute ("", c1:handle in frame f1, "insert", "get","Three|3", "character|integer","").
update c1 with frame f1.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
it@flude.co.uk,

i mean no offence by it, and your solution is as good or better then any other.
but don't you think sometimes simpler is better.

the next guy to work on that proc and even if it's you six month from now,
is in for a surprise.

but then again that's how i organized my apartment, empty walls and lot's of
electric appliances mostly in black :p
 
joey.jeremiah said:
it@flude.co.uk,

i mean no offence by it, and your solution is as good or better then any other.
but don't you think sometimes simpler is better.

If I'm using things like CALL, I don't want to mess about with the syntax, replicating it each and every time. I'd stick this in an include file and just use it when I need to. I'd probably wrap it in a couple of simpler functions as well.

Also, it was meant as a demonstration to show:
1. How to get attributes
2. How to set attributes
3. How to call simple and complicated methods

My original stab had six procedures/functions (1 for each of set/get/method, 1 to create the CALL, one to invoke the CALL, one to add parameters) bvut they all shared common code, so I combined them into one (fairly) easy to use function.

joey.jeremiah said:
the next guy to work on that proc and even if it's you six month from now,
is in for a surprise.

Actually, I'm at a loss as to when I would use the CALL statement to get/set attributes and call methods dynamically. Normally, I do it explicitly in code, which makes it clear and easy to understand.

Presumably, dynamic use of attributes/methods could be used in a database-driven setting, with call parameters being stored in a database/temp table and accessed on the fly. Not really my cup of tea, though.
 
badidi said:
Sorry but you could not understand me. I am not beginner. My question is about getting/setting attributes dynamically. See the example in my question again please.

I can appreciate that you are not a beginner. You should realise then it is all about iteration. Once you know how to set attributes, the same basis then applies for doing this dynamically(on-the-fly). That is where the skills is, programming. Ways to achieve your objective. Like M$ and Windows there is not always a single (correct) method or way.
 

badidi

New Member
Min. ver. requirement?

Marian EDU said:
Code:
function fGetAttribute...

Thanks, but it did not work.:( Note that I am using Progress ver 9.1C. Which version of Progress can run this function?:confused:
 

joey.jeremiah

ProgressTalk Moderator
Staff member
hello, is this thing on ?

i posted earlier, look up, it was introduced in 9.1d

and an alternative solution.
 

badong

New Member
Especially for badidi

Hullo badidi!!! I am writing this because I was somewhat pleasantly shocked that there were hundreds of the name "badidi" on the Internet when I did a Google search. :biggrin: I am a journalist, have been one for about 15 years now, come from the Fiji Islands in the South Pacific and have had thousands of friends call me by my nickname "badidi" for over 30 years now. I was just surfing the net and thought I should try do a Google on the name "badidi"...and I came across over a thousand of them.:confused:
You see, my friends started to use this nickname for me because it rhymed with my original name Vasiti, which is a general name for a girl in my country. This word "badidi" has no meaning at all in the Fijian language, simply has nothing to do with anyone at all. But I was really shocked to find that it actually is a Chief's name in Africa, named after a University in UAE and many others. Well, you can imagine my shock.:blush:
But I chose you because it interested me to find you have it as your username in this website...may I please enquire who you are...who subscribe to this site?...what are you guys talking about on this site?...why have you chosen this username?...any reason, whatsoever..??:confused:
I am just so curious...please take this as just a real query after a funny discovery on the net...many thanks and kind regards, your Fijian namesake...tee! hee!!:awink:

My full name is Ms Vasiti Ritova, nickname badidi...if you do a Google search now, I am the "badidi' that is connected with www.acsog.com on the Google...it is my old school in Fiji, a boarding school for young Fijian women and that has produced hundreds of achievers for my country and have formed leaders at all spheres. You cannot get into the site though because you have to be an old girl of the school.
However, you can send me an email on vritova@teivovo.com if you are interested to answer my very funny query.
Many thanks again - badidifiji:lol:
 
Top