Small Basic Forum
Variables in Subroutines - Printable Version

+- Small Basic Forum (https://litdev.uk/mybb)
+-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1)
+--- Forum: Discussion (https://litdev.uk/mybb/forumdisplay.php?fid=4)
+--- Thread: Variables in Subroutines (/showthread.php?tid=24)

Pages: 1 2 3


RE: Variables in Subroutines - litdev - 12-09-2023

JR,

Thanks, I can reproduce issues now.

They come from event subroutines, with issues relating to a variety of event threads interacting, being created or still running while other threads are paused for the debugging.  If I come up with a solution I will implement, but not hopeful at the moment.

I'm not sure I can easily fix this using the fairly basic debugging technique I used.  In general I suggest to do limited work in event subroutines - just set flags - and do all the work in an application game loop reacting to the event subroutine flags.  This is good practice for a variety of reasons (not just debugging) and is how interactive software generally works.  It keeps all the action on a single UI thread.

In your case, you have done a lot of work inside event subroutines - I would suggest carring on with your code (albeit with reduced debugging capability) and maybe next program you write think about the apllication loop idea.


RE: Variables in Subroutines - jrmrhrb00 - 12-09-2023

LitDev,

It's interesting in that the program actually works. When I try debugging with sb-prime is when trouble starts. At first I thought it was due to threading. I even set the processor affinity to one. My computer has 4 cores. That didn't do anything. I even put some of the subroutines back in the main code. Didn't work either!

Let me know if you decide to make any changes. I would be glad to try them out. Thanks for your help! I might try rewriting the program at a later time with your suggestions.

JR


RE: Variables in Subroutines - Scout - 12-11-2023

Hello JR,
Thank you for the database program with SQLite.
It is probably still a beta version, as the data entered looks somehow different in the generated tables. But it is a good basis for working with SQLite at all.
I have a request: Could you upload the file "dataBase.jpg" because I haven't found a demo with an IconList in the menu yet and I don't know what it should look like?
Here's a note to everyone who wants to check the tables created with SB: The "DB Browser for SQLite" is a free and solid tool for this.
https://sqlitebrowser.org/


RE: Variables in Subroutines - jrmrhrb00 - 12-11-2023

LitDev,

Sorry, I don't have that file anymore. Previously I upgraded my laptop to a new one and I missed saving that file. It was just an icon file that I had pulled off the web.

Previously I had used the database browser. Thanks for the link it allowed me to update.

JR


RE: Variables in Subroutines - litdev - 12-16-2023

JR, I have made some changes to help the debugger cope with event threads - hope it hasn't made things worse!


RE: Variables in Subroutines - jrmrhrb00 - 12-16-2023

LitDev,

I'll give it a go!

JR

How would I know if I have the right prime level? The one I have now is 1.1.9.0. If that is the right level, if I set a breakpoint it will go to it and then if I hit F11 it will step. I can see in previous steps what the variables were set to. So, I think it's better. In some places though it does jump to the wait loop. Being able to see what previous variables is set at is a big help.

You know a long time ago I remember stepping through a program with every step it took, but now, even with visual basic, I can't do that anymore. It seems like with multiple cores, events and threading that now it is just too complicated. In the end I go back to textwindow.writeline to find out what is happening.

I did get this exact program to graduate and I finally got it running under visual basic. Most of the problems I had in visual basic is that they didn't implement all of the functions of the text object. I got around that by using visual basic functions. So, with that I can see that SB-Prime stepping is working about the same as it does with visual basic.


RE: Variables in Subroutines - litdev - 12-16-2023

JR,
The new version has Debug Extension version 10 (bottom left footer).  You can update using Advanced -> Update option from inside SB-Prime.


RE: Variables in Subroutines - jrmrhrb00 - 12-16-2023

LitDev,

Debug extension 10 is what I was using. Stepping and variables looks as good as what I get with visual basic with the same sql_database program. Thanks!

JR


RE: Variables in Subroutines - jrmrhrb00 - 12-18-2023

LitDev,

I changed the SQLDatabase program so that all of the work should be done on the main thread for events. Put flags in for events. Could you try it out and see if stepping is working like you want it. Looks fine to me. The import code is: CRLC41.000. I tried that code and it worked for me. Should work for you!

JR


RE: Variables in Subroutines - litdev - 12-19-2023

JR,

Your database program looks great!

To do it 'on the main UI thread' would be inside the While True loop, something like described here and here.

As I said before your program works great and no need to change - the 'game loop' idea is mainly for interactive event control that is happening fast and the only issue for your program was the debugging.