LB Booster
« Wish List »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:44am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Wish List  (Read 1609 times)
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Wish List
« Thread started on: Jan 26th, 2015, 12:16pm »

Could we have?

(1) a RESUME NEXT command option for the error trapping facility, and/or
(2) a SWAP command that might also work with array elements.

In any case, I certainly hope there will be continuing releases of LBB.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #1 on: Jan 26th, 2015, 3:01pm »

on Jan 26th, 2015, 12:16pm, Jack Kelly wrote:
Could we have a RESUME NEXT command

Relatively easy to add, but it would necessarily have the same compatibility issue as RESUME, i.e. it would resume at the line (not statement) after the one in which the error occurred. Not a problem if you have only one statement per line.

Quote:
and/or a SWAP command

Again, easy to add but I worry about breaking existing programs which use 'swap' as a variable name. You could cheat and do this:

Code:
    v1 = 123
    v2 = 456
    print v1,v2
    !SWAP v1,v2
    print v1,v2 

Any other votes for these features to be added to LBB?

Richard.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Wish List
« Reply #2 on: Jan 26th, 2015, 7:38pm »

I'm in for RESUME NEXT. It is really missing in LB.
User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: Wish List
« Reply #3 on: Jan 26th, 2015, 9:38pm »

I'm fine with !SWAP.

No problem with one statement per line, especially in areas that a user could cause an error.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #4 on: Jan 26th, 2015, 9:51pm »

on Jan 26th, 2015, 7:38pm, tsh73 wrote:
I'm in for RESUME NEXT. It is really missing in LB.

It would be helpful (and increase the probability of me adding it!) if you could supply an example program with RESUME NEXT that I could use for testing, and perhaps put in the documentation.

Richard.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Wish List
« Reply #5 on: Jan 27th, 2015, 07:45am »

example from QBASIC
1. There is error could happen; we trap and handle it somehow ; but we want to continue from next statement, not from errored one
Code:
CLS
ON ERROR GOTO Handler

FOR i = -5 TO 5
   PRINT i, 1 / i
NEXT
END


Handler:
   PRINT "Error "; ERR; " happened but we ignore and continue"
   RESUME NEXT 

produces
Code:
-5            -.2
-4            -.25
-3            -.3333333
-2            -.5
-1            -1
 0            Error  11  happened but we ignore and continue
 1             1
 2             .5
 3             .3333333
 4             .25
 5             .2 

