Repeat...Until fails with No Such Variable when compiled

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
circe
Posts: 25
Joined: Wed 07 May 2025, 09:26

Repeat...Until fails with No Such Variable when compiled

Post by circe »

I have a somewhat large program with a REPEAT...UNTIL new% => last%. When Compiled with 'Shorten Names' ticked, repeats correctly until condition is met when it fails with No Such Variable.

A workaround is:

Code: Select all

            A%=new% :REM:To avoid problem with compiling Short Names.
            B%=last%
          UNTIL A% => B%
          REM:Equates to  UNTIL new% => last%
So the variables must exist!

Only fails if compiled with Shorten Names ticked and of course does not fail in Immediate mode.
I have not been able to reproduce in a small model so far.
Richard Russell
Posts: 714
Joined: Tue 18 Jun 2024, 09:32

Re: Repeat...Until fails with No Such Variable when compiled

Post by Richard Russell »

circe wrote: Thu 30 Jul 2026, 10:59

Code: Select all

      UNTIL A% => B%
This may be unrelated to your problem, but that is not valid BBC BASIC syntax. It should be A% >= B% not A% => B%. Think greater than or equal to.
I have not been able to reproduce in a small model so far.
I can't investigate further without a Minimal Reproducible Example to run. But if you're looking for a workaround that is less drastic than turning off the Shorten Names option altogether, consider using REM!Keep so that only the variable(s) that are causing the problem are retained in their original 'long' form:

Code: Select all

      REM!Keep new%, last%
          UNTIL new% >= last%
circe
Posts: 25
Joined: Wed 07 May 2025, 09:26

Re: Repeat...Until fails with No Such Variable when compiled

Post by circe »

Thank you Richard. The => vs >= issue was not the problem, but REM!Keep resolves.
I may be wrong, but I do not see a way of reproducing in a small model. If I do find a way, I will post it here.