Calling a Function in a Procedure

Charter

New Member
Hi guys,

I'm new to progress....

I've created a function and I was wondering what the syntax to call this function in a procedure would be?

the function is just doing a calculation...

thanks!
 

Cringer

ProgressTalk.com Moderator
Staff member
You need to define it as the same data type as the return value of your function.
 

Charter

New Member
hmmmm.....this is what I have...

Both have been defined as input integers in the function..

whats going on?!?! :)
 

TomBascom

Curmudgeon
Try posting a complete example of the problem. One that includes the function in question. Chances are the problem will be obvious once you do that.

Offhand though I note that you called the function with "currperiod" and the error is complaining about "currperiod.201" so I would be looking for some code that references currperiod.201 and I don't see anything like that here...
 

Charter

New Member
201 is just the error message number and currPeriod is :

RETURNS INTEGER (INPUT currperiod AS INTEGER,
INPUT invPeriod AS INTEGER):

in the function itself.

Thanks
 

TomBascom

Curmudgeon
Post a complete example and a correct and true copy of the error messages and we might be able to help you.

Expecting us to successfully guess the body of the function and the true text of error messages isn't going to be very productive.
 

Charter

New Member
oooops sorry! here is my function that I would like to be called by a procedure:

VIEW-AS ALERT-BOX INFO BUTTONS OK.
 

rzr

Member
The below code compiles correctly !, but not sure what your are trying to achieve though.....

Code:
[FONT=courier new]FUNCTION fn-getSlots RETURNS INTEGER 
     (INPUT currperiod AS INTEGER, 
      INPUT invPeriod AS INTEGER): 
/*------------------------------------------------------------------------------
 Purpose: calculate the period and place in correct slot [1-6]
 Notes: 
------------------------------------------------------------------------------*/
 DEFINE VARIABLE cslot     AS CHAR NO-UNDO FORMAT "x(20)".
 DEFINE VARIABLE cPeriod   AS CHAR NO-UNDO.

 DEFINE VAR i                AS INTEGER NO-UNDO.
 DEFINE VARIABLE li-Position AS INTEGER NO-UNDO.

 ASSIGN cslot = "6,5,4,3,2,1".

 REPEAT i = 1 TO 6:

     IF i = 1 THEN 
                 cperiod = STRING(currperiod).
     ELSE ASSIGN cperiod = cperiod + ',' + STRING(currperiod).

     IF currperiod MOD 100 = 1  THEN
          ASSIGN currperiod = currperiod - 89.
     ELSE ASSIGN currperiod = currperiod - 1.
 END.

 ASSIGN li-position = LOOKUP (STRING(invPeriod), cPeriod).

 IF li-position = 0 THEN RETURN li-position.
 IF invperiod > currperiod THEN RETURN 7.

 RETURN INTEGER ( ENTRY (li-position,cSlot)). 

END FUNCTION.

MESSAGE fn-getSlots (201106, 201107) VIEW-AS ALERT-BOX INFO BUTTONS OK. 
[/FONT]
 

rzr

Member
the error is not in the function but with in the internal procedure.

Code:
lv-Turnover = fn-getSlots (currperiod, invperiod)

You are referencing currperiod & invperiod variables in the internal procedure but these variables are not defined in the internal procedure.
 
Top