/* Sample call: run get-widget-len(co.co-num:handle in frame f1, output co-len). */ procedure get-widget-len: /* Determines widget length from its format. */ def input parameter wh as WIDGET-HANDLE no-undo. def output parameter wh-len as INTEGER no-undo. /* Make sure DATA-TYPE is queryable (buttons?) */ if CAN-QUERY(wh, "DATA-TYPE") then CASE wh:DATA-TYPE: WHEN "character" OR WHEN "integer" OR WHEN "decimal" OR WHEN "date" THEN wh-len = LENGTH(STRING("", wh:FORMAT)). /* get the longest of the two parts */ WHEN "logical" then wh-len = MAX(LENGTH(ENTRY(1, wh:FORMAT, "/")), LENGTH(ENTRY(2, wh:FORMAT, "/"))). end CASE. return. end procedure.