|
Post by bushrat on May 11, 2023 1:21:00 GMT -5
Hi, I've been using Liberty Basic very happily for many years and it's been problem free. Currently using an HP Laptop with Windows 10.
In more recent times (Oct 22) I upgraded it, but I'm starting to get strange problems with some of my programs, so I started to check the installation.
Notably, when I hit the 'Run' command I get a window which: 1. has no 'Error log' entry. 2. has a 'Kill Basic apps' command which has no effect whatever - I have to use windows Task Manager to 'end task' to stop a hanging program. 3. has a 'Debug' command which doesn't Execute anything - it thinks there's no code to debug when the current program code is sitting in the lower window pane.
What's happening is that I cannot serially run my program. What I mean is that upon loading my program, it runs first off exactly as expected - no problems. This particular program runs until it meets a conditional statement mid-program, at which point if the condition is not met I simply have an END statement.
But if I try running it again straight away, it runs to a certain point? then just hangs - as if stuck in a loop - which it probably is.
I assume the END statment stops the program and a subsequent Run command would clear all variable values and start the program afresh - so why won't the program simply run again giving the same results as the initial run?
I know this is a very simple issue I'm discussing here, but I don't know how I'm going to deal with it, The no. of times I've checked my code.....
Given the situation with the Run command window, perhaps my installation of Liberty Basic has become corrupted? Just thought I'd ask you about my problem in case you've run into similar situations before.
Anyway, thanks for your time. I hope you can shed some light on my problem because it's causing me some inconvenience.
|
|
|
Post by Rod on May 11, 2023 2:49:48 GMT -5
Don't blame the tools :) it will be something simple. Can we see the code?
|
|
|
Post by bushrat on May 11, 2023 5:54:16 GMT -5
The code isn't mine so I don't have permission to publish it.
As for 'blaming the tools' - that's not the case. My post indicates what is substantively the case; for example there is no error log etc. That's not some fanciful imaging of mine, it's a fact.
Thanks for your reply.
|
|
|
Post by tsh73 on May 11, 2023 6:10:49 GMT -5
These menu items are read in startup from INI file Look in C:\Users\your_user_name\AppData\Roaming\ something regarding LibertyBasic *.INI inside look for "externals" word "0 externals" likely means INI file was recreated from scratch, normal poiners to error.log and probably FreeForm is lost (but all could be recreated via menu Stup\External programs)
I would start with reinslalling LB into new folder (not touching old one) and see if running from new folder makes it any better.
|
|
|
Post by bushrat on May 11, 2023 6:56:49 GMT -5
yes, I'll reinstall LB to see if it makes a difference.
The thing I don't get is how a program can be loaded, runs correctly with expected results, compiler message says 'completed' - then when you try to rerun it, it won't run correctly? I've never encountered that situation before.
I'll let you know what happens after re-install.
|
|
|
Post by Rod on May 11, 2023 7:06:44 GMT -5
Do you open any files during the run? If so are they closed? There are lots of reasons why a program will appear stuck. One is sitting at a wait statement. The other is being stuck in a never ending loop. But you get a message saying the program has completed. Clicking on the > run icon should run it again.
So you can start Liberty and run the program once. That tells us there is likely nothing wrong with the install.
run till it stops. When you go to run it a second time click on the ladybug, then click on the animate arrows and see where the program is sitting stopped at or looping round at.
|
|
|
Post by bushrat on May 11, 2023 21:24:50 GMT -5
Hi, I haven't solved my little problem yet but your last reply was very helpful, it's given me a lot of ideas about a solution. I will get there eventually and I suspect, as you indicated earlier, the fault lies somewhere in my program. The confounding thing is that on the first run of my program I get no errors reported with any of compilation/syntax/leaving files open at program termination. But it's definately looping its ass off at some point. I guess I'll have to flood the program with print diagnostics to see if I can trap the looping somewhere, but it's a real pain in a big program (well not that big, it's about 5,000 lines).
I did check the error log - which I have always found very useful for diagnostic purposes - but the last log entry was for weeks ago, it's not being updated for the millions of times I've run the program since?.... I think re-install of LB will fix that (I'm a bit short of time right now, but I'll do it ASAP.)
I just had a thought, the error log simply appends the latest one to those already existing - would it be possible to introduce a command "Clear error log" so that only the most recent was reported? with a warning that doing so would eradicate longer term diagnostics if such a thing was later required.
cheers...
|
|
|
Post by Rod on May 12, 2023 1:03:23 GMT -5
The error log can get written in surprising places. It gets an error appended and grows and grows. Just select all and delete and save the empty file or just delete error.log and Liberty will write a new one. The best way to find the actual error.log being used is to navigate to it using liberty’s own menu system. Can’t just recall which menu it’s under but think it’s on the external programs list.
Use the debugger to trap where it is stopping or looping. Start it second time using the ladybug and click > run. Then when it seems non responsive click on the single step icon. If it lets you back in it will highlight each line as it moves through the loop.
If it does not let you back in it is in a tight loop with no scan or wait statement to let it see mouse and keyboard and event input. Then you will need print statements to see where you are. Start at a high level and work into the area that is causing the trouble.
|
|
|
Post by Rod on May 12, 2023 1:24:05 GMT -5
Actually thinking about it, it is probably the initial run that is causing the problem by not completing properly. It could be as simple as it not reaching the END statement. It might be coded but is the program flow actually reaching END. But if it is unresponsive and locked up it is probably in a loop. On Error can also seem to lock up the program if you use that anywhere. So use the debugger on the initial run > then Single arrow when it seems frozen, again you are looking for that blue highlighted line moving from command to command. If not it’s really crashed and you need to see where you get to.
One other method is to click on the left margin of the ide to create a break point. Start the debugger and then select run to line. If it runs to the break point and is still responsive you can move the break point further on and continue.
All this d3buggrr work is time well spent, you should know the debugger as well as the ide.
|
|
|
Post by bushrat on May 12, 2023 2:49:14 GMT -5
I'll have to make a confession - in all the years I've been using LB I've never used the debugger. Never had a problem I couldn't solve using the error log and diagnostic prints. One small problem - the debugger won't run, so until I've reinstalled LB I won't know whether that's a permanent problem on my machine or not.
I take your point though, learning to use the debugger is clearly a great benefit and it's my next job.
Many thanks for your input it's been great - I just need some time to get to these issues.
|
|
|
Post by Rod on May 12, 2023 5:58:58 GMT -5
When you say the debugger wont run, do you mean once your program has stopped/crashed? If so that's expected, you must start the debugger ahead of the program crash not after. Load the program or any simple program into the IDE, now click on the ladybug and then the >run icon or better still the animate icon. The program will start showing you line by line operation.
|
|
|
Post by bushrat on May 12, 2023 22:21:39 GMT -5
OK thanks - debugger runs
|
|
|
Post by bushrat on Jun 1, 2023 7:57:26 GMT -5
Just a follow up on my previous posts about difficulties re-running a program. I had to take a break from it all, it was getting a bit frustrating and I had lots of other stuff to do. I'm still stuck but this time I've isolated the problem code and listed it below.
There's just something I'm not seeing so I'd be really grateful if you would perhaps look at or run the code to see how it runs for you. I have no doubt whatsoever about the integrity of Liberty Basic - I've used it for years and it's run faultlessly, the problem is down to me. That's hard to accept sometimes when you're so convinced your code is correct - but somewhere it isn't...
Perhaps there's something I'm doing wrong with installation, or even a fault in my machine - I don't know what at this stage, so any clarification from you would be great.
If you are going to run it then please note that sometimes it fails straight off the bat, other times it runs perfectly first go and can even be run serially for perhaps 3 or 4 times but eventually fails. The thing that gets me is when it runs first time successfully with no reported errors, then why won't it run again? I've never had this problem before in all the stuff I've ever written. ---------------------------------------------------------------------------------------------------------------------------------------------------------------
'program: matrix.bas 'date: 1 jun 2023
'programmer: bushrat
'Purpose of program. '=================== 'This program generates a 42x2 matrix subject to the following. 'Matrix elements must conform to the following conditions: (a) they must be randomly generated nos. from 1 to 23 ' (b) there are two given nos. in the above range which they are not allowed to be used ' (c) there must be no duplicate nos. in any matrix row ' (d) each permissible random number must have frequency=4 in the final matrix ' (e) if the first element in any matrix row >18 then the matrix must be regenerated.
'The reason the matrix is 42 rows is because, at the end of the day, there should be 42 pairs of (23-2) random nos. with each no. having 'frequency=4. --> (21*4)/2 = 42 rows to hold these pairs.
'**************************** '* * '* Dimension declarations * '* * '**************************** [reStart] dim matrix(42,2) dim TA(23) '<-- TA(i)=frequency tracking array dim counter(23) '<-- random no. frequency counter
'*********************** '* * '* Initialise arrays * '* * '*********************** 'initialise tracking array - TA(i) keeps count of random no. frequencies in array 'matrix' '----------------------------------------------------------------------------------------- for i=1 to 23 TA(i)=0 next i
'use marker '99' in tracking array 'TA(i) for 2 excluded nos. '------------------------------------------------------------ TA(4)=99 '<-- the index numbers 4 and 5 are random, just so long as there are 2 excluded nos. in the range 1-23 TA(5)=99 ' they don't have to be consecutive either, they just happen to be in the present instance.
'initialise matrix(i,j) '---------------------- for i=1 to 42 for j=1 to 2 matrix(i,j)=0 next j next i
'initialise matrix frequency counter '----------------------------------- for i=1 to 23 counter(i)=0 next i '=================== 'END INITIALISATIONS '===================
'**************************** '* * '* Generate array 'matrix' * '* * '**************************** for row=1 to 42
'1st random element matrix(row,1) '-------------------------------- [rand1] r1=int(rnd(1)*23)+1
'reject if r1=excludedNo '----------------------- if TA(r1)=99 then [rand1]
'increment TA(r1) '---------------- TA(r1)=TA(r1)+1
'check tracking array counter not >4 '----------------------------------- if TA(r1)>4 then [rand1]
'assign r1 to matrix '------------------- matrix(row,1)=r1
'2nd random element matrix(row,2) '-------------------------------- [rand2] r2=int(rnd(1)*23)+1
'reject if r2=excludedNo '------------------------ if TA(r2)=99 then [rand2]
'reject duplicate '---------------- if r2=r1 then [rand2]
'increment TA(r2) '---------------- TA(r2)=TA(r2)+1
'check tracking array counter not >4 '----------------------------------- if TA(r2)>4 then [rand2]
'assign r2 to coupon '------------------- matrix(row,2)=r2
next row '===================== 'END MATRIX GENERATION '=====================
'diagnostics '----------- print print "Tracking array - attempted random nos." for i=1 to 23 print TA(i); " "; next i print
print print "un-ordered rows matrix" print "----------------------" for i=1 to 42 for j=1 to 2 print matrix(i,j); " "; next j print next i print
'******************************** '* * '* Order row elements 1 and 2 * '* * '******************************** for i=1 to 42 if matrix(i,1)<matrix(i,2) then [skipSwap]
'swap values for matrix(row,1) and matrix(row,2) '----------------------------------------------- x=matrix(i,1) y=matrix(i,2) matrix(i,1)=y matrix(i,2)=x [skipSwap] next i
'diagnostics '----------- print print "ordered rows matrix" print "-------------------" for i=1 to 42 for j=1 to 2 print matrix(i,j); " "; next j print next i print
print "frequency counts" print "----------------" 'heading '------- for i=1 to 23 i$=using("##", i) print i$; " "; next i print
'frequencies '----------- for i=1 to 42 for j=1 to 2 counter(matrix(i,j))=counter(matrix(i,j))+1 next j next i
for i=1 to 23 count$=using("##", counter(i)) print count$; " "; next i print print "end 1 - success" print "==============="
'reject 'matrix' if first row element>18 '--------------------------------------- goodMatrix=1 for i=1 to 42 if matrix(i,1)>18 then goodMatrix=0 next i if goodMatrix=0 then [reStart]
print print "end 2 - success" print "===============" end
(Nothing too complicated there but it's driving me nuts - not the right frame of mind for writing programs really). If you can help out it would be great. TIA.
|
|
|
Post by tsh73 on Jun 1, 2023 8:43:18 GMT -5
I run it a few times. Sometimes it just loops Run in under debugger, then it loops, press pause debugger button. You will see variables and could singles-step.
For me it always row=42, looping around [rand2] - probably all previous things set so last condition could not be fulfilled (or takes very long time to get to randomly?)
EDIT added a counter then it looped at [rand2] for 1000 loops, printed matrix(i,j) It always happens then N=matrix(42,1) and N already used twice so last line is N 0
Apparently since all "OK" passes has frequiency 4, it tries set matrix(42,2) fourth time as well - to N but it breaks condition r1<>r2.
|
|
|
Post by xxgeek on Jun 1, 2023 9:35:26 GMT -5
Does the following code actually do what you want. It seems to work, but you be the judge.
'program: matrix.bas 'date: 1 jun 2023
'programmer: bushrat
'Purpose of program. '=================== 'This program generates a 42x2 matrix subject to the following. 'Matrix elements must conform to the following conditions: (a) they must be randomly generated nos. from 1 to 23 ' (b) there are two given nos. in the above range which they are not allowed to be used ' (c) there must be no duplicate nos. in any matrix row ' (d) each permissible random number must have frequency=4 in the final matrix ' (e) if the first element in any matrix row >18 then the matrix must be regenerated.
'The reason the matrix is 42 rows is because, at the end of the day, there should be 42 pairs of (23-2) random nos. with each no. having 'frequency=4. --> (21*4)/2 = 42 rows to hold these pairs.
'**************************** '* * '* Dimension declarations * '* * '**************************** [reStart] dim matrix(42,2) dim TA(23) '<-- TA(i)=frequency tracking array dim counter(23) '<-- random no. frequency counter
'*********************** '* * '* Initialise arrays * '* * '*********************** 'initialise tracking array - TA(i) keeps count of random no. frequencies in array 'matrix' '----------------------------------------------------------------------------------------- for i=1 to 23 TA(i)=0 next i
'use marker '99' in tracking array 'TA(i) for 2 excluded nos. '------------------------------------------------------------ TA(4)=99 '<-- the index numbers 4 and 5 are random, just so long as there are 2 excluded nos. in the range 1-23 TA(5)=99 ' they don't have to be consecutive either, they just happen to be in the present instance.
'initialise matrix(i,j) '---------------------- for i=1 to 42 for j=1 to 2 matrix(i,j)=0 next j next i
'initialise matrix frequency counter '----------------------------------- for i=1 to 23 counter(i)=0 next i '=================== 'END INITIALISATIONS '===================
'**************************** '* * '* Generate array 'matrix' * '* * '**************************** for row=1 to 42
'1st random element matrix(row,1) '-------------------------------- [rand1] r1=int(rnd(1)*23)+1
'reject if r1=excludedNo '----------------------- if TA(r1)=99 then [rand1]
'increment TA(r1) '---------------- TA(r1)=TA(r1)+1
'check tracking array counter not >4 '----------------------------------- if TA(r1)>4 then [rand1]
'assign r1 to matrix '------------------- matrix(row,1)=r1
'2nd random element matrix(row,2) '-------------------------------- [rand2] r2=int(rnd(1)*23)+1
'reject if r2=excludedNo '------------------------ 'if TA(r2)=99 then [rand2]
'reject duplicate '---------------- if r2=r1 and TA(r2)>4 or TA(r2)=99 then [rand2]
'increment TA(r2) '---------------- TA(r2)=TA(r2)+1
'check tracking array counter not >4 '----------------------------------- if TA(r2)>4 then [rand2]
'assign r2 to coupon '------------------- matrix(row,2)=r2
next row '===================== 'END MATRIX GENERATION '=====================
'diagnostics '----------- print print "Tracking array - attempted random nos." for i=1 to 23 print TA(i); " "; next i print
print print "un-ordered rows matrix" print "----------------------" for i=1 to 42 for j=1 to 2 print matrix(i,j); " "; next j print next i print
'******************************** '* * '* Order row elements 1 and 2 * '* * '******************************** for i=1 to 42 if matrix(i,1)<matrix(i,2) then [skipSwap]
'swap values for matrix(row,1) and matrix(row,2) '----------------------------------------------- x=matrix(i,1) y=matrix(i,2) matrix(i,1)=y matrix(i,2)=x [skipSwap] next i
'diagnostics '----------- print print "ordered rows matrix" print "-------------------" for i=1 to 42 for j=1 to 2 print matrix(i,j); " "; next j print next i print
print "frequency counts" print "----------------" 'heading '------- for i=1 to 23 i$=using("##", i) print i$; " "; next i print
'frequencies '----------- for i=1 to 42 for j=1 to 2 counter(matrix(i,j))=counter(matrix(i,j))+1 next j next i
for i=1 to 23 count$=using("##", counter(i)) print count$; " "; next i print print "end 1 - success" print "==============="
'reject 'matrix' if first row element>18 '--------------------------------------- goodMatrix=1 for i=1 to 42 if matrix(i,1)>18 then goodMatrix=0 next i if goodMatrix=0 then [reStart]
print print "end 2 - success" print "===============" end
|
|