[Stackoverflow] [Progress OpenEdge ABL] How to perform basic string handling in Progress

Status
Not open for further replies.
D

Dominique

Guest
I want to put the whole alphabet in a string. For that, I need two variables, one containing the whole alphabet, the other containing a counter for the letters to be used, as follows:

Code:
DEFINE VARIABLE i AS INTEGER.
DEFINE VARIABLE Alphabet AS CHARACTER FORMAT "x(30)".

The logic I've found, does this as follows:

Code:
/* Main logic */
i = ASC("a").
REPEAT:
  APPLY CHR(i) TO Alphabet.
  IF CHR(i)="z" THEN LEAVE.
  i = i + 1.
END.

As I have experience in other programming languages, I would opt for another approach:

Code:
/* Main logic */
i = ASC("a").
REPEAT:
  Alphabet = Alphabet + CHR(i). /* This line is different */
  IF CHR(i)="z" THEN LEAVE.
  i = i + 1.
END.

Obviously my proposal is not working, but then I wanted to understand why, and I had a look at an official URL, explaining the APPLY statement, stating the following:

APPLY statement

Applies an event to a widget or procedure. Syntax

APPLY event [ TO widget-phrase ]

Now I'm lost: what is the relationship between chars in a string, and events (I understand an event as a button-click or something)? (I fear I'm completely misunderstanding this whole concept)

Edit, after some more research:

In the meantime I've understood that I can make the whole thing work, as follows:

Code:
/* Main logic */
i = ASC("a").
REPEAT:
  Alphabet = Alphabet + CHR(i). /* This line is different */
  IF CHR(i)="z" THEN LEAVE.
  i = i + 1.
END.
Alphabet:SCREEN-VALUE = Alphabet.

This, however, only shows me that "normal" string-handling is possible in Progress, it does not yet explain the whole event-thing.

Continue reading...
 
Status
Not open for further replies.
Top