Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## ENTRY function

> Returns a character string entry from a list based on an integer position.

> #### Syntax

>     ENTRY ( element , list [ , character ] )

> ``element``

> An integer value that corresponds to the position of a character string in a list of values. If the value of `element` does not correspond to an entry in the list, Progress raises the ERROR condition. If the value of `element` is the Unknown value (`?`), ENTRY returns the Unknown value (`?`). If `element` is less than or equal to 0, or is larger than the number of elements in `list`, ENTRY returns an error.

> ``list``

> A list of character strings separated with a character delimiter. The `list` can be a variable of type CHARACTER or LONGCHAR. If the value of `list` is the Unknown value (`?`), ENTRY returns the Unknown value (`?`).

> ``character``

> A delimiter you define for the list. The default is a comma. This allows the ENTRY function to operate on non-comma-separated lists. If you use an alphabetic character, this delimiter is case sensitive.

> Examples

> This procedure returns the day of the week that corresponds to a date the user enters. The WEEKDAY function evaluates the date and returns, as an integer, the day of the week for that date. The ENTRY function uses that integer to indicate a position in a list of the days of the week.

> r-entry.p
>     DEFINE VARIABLE datein AS DATE.
>     DEFINE VARIABLE daynum AS INTEGER.
>     DEFINE VARIABLE daynam AS CHARACTER INITIAL "Sunday,
>             Monday, Tuesday, Wednesday, Thursday, Friday, Saturday".

>     SET datein LABEL "Enter a date (mm/dd/yy)".
>     daynum = WEEKDAY(datein).
>     DISPLAY ENTRY(daynum,daynam) FORMAT "x(9)" LABEL "is a" WITH SIDE-LABELS.

> This is an example of a list separated by dashes instead of commas. The result is “helvetica”.

> r-entry2.p
>     DEFINE VARIABLE typeface AS CHARACTER.typeface =
>     "-adobe-helvetica-bold-r-normal--*-210-*-*-*-*-iso*-*".
>     DISPLAY ENTRY(3, typeface, "-") FORMAT "x(16)".

> The next procedure looks up UNIX login IDs in a small password array and returns the name of the user.

> r-entry3.p
>     DEFINE VARIABLE login-name AS CHARACTER FORMAT "x(10)".
>     DEFINE VARIABLE real-name  AS CHARACTER FORMAT "x(20)".
>     DEFINE VARIABLE loop AS INTEGER.
>     /*username:password:uid:gid:gcos-field:home-dir:login-shell */
>     DEFINE VARIABLE passwd AS CHARACTER EXTENT 5 INITIAL [
>       "kulig::201:120:Clyde Kulig:/users/kulig",
>       "gegetskas::202:120:Neal Gegetskas:/users/geget:",
>       "bertrand::203:120:Rich Bertrand:/users/bertr:",
>       "lepage::204:120:Gary Lepage:/users/lepag:",
>       "wnek::205:120:Jordyn Wnek:/users/wnekj:"
>         ].
>     REPEAT:
>       SET login-name.
>       real-name = ?.
>       DO loop = 1 TO 5:
>         IF ENTRY(1,passwd[loop],":") = login-name THEN LEAVE.
>       END.
>       IF loop > 5 THEN
>         MESSAGE "Sorry, but" login-name
>           "is not in my password file.".
>       ELSE
>         real-name = ENTRY(5,passwd[loop],":").
>       DISPLAY real-name.
>     END.

> #### Note

> The ENTRY function is double-byte enabled. It can return an entry that contains double-byte characters from a specified list and the `character` delimiter can be a double-byte character.

> #### See also

> LOOKUP function

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095