Question

I am a new with progress-4gl (OpenEdge) and I have run into some code that for the life of my I can't understand exactly what it does. Below is an example of the code I am trying to dissect and all the material I have found on the situation.

I realize that my answer is in the material however I can't really understand it as well as I want to. Hopefully someone with a bit more knowledge than me can help me. Thanks for anyone who has spent on this:

Function functionName RETURNS CHAR ( integerName AS INT ) {1}:

This function is stored in an include file and is being called by a different procedure in the following way:

charName = GetCommSecType ( intName )

What I don't completely understand is why the {1} is there and what exactly is it doing. If I don't put the {1} everything seems to work the same. I have looked in the help file pasted its information below:

{ } Argument reference:
References the value of an argument that a procedure passes to a called external procedure file or to an include file. ABL converts each argument to a character format. This conversion removes the surrounding double-quotes if the parameter was specified as a character string constant in the RUN statement or include file reference. When one procedure is called from another and arguments are used, ABL recompiles the called procedure, substituting the arguments that the calling procedure passes, and then runs the called procedure.

I believe the purpose of this is to allow the include files function to be run on a command line RUN command. Please correct me if I am wrong. Thanks

Was it helpful?

Solution

{} is something called a preprocessor meaning that it only affects the outcome of your program during compile time, not run time.

Generally you would include a .i file, not run it but this kind of syntax could be used both for running and including files.

In this perticular case it means that the compiler will insert something where {1} is written. {1} signifies the first argument inserted. You can name arguments as well (see the link below).

A simple include of a file like this:

{filename.i}

In this case it's not very easy to guess whats inserted but basically if you do an include like this:

DEFINE VARIABLE c AS CHARACTER   NO-UNDO.
c = "ABC".
{c:\temp\includetest.i c}

The compiler will insert ABC where {1} is written in your include file. That would make no sense in this example of course. And I don't now of anything that really can be written between the parameters and the colon.

Let's say your the filname.i file simply contains.

DISPLAY {1}.

Doing the include like above would then make the compiler replace {1} with "ABC" and thus making the statement look like this:

DISPLAY c.

Running this would display the value of c - "ABC".

You would have to provide the code running or including your file for better understanding of this!

Pages 22 and forward in this document describes this deeper.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top