[4GL/ABL] Help a dummy/newbie with some ambigued (for me) co

Posted by Admin on 30-Jun-2008 05:14

Good morning to all guy!

I'm a new italian user of OpenEdge SW suite, so sorry for my bad english.

For example, this is a correct use of SuperProcedure?

DEF VAR hPersist AS HANDLE NO-UNDO.

/* FIND PERSISTENT PROCEDURE HANDLE. EXECUTE IT IF NOT THERE. */

hPersist = SESSION:FIRST-PROCEDURE.

DO WHILE VALID-HANDLE(hPersist):

IF hPersist:PRIVATE-DATA = "wpersist" THEN LEAVE.

hPersist = hPersist:NEXT-SIBLING.

END.

IF NOT VALID-HANDLE(hPersist) THEN

DO:

RUN wpersist.p PERSISTENT SET hPersist.

SESSION:ADD-SUPER-PROCEDURE(hPersist).

END.

I must always do this step to create a SuperProcedure?! o_O

All Replies

Posted by Admin on 30-Jun-2008 05:16

The notation:

SESSION:FIRST-PROCEDURE

hPersist:PRIVATE-DATA

hPersist:NEXT-SIBLING

SESSION:ADD-SUPER-PROCEDURE(hPersist)

, what mean?

The field "FIRST-PROCEDURE"/"PRIVATE-DATA" off the object SESSION/hPersist ?!

Posted by Admin on 30-Jun-2008 06:22

I find the call at the function:

set-user-field("TxtLast", v-last).

in a file named cgiutils.i, is a function of the Progress library like get-value(...)?

Posted by Admin on 30-Jun-2008 06:32

&IF DEFINED(EXCLUDE-set-user-field) = 0 &THEN

&ANALYZE-SUSPEND _CODE-BLOCK _FUNCTION set-user-field

FUNCTION set-user-field RETURNS LOGICAL

(INPUT p_name AS CHARACTER,

INPUT p_value AS CHARACTER) :

/****************************************************************************

Description: Sets the associated value for the specified user field. User

field values are global and available to any Web object run by the

current Agent in the same web request. The value can be retrieved with

get-user-field() or get-value().

Input Parameters: Name of user field, associated value

Returns: TRUE if field added, otherwise FALSE

Side effects: Queues a message if adding a field fails

Global Variables: UserFieldList, UserFieldVar

****************************************************************************/

DEFINE VARIABLE i AS int NO-UNDO.

ASSIGN i = LOOKUP(p_name, UserFieldList).

IF i > 0 THEN

ASSIGN UserFieldVar = p_value.

ELSE DO:

IF NUM-ENTRIES(UserFieldList) THEN

ASSIGN

UserFieldList = UserFieldList +

(IF UserFieldList = "" THEN "" ELSE ",":U) + p_name

i = NUM-ENTRIES(UserFieldList)

UserFieldVar = p_value.

ELSE DO:

/* If we get to here, then there's no more room for new parameters. */

queue-message("WebSpeed":U, "set-user-field: maximum number of entries" +

" exceeded").

ASSIGN i = ?.

END.

END.

RETURN (i <> ?). /* return TRUE unless field could not be added */

END FUNCTION. /* set-user-field */

&ANALYZE-RESUME

&ENDIF

Posted by Admin on 30-Jun-2008 06:57

I try a auto-answer for this case, in the same file i find the definition of "get-value()" so i think that set-user-field is a function Progress.

&IF DEFINED(EXCLUDE-get-value) = 0 &THEN

&ANALYZE-SUSPEND _CODE-BLOCK _FUNCTION get-value

FUNCTION get-value RETURNS CHARACTER

(INPUT p_name AS CHARACTER) :

/****************************************************************************

Description: Retrieves the first available value for a user field, field

or cookie.

Input Parameter: Name of item or ?

Returns: Value of user field, form field or Cookie in that order or blank if

an invalid name. If ? was specified for the name, a comma separated list

of all user fields, fields and cookies is returned.

Global Variables: UserFieldList, UserFieldVar, FieldList, FieldVar

****************************************************************************/

DEFINE VARIABLE v-value AS CHARACTER NO-UNDO.

DEFINE VARIABLE v-field-list AS CHARACTER NO-UNDO.

DEFINE VARIABLE v-cookie-list AS CHARACTER NO-UNDO.

DEFINE VARIABLE i AS int NO-UNDO.

/* If name is ?, pass a list of all names in user fields, fields and

cookies. */

IF p_name = ? THEN DO:

ASSIGN

v-field-list = get-field(?)

v-value = UserFieldList +

(IF UserFieldList <> "" AND v-field-list <> "" THEN ",":U ELSE "") +

v-field-list

v-cookie-list = get-cookie(?)

v-value = v-value +

(IF v-value <> "" AND v-cookie-list <> "" THEN ",":U ELSE "") +

v-cookie-list.

RETURN v-value.

END.

/* Else, item name passed so look for it in user fields, fields and

cookies in that order. */

ELSE DO:

ASSIGN i = LOOKUP(p_name, UserFieldList).

IF i > 0 THEN

RETURN UserFieldVar.

IF CAN-DO(get-field(?), p_name) THEN

RETURN get-field(p_name).

RETURN get-cookie(p_name).

END.

END FUNCTION. /* get-value */

&ANALYZE-RESUME

&ENDIF

Posted by Admin on 30-Jun-2008 07:08

I find an example of code that use in comination these 2 function, but don't understand well what this product ...

get-value("txtPromotion").

set-user-field("CONTEXT_PROMO", v-prom).

Posted by Admin on 30-Jun-2008 07:24

But the most simple method to declare a SuperProcedure what is:

RUN PERSISTENT.

RUN PERSISTENT SET hHandle.

?!?!?!

Posted by Thomas Mercer-Hursh on 30-Jun-2008 11:05

I can't help you with the ADM stuff, but that initial example isn't the way that I would handle superprocedures myself. Personally, I tend to keep my use of supers clean and simple so that, for example, a session super is invoked at the top level so that one can always count on it being there and a super local to a functional group is initiated at the top level of that group so that the group can count on it being there. There are those who want to error trap everything possible, but I tend to figure that if I have a set of code that is always invoked from the top, checking in one of the lower procedures for a super that was supposed to be started at the top is gilding the lily since, if the super isn't there, it almost certainly means there is all kinds of stuff wrong. This is based on the notion that one should provide good structuring and encapsulation.

If you are using procedures all over the place for some reason and you aren't sure what has and hasn't been started, then you might want to look into Tim's procedure manager http://www.oehive.org/project/proc-manager Rather than put a bunch of check code in every call, put it all in one place and manage it.

Posted by Matt Baker on 30-Jun-2008 12:10

Bob,

It looks like you're digging through the webspeed code. The set-field() and get-field() are functions built into Webspeed. These are written in ABL. There are several variations on these two methods that are useful, but each works on a different set of values. get-cookie() and set-cookie() work for setting and retrieving cookies from the web browser. get-field() and set-field() work on getting and setting values in either the URL as part of the query string passed to the webserver or as values that are posted from a form in the webbrowser.

The get-user-field and set-user-field are a way to temporarily set values in memory. They're stored in a string so there is a limitation as to how much data can be stored. The values from get-user-field() and set-user-field() only last as long as the current web request.


The other ones get-value() and set-value() look through the return values of each of the other functions ( in a predefined order) and return the values they find. In your example, the code is relying on the search behavior of the get-value() function to allow the posted value of CONTEXT_PROMO to be overridden with the value setup in value of set-user-field("CONTEXT_PROMP", v-prom).

This thread is closed