In an internal proc i have defined these 2 variables.
DEFINE OUTPUT PARAMETER loc_Width_tmp AS INTEGER NO-UNDO EXTENT 1000.
DEFINE OUTPUT PARAMETER cnt AS INTEGER NO-UNDO INITIAL 1.
I have used the above values in another internal procedure as
DEFINE VARIABLE widthMax AS INTEGER NO-UNDO EXTENT 1000.
DEFINE VARIABLE vTextCnt AS INTEGER NO-UNDO INITIAL 1.
Now in this procedure
DEF VAR loc_width AS INTEGER NO-UNDO.
DEF VAR loc_pos AS INTEGER NO-UNDO INITIAL 1.
i have did some calculations such as loc_width = widthMax etc.
loc_pos = loc_pos + loc_width.
etc..
but i want the definition of loc_width and loc_pos as decimal.
Help me out in doing this. is this possible ? ? ?
I thought of using decimal through out this process but since i have used arrays , its nt possible
since array subscripts must be integer
I thought of using decimal through out this process but since i have used
arrays , its nt possible
since array subscripts must be integer
It's a little unclear what you're trying to do. Could you post a little more code?
DEF VAR loc_width AS INTEGER NO-UNDO.
DEF VAR loc_pos AS INTEGER NO-UNDO INITIAL 1.
i have did some calculations such as loc_width = widthMax etc.
loc_pos = loc_pos + loc_width.
When working with arrays you'll need to do something like the below:
DO iIndex = 1 to EXTENT(array_variable):
array_variable[iIndex] = /* somevalue */
/* or */
if array_variable[iIndex] eq /* something */ then
END.
The array variable can be any data type (INT, INT64, DEC, CHAR, Object, HANDLE, etc). The indexer must be integer. Make sure you're not getting the array and the indexer confused.
You can convert a decimal to integer using the INTEGER() function but I don't think that's what you want to be doing here.
-- peter
I concur with Peter that we need a bit more context to respond meaningfully. I would just like to note that having the initial 1 in two places is likely to confuse since I gather that one is the source of the other. I.e., for the destination, an initial value should be meaningless.
..
Two things:
Firstly, check the doc for the return type of the LENGTH function. You can convert that to a decimal using the DECIMAL() function.,
Secondly,
FOR EACH ttprintdata BREAK BY ttprintdata.kolumn BY
LENGTH(ttprintdata.data) DESCENDING:
IF LENGTH(ttprintdata.data) > LENGTH(tempdata) THEN tempdata =
ttprintdata.data.
ELSE.
Are you sure you need the . after the else in the line above? This means that the line below always runs, not just if the ELSE condition is true.
loc_Width_tmp[cnt] = LENGTH(tempdata) + 1.
IF LAST-OF(ttprintdata.kolumn) THEN DO:
cnt = cnt + 1.
tempdata = '1'.
END.
END.
-- peter
Do you really need decimal or would INT64 be sufficient (you don't mention version)?
Not sure what you want, but it is possible to return an integer value to a decimal:
DEFINE VARIABLE dValue AS DECIMAL EXTENT 10 NO-UNDO.
RUN foo(OUTPUT dValue).
dValue[1] = dValue[1] / 3.
MESSAGE dValue[1] VIEW-AS ALERT-BOX INFO BUTTONS OK.
PROCEDURE foo:
DEFINE OUTPUT PARAMETER piValue AS INTEGER EXTENT 10 NO-UNDO.
piValue[1] = 10.
END.