Coding help requested.

1 view
Skip to first unread message

gor...@bellsouth.net

unread,
Jun 17, 2008, 7:39:37 PM6/17/08
to OpenQM
Do any of you have an idea on how to make the following code work in
QM without using ON...GOSUB?


for x = 10 to 50 step 10
gosub "ABC":x
next x

stop
********************
ABC10:
crt "It"
return
ABC20:
crt "was"
return
ABC30:
crt "a"
return
ABC40:
crt "success,"
return
ABC50:
crt " Gordon."
return
END




Gordon French
*****************
QM Novice

Eugene Perry

unread,
Jun 17, 2008, 8:29:10 PM6/17/08
to Ope...@googlegroups.com
You could use a case statement with a series of IF statements

BEGIN CASE
CASE X=10
GOSUB ABC10
CASE X=20
GOSUB ABC20
etc...
END CASE

Glen B

unread,
Jun 17, 2008, 9:49:13 PM6/17/08
to Ope...@googlegroups.com

Use classes and fire off methods when criteria is met?

GlenB

Ashley Chapman

unread,
Jun 18, 2008, 2:20:20 AM6/18/08
to Ope...@googlegroups.com
2008/6/17 gor...@bellsouth.net <gor...@bellsouth.net>:


Not sure what you're aiming to avoid, but how about the obvious:-

for x = 10 to 50 step 10

begin case
case x = 10
crt "It"
case x = 20
crt "was"
case x = 30
crt "a"
case x = 40
crt "success,"
case x = 50
crt "Gordon"
end case
next x
stop


--
Ashley Chapman

Martin Phillips

unread,
Jun 18, 2008, 4:16:31 AM6/18/08
to Ope...@googlegroups.com
Hi Gordon,

I replied to your original direct email but it sounds like it never reached
you.

Another way to do this is to use the ON GOSUB statement. Which of the
various solutions offered is best will depend entirely on how this example
relates to what the real program needs to do.

program test_gosub


for x = 10 to 50 step 10

on x/10 gosub 10, 20, 30, 40, 50
next x
stop


Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
+44-(0)1604-709200

gor...@bellsouth.net

unread,
Jun 18, 2008, 8:11:12 AM6/18/08
to OpenQM


Thanks to all of you for helping.

I will close this now that I have learned that gosub labels are
'fixed' at compile time.

In my case the 'calculated' gosub contains alpha text.

Since I cannot do a math calculation I believe that my best solution
is to use a series of case statements.


Gordon French
*****************
Gordon French Accounting, Inc.


On Jun 18, 4:16 am, "Martin Phillips" <martinphill...@ladybridge.com>
wrote:

JeffG

unread,
Jun 18, 2008, 3:26:30 PM6/18/08
to OpenQM
How about this...

SENTENCE = "It was a success Gordon"

FOR X = 10 TO 50 STEP 10
Y = X/10 ;* or just use 1 to 5
CRT FIELD(SENTENCE,' ',Y)
NEXT X

or... (I would probably do this.)

SENTENCE = TRIM("It was a success Gordon") ;* make sure no double
spaces
CONVERT ' ' TO @AM IN SENTENCE

FOR X = 1 TO 5
CRT SENTENCE<X>
NEXT X

On 17 Jun, 19:39, "gord...@bellsouth.net" <gord...@bellsouth.net>
wrote:

Kevin Powick

unread,
Jun 18, 2008, 5:28:01 PM6/18/08
to OpenQM
Ok, just going for the desired output and disregarding the actual
requirements. :-)

S = 'It was a success, Gordon.'
CONVERT ' ' TO CHAR(13):CHAR(10) IN S
CRT S

--
Kevin Powick

Paddy

unread,
Jun 20, 2008, 6:23:48 AM6/20/08
to OpenQM
The only thing I can think of is to change your internal subroutines
to external ones, then use VAR='ABC':X; CALL @VAR

Like:

for x = 10 to 50 step 10
var='ABC':x
CALL @var
next x

where there are external subroutines:


ABC10
SUBROUTINE ABC10
...
RETURN


ABC20
SUBROUTINE ABC20
....
RETURN


ABC30
SUBROUTINE ABC30
...
RETURN


etc.

John Racine



On 17 Jun, 19:39, "gord...@bellsouth.net" <gord...@bellsouth.net>
wrote:
Reply all
Reply to author
Forward
0 new messages