English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. General (https://eab.abime.net/forumdisplay.php?f=37)
-   -   arexx help (https://eab.abime.net/showthread.php?t=57319)

jimbobrocks92 19 January 2011 09:24

arexx help
 
hi I'm having trouble with my arexx code it runs, but nothing happens here is the listing:

/* my program */

LoopCounter = 0
PlaceValue1 = 0
PlaceValue10 = 0
PlaceValue100 = 0
PlaceValue1000 = 0
do while LoopCounter < 1000
if PlaceValue1 > 9 then
PlaceValue1 = 0
PlaceValue10 = PlaceValue10 + 1
end /* end of IF statement */
if PlaceValue10 < 9 then
PlaceValue10 = 0
PlaceValue100 = PlaceValue100 + 1
end /* end of IF statement */
if PlaceValue100 < 9 then
PlaceValue100= 0
PlaceValue1000 = PlaceValue1000 + 1
end /* end of IF statement */

say "hi!" PlaceValue1000 PlaceValue100 PlaceValue10 PlaceValue1
/* Displays hi! followed by the current value in the PlaceValue Variables */

LoopCounter= LoopCounter +1
end /* end of While statements */

Thanks for any help received

davideo 19 January 2011 09:50

Quote:

Originally Posted by jimbobrocks92 (Post 730571)
hi I'm having trouble with my arexx code it runs, but nothing happens here is the listing:

/* my program */

LoopCounter = 0
PlaceValue1 = 0
PlaceValue10 = 0
PlaceValue100 = 0
PlaceValue1000 = 0
do while LoopCounter < 1000
if PlaceValue1 > 9 then
PlaceValue1 = 0
PlaceValue10 = PlaceValue10 + 1
end /* end of IF statement */
if PlaceValue10 > 9 then
PlaceValue10 = 0
PlaceValue100 = PlaceValue100 + 1
end /* end of IF statement */
if PlaceValue100 > 9 then
PlaceValue100= 0
PlaceValue1000 = PlaceValue1000 + 1
end /* end of IF statement */

say "hi!" PlaceValue1000 PlaceValue100 PlaceValue10 PlaceValue1
/* Displays hi! followed by the current value in the PlaceValue Variables */

LoopCounter= LoopCounter +1
end /* end of While statements */

Thanks for any help received

I'm no expert on Arexx and there may be other problems with your code but I would guess that the 2 minor alterations I've made would help!!

Dave G :cool

jimbobrocks92 19 January 2011 10:19

thx

daxb 19 January 2011 11:57

ARexx has a trace/debug function. Look in your manual about how trace works. This will help and you might easily see what happens (wrong). However, for better readability you should use forums its code tag.

Code:

/* Wonderful magical code follows: */
IF codetagsused=yes THEN DO
    SAY "Wouhh... that looks good ;-)"
    EXIT
END
ELSE SAY "Don`t"


thomas 19 January 2011 12:50

Quote:

Originally Posted by jimbobrocks92 (Post 730571)
end /* end of IF statement */

This is wrong. An IF statement does not have a corresponding end. After THEN and ELSE exactly one statement is executed conditonally. If you want to execute a group of statements, you need to surround them by DO and END. Only DO has a corresponding END. Well, SELECT has one, too. But not IF / THEN / ELSE.

Code:

IF condition THEN
    one statement
else
    another one statement

or

Code:

IF condition THEN
  DO
      multiple statements
  END
ELSE
  DO
      other multiple statements
  END



All times are GMT +2. The time now is 17:42.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04919 seconds with 11 queries