Stronger curiosity Or File Corruption?
Pages: 1 2
Greg (2474) 144 posts |
A few days ago my sdcard on my RPI was showing signs of failure as it started to fail on saving. Reinstall RISC OS on new ad card and everything was fine. Around the same time whenever I loaded a program I had been writing into StrongEd it started to insert line nos even though StrongEd was configured to no line nos. When this happened StrongEd would produce a notification box saying that line nos are inserted due to a line reference. The only things i can think of that BASIC would use line references would be GOTO and GOSUB niether of which are used. If I loaded an older version of code no line nos would be inserted. Any ideas ? Greg |
Clive Semmens (2335) 3276 posts |
One other kind of line number reference might occur: in a RESTORE instruction. Can’t think of any others. |
Martin Avison (27) 1494 posts |
Line numbers can also appear after THEN and ELSE in a single-line IF. If there are any in the file, they are encoded into 4 bytes, the first of which is the token &8D. |
Greg (2474) 144 posts |
@ Clive & Martin I havn’t used RESTORE anywhere but there are quite a few IF…THENs but they seem fine. The BASIC part is identical to the BASIC part in some older code but that doesnt have the same issue with StrongED. Im beggining to think that when the SDcard was failing it has somehow corrupted my program in some way that is confusing StrongED. The code itself assembles fine and runs as it should, its just a curiosity as well as a bit irritating to have to maually delete the line nos each time I load the code. Greg |
Martin Avison (27) 1494 posts |
Can you compare your latest program with a backup that behaved? |
Greg (2474) 144 posts |
I dont have an exact copy as a backup as I didnt realize there was a problem until it was too late and my backups of the problem code suffer the same problem. I have something very similar though. When you say compare do you mean a visual compare or something else. If you mean a visual then I have done that by way of taking my very similar older bit of code that doesnt have line nos and gone through it line by line copying the differences across to get an up to date version without line numbers. A day and a half and 10000 lines of code approx. Dont want to be doing that again anytime soon. I dont have to delete the lines, they just irritate me as they serve no purpose and I havent coded with line numbers since before the 2000’s |
Martin Avison (27) 1494 posts |
@Greg: No, I was not meaning visual comparison, as it is impossible to spot the crucial minor change … and especially not on that size of code! I use two methods which work well on Basic programs (where the line numbers are excluded) are SideDiff by Harriet Bazley from http://www.starfighter.acornarcade.com/mysite/utilities.htm#sidediff or my own Compare from www.avisoft.f9.co.uk. But without a known ok backup copy you are probably going to see the other changes in the code. If you want to email the code to me (in a zip) I will have a look at it – address is my website name with www. replaced by riscos@ |
Clive Semmens (2335) 3276 posts |
I have – precisely for the RESTORE instruction I mentioned. There are other ways of achieving the same effect: either loading all your data into arrays when your program starts, from DATA statements or from one or more separate files; or loading from separate files each time you would have used a RESTORE instruction. But those methods are clumsier – and slower, and use more memory (not that either of those is likely to be an issue). |
Steve Pampling (1551) 8170 posts |
@Greg: No, I was not meaning visual comparison, as it is impossible to spot the crucial minor change … and especially not on that size of code! For the type of problem Greg has given then the side by side comparison with difference points marked, as with SideDiff, is usually best1. Compare is handy for other issues. 1 It’s actually quite like the Diff/Compare in the PC program “Notepad++” which I use extensively in work. |
Martin Avison (27) 1494 posts |
There is no need to use actual line numbers with RESTORE – I always use the offset variant ie RESTORE+n which uses the +n as an offset line from the RESTORE statement to start looking for a DATA statement. +0 simply starts at the RETORE line. Essential in Libraries, but also useful in a main program. |
Clive Semmens (2335) 3276 posts |
Thanks, Martin – that’s something I’d completely missed. I don’t think I’ll edit existing programs to use it though. Indeed I might continue using line numbers where I’ve got more than one block of data in a program, because the correspondence between a line number and a block of data is clear, whereas it would be very easy to miscount lines between one block and the next. Edit. D’uh. See next post! |
Greg (2474) 144 posts |
@ Clive & Steve Thank you for your input on this matter but if i am honest i am a little bit old school in that i love coding ( trying to at least ) in assembly language using the BASIC assembler and thereby BASIC itself is usually used as a launch platform for the assembler. However what has been said has been noted. Something learnt today. @ Martin Will take a look at SideDiff & Compare ASAP but am quite busy over next few days. No problem in sending the code. Thank you very much. However if you need to run the code then it will be quite a lot larger as there are several support files it requires and therefore there will be a number of zips. As I understand it though you only need to see the effect of loading it into StrongED. Could you please confirm whether you need to RUN the code or not so I know what to send. Oh and one more thing. Please dont spend too much time on this as I am sure you are a busy man and as I said further up this thread I have managed to get around this curiosity. But it would be interesting to know if there is a way around this to save me or someone else having to spend a day and a half phaffing around like I did. I appreciate the time you are willing to spend as I am stumped Greg |
nemo (145) 2546 posts |
Clive wrote:
Put the DEFFNnamedthing(A%):LOCALN%,A$ RESTORE+1:REPEATREADN%,A$:UNTILA$=""ORA%=N%:=A$ DATA2,Company,3,Crowd,4,Soiré,5,Mob,0,"" DEFFNpolygon(A%):LOCALN%,A$ RESTORE+1:REPEATREADN%,A$:UNTILA$=""ORA%=N%:=A$ DATA1,Point,2,Line,3,Triangle,4,Quadrilateral,0,"" |
Clive Semmens (2335) 3276 posts |
Nemo – generally, yes, I can see that. If you use the same block of data again somewhere else in the program, not so easy. |
nemo (145) 2546 posts |
DEFPROCthisdata:RESTORE+1:ENDPROC DATA"O RLY?" |
Martin Avison (27) 1494 posts |
@ Greg: Just the source that is causing the SE oddity, please. |
Steve Drain (222) 1620 posts |
Just to clarify, that is not strictly accurate, although it has no practical implications. It might also be worth pointing out that the +parameter is the number of actual lines, not an addition to the current line number, so the line number increment is irrelevant. Just for nemo, Basalt makes |
Clive Semmens (2335) 3276 posts |
Nemo: yes, I can see ways around it. If you have to have ways around things, it’s worth thinking whether it’s just simpler to have line numbers. I’m 100% in agreement with getting rid of GOTO and GOSUB, and the implied GOTO in THEN and ELSE, but I don’t have any objection in principle to line numbers per se, and if they’re useful (as in error reports, or describing a program in another document) then I really don’t mind having them.
That seems pretty clear from the manual, and inescapable if you don’t actually have any line numbers! |
Martin Avison (27) 1494 posts |
But all (tokenised) BASIC programs contain line numbers. You and your editor may chose to display them or not. |
Clive Semmens (2335) 3276 posts |
Ah, fair enough. So it’s just as well the count in RESTORE+ is physical lines, not line numbers. Does that mean that library programs actually have line numbers too? Presumably it does… |
Steve Fryatt (216) 2105 posts |
It does, indeed. That’s why line numbers become increasingly meaningless as a concept. BASIC really doesn’t care about the line numbers, unless you’re referencing them. Once you get past the constraints of the line editor or |
Greg (2474) 144 posts |
Ive posted source for you Martin Greg |
Steve Drain (222) 1620 posts |
As Martin points out, you alway have them, but as Steve says, they are largely meaningless. David Feugey urged the use of labels instead of line numbers, so Basalt adds ‘tags’ that can be used with |
Clive Semmens (2335) 3276 posts |
Suits me!
Exactly. Nemo’s cunning trick with putting DATA along with a RESTORE in a PROC achieves the same effect, but using a PROC as a label like that is a lot clumsier than actually having a proper label. |
Martin Avison (27) 1494 posts |
After a quick scrummage through the source, I have found the cause of the original problem. Remember that THEN can have a line number after it? Line 13090 is an assembler line, which has at the end a comment something like I have had other oddities caused by the fact the SE tokenises keywords in comments. |
Pages: 1 2