Breakpoint and selected variables ect.

Here you can suggest additions and modifications to BB4W or BBCSDL
Ivan
Posts: 47
Joined: Tue 07 May 2019, 16:47

Breakpoint and selected variables ect.

Post by Ivan »

I could really, really use breakpoint(s) and selected variables.

Indentions in procedures and functions would be very nice.

And if then else indention, the current way to indent is a bit blurry for my eyes.

Code: Select all

DEF PROC_name
  IF statement THEN
    code
  ELSE IF or ELIF
    code
  ELSE
    code
  ENDIF
ENDPROC_name
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 399
Joined: Tue 15 Oct 2019, 09:10

Re: Breakpoint and selected variables ect.

Post by RichardRussell »

Ivan wrote:
Fri 31 Jul 2020, 19:40
I could really, really use breakpoint(s) and selected variables.
Breakpoints are straightforward (to the extent that BBC BASIC supports them) - the code is already in LBB and just needs to be transferred into SDLIDE - but they are not high on my priority list because BBC BASIC programmers haven't traditionally had them and don't miss them! Does anybody else think they should be implemented in BBCSDL?

I don't know what "selected variables" are, sorry.
Indentions in procedures and functions would be very nice.
Personally I don't see how indenting PROCs and FNs adds any clarity to a program. Separating them with whitespace and/or comment lines etc. should make it obvious where they begin and where they end. But YMMV.

Anyway, I don't know how to do it. Because (in BBC BASIC) a procedure can have multiple entry points and multiple exit points it would be difficult to determine which lines should be indented. For example how would you indent this automatically:

Code: Select all

      DEF PROCone : LOCAL id% : id% = 1
      DEF PROCtwo : LOCAL id% : id% = 2
      DEF PROCthree : LOCAL id% : id% = 3
      ...
      IF id% = 1 THEN
        ENDPROC
      ENDIF
      ...
      IF id% = 2 THEN
        ENDPROC
      ENDIF
      ...
      IF id% = 3 ENDPROC
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 47
Joined: Tue 07 May 2019, 16:47

Re: Breakpoint and selected variables ect.

Post by Ivan »

Breakpoints: I think it's easier, at least to me to step through the program using breakpoints where certain variables have to be examined and then singlestep one command at a time. When nobody else needs breakpoints, I will continue to setup debug/print lines to see, when I have logical errors and test code.

I was not aware of multiple entry points and exits in procedures and I'm not able to see the benefits of using these features. With respect: For me it's reminds me of spaghetti/gotos, but it's properly beacause I don't understand.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 399
Joined: Tue 15 Oct 2019, 09:10

Re: Breakpoint and selected variables ect.

Post by RichardRussell »

Ivan wrote:
Sun 02 Aug 2020, 09:11
Breakpoints: I think it's easier, at least to me to step through the program using breakpoints where certain variables have to be examined and then singlestep one command at a time.
Setting a breakpoint simply inserts a TRACE STEP statement into the program at that point, so you can always do that manually. The advantage of building a breakpoint capability into the IDE is, of course, that those TRACE STEP statements are only inserted temporarily, not 'permanently' in your program's source code (you can leave TRACE STEPs in your program, since they are ignored unless executed in Debug mode, although they will slow it down very slightly).

I would still be interested in the views of other users. I would find it hard to justify implementing breakpoints for a single user, but if there are others who would find that feature valuable it would raise its priority.
I was not aware of multiple entry points and exits in procedures and I'm not able to see the benefits of using these features. With respect: For me it's reminds me of spaghetti/gotos, but it's properly beacause I don't understand.
Multiple entry points is a somewhat unusual feature, although I have sometimes found it useful. But even C supports multiple exits points (return statements) in a function, and I'm not aware that it is particularly discouraged. So if it's good enough for C it should be good enough for BBC BASIC!
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Edja
Posts: 33
Joined: Tue 03 Apr 2018, 12:07

Re: Breakpoint and selected variables ect.

Post by Edja »

So if it's good enough for C it should be good enough for BBC BASIC
I use this regularly in combination with a CASE statement. Very useful!
Edja

RichardRussell
Posts: 399
Joined: Tue 15 Oct 2019, 09:10

Re: Breakpoint and selected variables ect.

Post by RichardRussell »

RichardRussell wrote:
Fri 31 Jul 2020, 20:45
Breakpoints are straightforward (to the extent that BBC BASIC supports them) - the code is already in LBB
I should have added that breakpoints are also implemented in bbcide, one of the alternative BB4W IDEs. So if you want to experiment with breakpoints in BBC BASIC for Windows you can do so by running bbcide.exe rather than the standard IDE. It can be found at the files area of the Discussion Group here.