2. Example from old VB (QB doesn't have ON ERROR RESUME NEXT)
Somehow on the Internet it is called "C-style error handling"
We have normal code; but there is a part that could break (it could be complex expression, or call to sub, or some device operation (file/disk/network etc))
We enclose it in ON ERROR RESUME NEXT/ON ERROR GOTO 0
(btw LB does not have ON ERROR GOTO 0 as well :(( )
Text1 is multiline textbox, Command1_Click is button handler.

Code:
Private Sub Command1_Click()
    'some ordinary code
    Text1 = Text1 + "Hello" + vbCrLf
    
    'isolate dangerous code
    On Error Resume Next
    ThisMightBreak (0)
    If Err <> 0 Then
        Text1 = Text1 + "!!! Some error happened" + vbCrLf
    End If
    On Error GoTo 0 'turn error checking off
    
    'some more ordinary code
    Text1 = Text1 + "Hello again" + vbCrLf
    
    'second piece of dangerous code - this will break
    On Error Resume Next
    ThisMightBreak (1)
    If Err <> 0 Then
        Text1 = Text1 + "!!! Some error happened" + vbCrLf
    End If
    On Error GoTo 0 'turn error checking off
    
    'last piece of ordinary code
    Text1 = Text1 + "last Hello"
End Sub

Public Sub ThisMightBreak(i)
    If i = 1 Then a = 1 / 0 'force error
    'else
    Text1 = Text1 + "Sub happened to work OK" + vbCrLf
End Sub
 


Output in a textbox: Code:
Hello
Sub happened to work OK
Hello again
!!! Some error happened
last Hello 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #6 on: Jan 27th, 2015, 1:43pm »

on Jan 27th, 2015, 07:45am, tsh73 wrote:
QB doesn't have ON ERROR RESUME NEXT

Do you think this construction is valuable? 'Silently' ignoring an error and continuing execution seems a relatively unlikely (and risky) thing to want to do.

What would be nicer is proper Structured Exception Handling of the TRY...CATCH sort. I could do that, but fortunately nobody's asked for it. grin

Quote:
LB does not have ON ERROR GOTO 0 as well sad

Oh, I thought it did. LBB has it, of course, but I don't advertise it as an enhancement. Probably I should!

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #7 on: Jan 27th, 2015, 5:55pm »

on Jan 27th, 2015, 07:45am, tsh73 wrote:
I'm in for RESUME NEXT. It is really missing in LB.

OK, I have added RESUME NEXT to my Work In Progress version. With this program:

Code:
    CLS
    ON ERROR GOTO [Handler]

    FOR i = -5 TO 5
      PRINT i, 1 / i
    NEXT
    END

[Handler]
    PRINT Err$; " happened but we ignore and continue"
    RESUME NEXT 

I get this output:

Code:
-5            -0.2
-4            -0.25
-3            -0.333333333
-2            -0.5
-1            -1
0             Division by zero at line 5 happened but we ignore and continue
1             1
2             0.5
3             0.333333333
4             0.25
5             0.2 

And with this code:

Code:
    CrLf$ = chr$(13);chr$(10)

    'some ordinary code
    Text1$ = Text1$ + "Hello" + CrLf$

    'isolate dangerous code
    On Error Goto [resume.next]
    dummy = 1 / 1
    If Err <> 0 Then
        Text1$ = Text1$ + "!!! Some error happened" + CrLf$
    End If
    On Error GoTo 0 'turn error checking off
    
    'some more ordinary code
    Text1$ = Text1$ + "Hello again" + CrLf$
    
    'second piece of dangerous code - this will break
    On Error Goto [resume.next]
    dummy = 1 / 0
    If Err <> 0 Then
        Text1$ = Text1$ + "!!! Some error happened" + CrLf$
    End If
    On Error GoTo 0 'turn error checking off
    
    'last piece of ordinary code
    Text1$ = Text1$ + "last Hello"
    Print Text1$
    End

[resume.next]
    Resume Next 

I get this output:

Code:
Hello
Hello again
!!! Some error happened
last Hello 

The ThisMightBreak(n) technique won't work in LBB as it stands, because the error is thrown inside the SUB (and the RESUME NEXT attempts to continue execution inside the SUB).

I could make LBB reproduce the VB behaviour (the error is effectively thrown in the CALL statement), but it's considerably more complicated and it might break compatibility with LB's existing RESUME functionality.

Richard.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Wish List
« Reply #8 on: Jan 27th, 2015, 8:32pm »

Quote:
Quote:LB does not have ON ERROR GOTO 0 as well
Oh, I thought it did. LBB has it, of course, but I don't advertise it as an enhancement. Probably I should!

Indeed. I remember having trouble debugging someone else's program which had on error in a main module. Program didn't worked without on error at all, and there are no way to turn it off once it started. (and I reckon something weird in debugger too)

Quote:
OK, I have added RESUME NEXT to my Work In Progress version.

Great. Thanks a lot.

Quote:
Do you think this construction is valuable? 'Silently' ignoring an error and continuing execution seems a relatively unlikely (and risky) thing to want to do.

Well, if used right (set to ignore an error for a dangerous statement - check and restore normal handling with ON ERROR GOTO 0 right after) , it might be helpful.
EDIT
it's still with us in VBS and Ms Excel.
« Last Edit: Jan 27th, 2015, 8:37pm by tsh73 » User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: Wish List
« Reply #9 on: Jan 29th, 2015, 12:52am »

I'd like like the LBB tool bar to have that icon on the LB tool bar that, when clicked, shows a list of the branch names, and then I can jump right to the one I want. I use this feature a lot.

Also I'd like LBB to automatically nullify the 'nomainwin command when the program is run in debug mode.

r.m.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #10 on: Jan 29th, 2015, 11:50am »

on Jan 29th, 2015, 12:52am, Alincon wrote:
I'd like like the LBB tool bar to have that icon on the LB tool bar that, when clicked, shows a list of the branch names

I agree it's a nice feature. My concern would be whether I could generate the list of branch/function/sub names in a sensible time-frame if the program is really large (I know of programs in excess of 60,000 lines being compiled with LBB).

I know it's not entirely a substitute, but remember that in LBB you can right-click on a branch/function/sub name and then select Jump to from the displayed context menu; to return from where you came right-click and select Go back.

I would speculate that commonly when you want to jump to a particular branch/function/sub it's because you are currently looking at some code which references it (e.g. a GOTO or a CALL), so in that circumstance the right-click option does the job.

Quote:
Also I'd like LBB to automatically nullify the 'nomainwin command when the program is run in debug mode.

I'll investigate the practicality of that.

Richard.
« Last Edit: Jan 29th, 2015, 11:55am by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #11 on: Jan 31st, 2015, 12:55pm »

on Jan 29th, 2015, 12:52am, Alincon wrote:
Also I'd like LBB to automatically nullify the 'nomainwin command when the program is run in debug mode.

I can confirm that this will be in the next release of LBB, due in March.

Richard.
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: Wish List
« Reply #12 on: Feb 1st, 2015, 2:33pm »



Code:
try
catch
end try
 

Code:
call subname a( 13 ) , a( 14 ) , a( 15 )
end
sub subname byref x , byref y , byref  z
end sub
 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #13 on: Feb 1st, 2015, 3:23pm »

on Feb 1st, 2015, 2:33pm, bluatigro wrote:
Code:
try
catch
end try 

Any other votes for this?

Quote:
Code:
call subname a( 13 ) , a( 14 ) , a( 15 )
end
sub subname byref x , byref y , byref  z
end sub 

Good catch! That should definitely work (in LBB), the fact that it doesn't is a mistake on my part. I'll fix it in the next release. Thank you!

Richard.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Wish List
« Reply #14 on: Feb 8th, 2015, 1:45pm »

on Jan 27th, 2015, 5:55pm, Richard Russell wrote:
OK, I have added RESUME NEXT to my Work In Progress version.

Sorry to mess you around, but I've taken it out again! I decided that with SEH being supported in the next release of LBB it didn't make much sense to support the outdated RESUME NEXT as well.

The SEH equivalent to the previous simple example is as follows, and it's much nicer (IMHO):

Code:
    CLS
    FOR i = -5 TO 5
      TRY
        PRINT i, 1 / i
      CATCH
        PRINT Err$; " happened but we ignore and continue"
      END TRY
    NEXT
    END 

And here is the SEH equivalent to the more complex example; no GOTOs, no labels, this is how modern code should be written!:

Code:
    CrLf$ = chr$(13);chr$(10)

    'some ordinary code
    Text1$ = Text1$ + "Hello" + CrLf$

    'isolate dangerous code
    Try
      Call Reciprocal 1
    Catch
      Text1$ = Text1$ + "!!! Some error happened" + CrLf$
    End Try
    
    'some more ordinary code
    Text1$ = Text1$ + "Hello again" + CrLf$
    
    'second piece of dangerous code - this will break
    Try
      Call Reciprocal 0
    Catch
      Text1$ = Text1$ + "!!! Some error happened" + CrLf$
    End Try
    
    'last piece of ordinary code
    Text1$ = Text1$ + "last Hello"
    Print Text1$
    End

Sub Reciprocal n
    dummy = 1 / n
End Sub 

Richard.
« Last Edit: Feb 8th, 2015, 1:48pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls