Focal Point
Calling a subroutine

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3861078331

July 06, 2005, 08:38 PM
<Lee Roper>
Calling a subroutine
I was told recently that I can create procedures such as long, complex Defines in a separate procedure, and then call that procedure by putting EX Subroutine Name. However, it does not seem to be recognizing the subroutines. Can this be done?
July 06, 2005, 08:44 PM
Leah
I believe with a complex define as you want, you need to do a '-include' in your code

a.fex
define.....
..
end

b.fex
-include a
table...
...
end
Or if you need concrete
a.fex is
DEFINE FILE CAR
MODELA/A20 = MODEL;
END

b.FEX
-include a
TABLE FILE CAR
PRINT MODEL MODELA
END
What you are including has to be in the application path or library concatenation depending on if you are mainframe versus web for storing fex.
July 06, 2005, 09:01 PM
Mickey
Hi,

You can create functions and save it as a file say "function.fex". For Example

DEFINE FUNCTION FNAME/A20(PARAM/A20)
FNAME/A20 = PARAM;
END

You can call this function in a Fex by including the file
-INCLUDE function.fex

and referring to the function as any other focus functions.

DEFINE FILE CAR
TEST/A20 = FNAME('TEST');
END

M
July 07, 2005, 02:19 PM
<Lee Roper>
Thanks for the response. I've found that both
-Include and EX work, but only for one subroutine. I can call one subroutine, the first one, but it ignores the others.

The thing is that they are all Defines, and because they are such long, complex Defines, and the fact that I want to use them in other reports, it seemed better to save them separately. One of the problems seems to be that the only way I could get even one subroutine call to work is that I had to put the Define File Filename...procedure...End in each separate subroutine. Is there a way to call multiple subroutines? That part didn't work for me with either -Include or EX.
July 07, 2005, 02:28 PM
dwf
Lee, could you paste your focexec in a post? And are you getting any error messages at all?
July 07, 2005, 02:31 PM
j.gross
Two approaches:
- - -
(a) Omit the DEFINE and END lines from the includes, and keep them in the reporting focexec:

DEFINE FILE XXX
-INCLUDE mydefs1
-INCLUDE mydefs2
-INCLUDE mydefs3
END

(b) Use the ADD option:
In each of your Define focexecs put:
-DEFAULT &OPTION=' '
DEFINE FILE xxx &OPTION
...
END
And in your report fex:
EX mydef1
EX mydef2 OPTION=ADD
EX mydef3 OPTION=ADD
(DEFINE with no option, or with the CLEAR option, cancels any prior Defines for that filename (which was your problem), while ADD appends to the existing list.)
- - -

Either way, the net effect achieved is that the sets of defines are activated, in the desired order.
July 07, 2005, 02:47 PM
<Lee Roper>
Thanks! That worked!