Those of us working through the process of converting an AREV application have noticed that dictionary symbolics like this: {FIELDNAME_DEF} DO NOT work as defaults in OI forms. (You get a 'cannot read' error if you try it.)
Personnally I do not know why OI could not EASILY accommodate this, but it does not. If you are doing a conversion likely the AREV app has zillions of these, and dealing with them as individual functions or event code is very time (and PROFIT!) consuming.
I was not too thrilled with other solutions to this that I found here… all basically involving recreating what DEFAULT is supposed to do as a gotfocus event…. and reconstructing the original default logic within. Way too time consuming if you need to do it many times over.
Here is a little function I wrote that encapsulates a dictionary item into a function, so it can be called from the control's default.
Theoretically I should be able to retrieve the name of the table programmatically from the form (TABLE property of @WINDOW?)… but alas I could not… so it is specified as a parameter. Crude but it works.
If anyone has a *more elegant* solution please share, but here is what I came up with:
FUNCTION GET_DICT_DFLT(tablename,column)
/* this allows dict symbolics to be used for editline
defaults, by encapsulating the formula within a function.
This should also work with a literal field.
USE: Place this in the default line of a control with the
table name and column name as parameters.*/
* 06/26/03 Jim Peters Created
declare function unassigned, Get_Property
ans ="
if unassigned(tablename) then
tablename="
end
if unassigned(column) then
column="
end
if (tablename # "") AND (column # "") then
id =Get_Property(@WINDOW,"ID")rec =Get_Property(@WINDOW,"RECORD")@ID =id@RECORD=recOpen "DICT", tablename to @DICT thenans=CALCULATE(column)end elsecall fsmsg(column)endend
return ans
Jim,
Maybe this will help.
In the Default for the control, we call a program, e.g.,
GET_DEFAULT_VALUE('ZIP')
Notice I am passing one parameter "ZIP" or whatever. Maybe you can pass two separate parameters, but I haven't test that. This works for us however.
If you can't pass two parameters, but need to, then you might try something like this GET_MANAGER('ZIP*ZIP_FILE' and parse out the values you need.
HTH, and good luck on your journey. I think that you will really enjoy working with and using OI, especially OI32.
Ray Chan
Jim,
Theoretically I should be able to retrieve the name of the table programmatically from the form (TABLE property of @WINDOW?)… but alas I could not… so it is specified as a parameter. Crude but it works.
See .
- Oystein -
Ah, yes… that works!
WinID=@Window
$Insert OIWin_Comm_Init
TableName=JoinMap@
Thanks! to Oystein -] Carl Pates -] Andrew for the answer to that one.
The original version worked nicely, but it bugged me that I had to supply the table name when calling it.
Here is an updated version of the function that only requires the column name as a parameter:
=============================
FUNCTION GET_DICT_DFLT(Column)
/* this allows dict symbolics to be used for editline
defaults, by encapsulating the formula within a function.
This should also work with a literal field.
USEAGE: Place this in the default of a control with the
column name supplied as a parameter.06/26/03 Jim Peters Created
*/
declare subroutine fsmsg
declare function unassigned, Get_Property
TableName="
ans ="
WinID =@Window
$Insert OIWin_Comm_Init
TableName=JoinMap@
if unassigned(column) then
column="
end
if (TableName # "") AND (Column # "") then
@ID =Get_Property(@WINDOW,"ID")@RECORD=Get_Property(@WINDOW,"RECORD")
Open "DICT", TableName to @DICT thenans=CALCULATE(Column)end elsecall fsmsg()endend
return ans