The breakpoints work exactly as they do in LBB: double-clicking in the left margin adds (or removes) a breakpoint on that line. If the program is run in Debug mode it will pause on that line; execution can be resumed, or the program single-stepped, using the buttons in the List Variables window. Breakpoints are only active when the program is run in Debug mode, otherwise they are ignored.

If I were to implement breakpoints in BBC BASIC for SDL 2.0 they would work in a very similar way.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 47
Joined: Tue 07 May 2019, 16:47

Re: Breakpoint and selected variables ect.

Post by Ivan »

Edja wrote:
Tue 04 Aug 2020, 10:40
So if it's good enough for C it should be good enough for BBC BASIC
I use this regularly in combination with a CASE statement. Very useful!
Edja

Code: Select all

/* function returning the max between two numbers */
int max(int num1, int num2) {

   /* local variable declaration */
   int result;
 
   if (num1 > num2)
      result = num1;		
   else
      result = num2;
 
   return result; 
}
I find one return more readable.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 399
Joined: Tue 15 Oct 2019, 09:10

Re: Breakpoint and selected variables ect.

Post by RichardRussell »

Ivan wrote:
Sat 08 Aug 2020, 08:34
I find one return more readable.
I'm not convinced that multiple ENDPROCs (returns in C) are any less acceptable than multiple EXITs (breaks in C). They are both ways of prematurely leaving a structure, and the alternative can be a messy set of cascaded conditional blocks. Consider for example this:

Code: Select all

      WHILE <condition>
        ...
        IF <condition1> EXIT WHILE
        ...
        IF <condition2> EXIT WHILE
        ...
        IF <condition3> EXIT WHILE
        ...
      ENDWHILE
Now look what happens if one replaces the EXITs with conditional blocks:

Code: Select all

      WHILE <condition>
        ...
        IF NOT <condition1> THEN
          ...
          IF NOT <condition2> THEN
            ...
            IF NOT <condition3> THEN
              ...
            ENDIF
          ENDIF
        ENDIF
      ENDWHILE
To me, those cascaded IF...ENDIF blocks, with their increasing indentation, give an entirely misleading indication of the program's structure. They are not 'nested' in any meaningful way, but they appear to be.

The PROC case is directly comparable. With multiple ENDPROCs:

Code: Select all

      DEF PROCtest
      ...
      IF <condition1> ENDPROC
      ...
      IF <condition2> ENDPROC
      ...
      IF <condition3> ENDPROC
      ...
      ENDPROC
whereas with IF...ENDIF blocks:

Code: Select all

      DEF PROCtest
      ...
      IF NOT <condition1> THEN
        ...
        IF NOT <condition2> THEN
          ...
          IF NOT <condition3> THEN
            ...
          ENDIF
        ENDIF
      ENDIF
      ENDPROC
Again, in my opinion, giving a misleading impression of the program's structure.

There are some languages (Liberty BASIC is one) in which the 'premature' exit is achieved using the equivalent of EXIT PROC rather than ENDPROC. It would be possible to modify BBC BASIC to accept that too, but it's only syntactic sugar. Functionally they are identical.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 47
Joined: Tue 07 May 2019, 16:47

Re: Breakpoint and selected variables ect.

Post by Ivan »

Code: Select all

      WHILE <condition>
        ...
        IF <condition1> EXIT WHILE
        ...
        IF <condition2> EXIT WHILE
        ...
        IF <condition3> EXIT WHILE
        ...
      ENDWHILE
As far as I can see there are 4 exits.


Below is my preferred way with one exit:

Code: Select all

      REPEAT
  
        over = FALSE
  
        IF NOT over
    
          dize = RND(6)
    
          IF dize = 1 over = TRUE
          IF dize = 2 over = TRUE
          IF dize = 3 over = TRUE
    
        ENDIF
  
      UNTIL over
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 399
Joined: Tue 15 Oct 2019, 09:10

Re: Breakpoint and selected variables ect.

Post by RichardRussell »

Ivan wrote:
Sat 08 Aug 2020, 14:02
Below is my preferred way with one exit:
Unless I'm missing something, your code is not equivalent to what I listed - it's a completely different example. I'm happy for you to propose an alternative approach, but to show how it avoids EXIT it must be functionally the same!

break statements in C are common, so just as in the multiple-return case I don't think I need to justify BBC BASIC having an equivalent.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.