Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:25 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MM - Nonumber

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 03:35am 19 Jan 2012
Copy link to clipboard 
Print this post

I used the nonumber routine on the LCD file. The first label was OK but subsequent labels were all missing.
Anyone had similar problems.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Keith W.
Senior Member

Joined: 09/10/2011
Location: Australia
Posts: 118
Posted: 10:32am 19 Jan 2012
Copy link to clipboard 
Print this post

Hi Paul,

You are the first to have reported a problem with NoNumber.

And you are correct; I can reproduce the fault with LCD.bas. Incidence labels are placed (though not completely correct) but most destination labels are missing.
I immediately noticed the high value line numbers used by the LCD program. I performed a Renumber of LCD.bas using the inbuilt MMBasic function, NoNumber then worked on the file with all the labels placed correctly. It seems that I have more to learn about MMBasic numbers. I hope to have a correction soon.

Thank you Paul,

Keith W.
 
Keith W.
Senior Member

Joined: 09/10/2011
Location: Australia
Posts: 118
Posted: 01:37am 20 Jan 2012
Copy link to clipboard 
Print this post

Hi,

The problem had nothing to do with the value of the line numbers that I had supposed and it is strange that the fault had not shown up earlier. The fix is very simple. Here is a portion of code showing the fix from the current published NNUMB.bas. Geoff Graham will shortly be releasing a new version of NNUMB with enhancements and I will attach this fix to his file otherwise I think that it will become too confusing for all with different versions. To fix at present alter line 3030 as shown.

3010 ' Compact Destinations -remove duplications
3020 '
3030 x = 0 <<<<<<<<<<<<<<< <<<<<<<<<<< ORIGINALLY THIS WAS: - 3030 x = 1
3040 Do While lines(x) <> 0 And x < lcount
3050 Do While lines(x) = lines(x + 1 )
3060 For p = x To Lcount
3070 lines(p) = lines(p + 1)
3080 Next p
3090 Loop
3100 x = x + 1
3110 Loop

This section of the code will compact a list of the destination numbers found in a program to ensure that each different destination is only listed once. Because the starting index was incorrect the first 2 entries were not compared with the result that the first entry was not removed although of the same value.

The code beginning at line 3660 which places the destination labels then failed because the same line number appeared twice. The first label would be placed and subsequently lineindex would be incremented for the next line. But searching for the same line number against lineindex for the second label would not succeed and the destination label placement not progress.
Any program that contained the first 2 incidence destinations to the same line number would fail to Nonumber, luck had not shown this fault before.

That is not the only element of luck with LCD.bas. In fact the first destination is given only once in the first program line, to line 11000. Why did it become listed twice in the list of destinations? In fact it is listed again in the comment at line 10090 (GOSUB 11000), the original Renumber.bas program upon which Nonumber is based does not differentiate between comments and executable code when searching for keywords with line numbers attached. The Renumber program built into MMBasic however does not alter comments. That is why after I had Renumbered LCD.bas that NNUMB worked, the line number within the comment was not changed resulting in the first destination only appearing once. I have thought about altering NNUMB that it not search within a comment, but as demonstrated with LCD.bas it was correct in altering the comments.

Please let me know of any other problems found with NNUMB.

Keith W.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024