The Museum of HP Calculators

HP Forum Archive 19

[ Return to Index | Top of Index ]

Hrast BASIC-4X Discussion
Message #1 Posted by HrastProgrammer on 5 Dec 2010, 5:52 a.m.

As asked by J-F, I am creating this thread about the BASIC interpreter for HP-48/49 I am currently working on. We can discuss specifications (after I'll have them fixed), ask questions, provide benchmarks etc.

Quote:
doesn't allow identifier after NEXT (so, NEXT always closes the inner FOR and FOR/NEXT crossing isn't possible).

So how do you exit a for loop early????

- Pauli


I must admit that I don't understand your question. How does variable after NEXT help you to exit a FOR loop early?

For example, we have the following program:

10 FOR I=1 TO 10
20 DISP I
30 NEXT I
40 DISP "I am out!"

How does NEXT I enable a premature exit, compared to NEXT only?

Couldn't you write I=10: GOTO 30 to exit the loop, no matter of NEXT vs. NEXT I?

10 FOR I=1 TO 10
15 IF I=6 THEN I=10: GOTO 30
20 DISP I
30 NEXT
40 DISP "I am out!"

Of course, BASIC-4X, being a highly structured language, provides EXIT and EXIT FOR statements for such purpose:

FOR I=1 TO 10
  IF I=6 THEN EXIT
  DISP I
NEXT
DISP "I am out!"
      
Re: Hrast BASIC-4X Discussion
Message #2 Posted by Namir on 5 Dec 2010, 2:14 p.m.,
in response to message #1 by HrastProgrammer

Hrast,

Anyway you can setup a PayPal account so that we can purchase the various software you are selling? Sending money through Western Union has a bad taste because of all the scams on the *other auction* site!!

Namir

PS: Your music shows that you are also talented in that area as well as programming.

            
Re: Hrast BASIC-4X Discussion
Message #3 Posted by Howard Owen on 5 Dec 2010, 6:07 p.m.,
in response to message #2 by Namir

I second this. My bank goes a little insane every time I send money via Western Union.

            
Re: Hrast BASIC-4X Discussion
Message #4 Posted by HrastProgrammer on 6 Dec 2010, 1:18 a.m.,
in response to message #2 by Namir

Quote:
PS: Your music shows that you are also talented in that area as well as programming.

Thanks Namir! The problem is to find time to do all this, because of other "trivial" activities like work etc. Time is my biggest enemy :-(

In regard to PayPal/Western Union ... When I started with emulators, there wasn't even a sign of PayPal here and last time I checked it still wasn't possible to receive money via PayPal. Perhaps things changed recently, I will check it again.

      
Re: Hrast BASIC-4X Discussion
Message #5 Posted by Eric Smith on 5 Dec 2010, 9:23 p.m.,
in response to message #1 by HrastProgrammer

NEXT with a variable name is used for exiting an inner loop:

10 FOR I=5 TO 1000 STEP 2
20 FOR J=3 TO SQR(I) STEP 2
30 IF I/J = INT(I/J) THEN 60
40 NEXT
50 PRINT I;
60 NEXT I

You might well be able to do this better with your fancy structured BASIC, but this is how it was traditionally done.

            
Re: Hrast BASIC-4X Discussion
Message #6 Posted by Paul Dale on 6 Dec 2010, 1:19 a.m.,
in response to message #5 by Eric Smith

Eric got it first go. Being able to exit an inner loop (or two) is useful.

Many Basics pre-evaluate the loop bounds so setting the control variable to the end value didn't always work. It seems this isn't the case with yours though.

- Pauli

            
Re: Hrast BASIC-4X Discussion
Message #7 Posted by HrastProgrammer on 6 Dec 2010, 1:20 a.m.,
in response to message #5 by Eric Smith

I see. OK, I will put this feature on my TODO list. Thanks ...


[ Return to Index | Top of Index ]

Go back to the main exhibit hall