Lazarus

Free Pascal => Beginners => Topic started by: MrPink on May 30, 2025, 04:30:02 am

Title: Accessing A Previous-Iteration File – Having Code That Runs
Post by: MrPink on May 30, 2025, 04:30:02 am
Back in December, I was on the forum -- dabbling with learning Lazarus. And several good folks helped me out. Handoko, among others.

I college-learned TP in an earlier life (1985), and hobby-programmed thru 2018. Then, I largely went dormant until last summer. Anyway, in the wake of that recent experience, I learned that I don’t truly program enough to warrant the Lazarus learning time leap. Basically, I’ve settled into using the text-mode IDE. In a no-fuss limited way, it’s convenient and, that MO works for me.

So, I’m hopeful that despite wallowing in the old, I can periodically roll in and get a question or two answered here on the forum. Sharing an issue that beached me today. I am currently wrestling with a 201 runtime error -- which is thoroughly frustrating in itself. The editor auto-saves that crippled file, and I have no access to what would be the very helpful prior-file. As in the one that worked before my added code made it not work......

It strikes me that in future I could do a periodic save-as; forever naming my good ‘working’ file differently. However, that method seems obtuse – like maybe the editor design really has a better way (???). As an old dog trying to rekindle old tricks -- am I missing something?
Thank you,
Mr. Pink
FPC 3.2.2
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: cdbc on May 30, 2025, 09:48:31 am
Hi
Wow, I've become real rusty in the tui-ide...  ;D
But here goes, below you'll see a 'fp.ini' file from my installation:
Code: INI  [Select][+][-]
  1. [Compile]
  2. CompileMode=DEBUG
  3.  
  4. [Editor]
  5. DefaultTabSize=8
  6. DefaultFlags=20599
  7. DefaultSaveExt=.pas
  8. DefaultIndentSize=1
  9.  
  10. [Highlight]
  11. Exts="*.pas;*.pp;*.inc"
  12. NeedsTabs="make*;make*.*"
  13.  
  14. [SourcePath]
  15. SourceList=""
  16.  
  17. [Mouse]
  18. DoubleDelay=8
  19. ReverseButtons=0
  20. AltClickAction=6
  21. CtrlClickAction=1
  22.  
  23. [Search]
  24. FindFlags=4
  25.  
  26. [Breakpoints]
  27. Count=0
  28.  
  29. [Watches]
  30. Count=0
  31.  
  32. [Preferences]
  33. DesktopFileFlags=209
  34. CenterCurrentLineWhileDebugging=1
  35. # HERE v #
  36. AutoSaveFlags=7
  37. MiscOptions=6
  38. DesktopLocation=1
  39.  
  40. [Misc]
  41. ShowReadme=0
  42.  
  43. [Keyboard]
  44. EditKeys=microsoft
  45.  
  46. [Files]
  47. OpenExts="*.pas;*.pp;*.inc"
  48. PrinterDevice=prn
  49.  
  50. [Tools]
  51. Title1="svn ~u~p (curr. dir)"
  52. Program1="svn"
  53. Params1="up $CAP_MSG()"
  54. HotKey1=23296
  55. Title2="svn c~i~ (curr. dir)"
  56. Program2="svn"
  57. Params2="ci $CAP_MSG()"
  58. HotKey2=23552
  59. Title3="svn ~d~iff"
  60. Program3="svn"
  61. Params3="diff $CAP_MSG() $EDNAME"
  62. HotKey3=23808
  63. Title4="svn ~l~og"
  64. Program4="svn"
  65. Params4="log $CAP_MSG() $EDNAME"
  66. HotKey4=34560
  67. Title5="svn ~b~lame"
  68. Program5="svn"
  69. Params5="blame $CAP_MSG() $EDNAME"
  70. HotKey5=34816
  71. Title6="svn ~a~dd"
  72. Program6="svn"
  73. Params6="add $CAP_MSG() $EDNAME"
  74. HotKey6=0
  75.  
...Maybe you could fiddle with the "Autosave" parameter, to remedy your predicament...?
Regards Benny
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: cdbc on May 30, 2025, 09:58:48 am
Hi again
You can also find the above in menu -> 'Options' -> 'Environment' -> 'Preferences' in the 'fp' IDE...
Regards Benny
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: MrPink on May 30, 2025, 04:10:08 pm
Benny,
Thanks for your input. In my first go-round on the forum (Dec), I got the unfortunate sense that few participants are non-Lazarus. Perhaps 5/10 percent? That certainly lowers my future success rate for having helpers that are familiar. I presume that most everyone here was formally-trained on Lazarus after it came into being (2014). Or, many were ‘professionally’ motivated to spend the time to learn a new good editor.

Back to the salt mine. I did pursue your tip of -> 'Options' -> 'Environment' -> 'Preferences. However, no luck. That formal menu shows an X at the Auto Save desktop option. I removed that X, but it doesn’t take, even after a shut and restart of the program. It’s like working on a 1956 Buick sans any resources.

Related, my relationship with Pascal has always been extremely fraught, based on those aforementioned runtime errors. For me, they’re like (expletive) Darth Vader! Save for inserting writelns in the difficult cure pursuit, I have no satisfying method to remedy that scenario. For example, if my current crippled program can’t be cured – I will need to scrap it and start anew.

It's frustrating, to the point of my having a much liked hobby – that doesn’t particularly like me.
Thank you,
Mr. Pink
FPC 3.2.2
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: cdbc on May 30, 2025, 04:27:10 pm
Hey MrPink
No need to be so "Gloomy Gus"  ;D
I've been doing pascal since TP 3.0, back in the 80's and the pascal from then, can still be compiled and run.
Just like many here in the forum, I just followed the progress in pascal features and IDE's and have now landed in Lazarus / Fpc.
You can do practically anything in the fp-ide (TUI), that your heart desires...
But alas, I have forgotten most of the tricks in the textmode-IDE.
Anyway, I'd disable the autosave mechanism and remember to save myself...
Did you remember to save the fp.ini, when you changed preferences?!?
-> menu -> 'Options' -> 'Save'(fp.ini)
Regards Benny
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: Handoko on May 30, 2025, 04:53:51 pm
I am currently wrestling with a 201 runtime error -- which is thoroughly frustrating in itself.

I believe many programmers will agree with me, 201 runtime error is one of the easiest-to-fix bug. I dealt with it often in the past. Post the source code here, we are able to help you. Or if you want, you can send it to me, I'll be glad to fix it for you.
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: MrPink on June 01, 2025, 11:47:43 pm
Gloomy Gus? You are correct -- a Pink dive too low for the circumstance. The upside is having the forum provide a get-out-of-jail card on future issues (runtime errors, etc.). Having such expert help is huge. Thank you for that......

Fessing up; I did not do the fp.ini (scared to screw up something with no future recourse). However, I will do that in future and report on that save-file issue.

Short term, I’ll focus on my latest runtime error (201). I will attempt a first-time attach of my source code and see if it takes; to the point of getting some kindly help on same.
Thank you,
Mr. Pink
FPC 3.2.2
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: cdbc on June 02, 2025, 12:40:15 am
Hey MrPink
I took the liberty of changing a little bit in your code:
Code: Pascal  [Select][+][-]
  1. {******************************************************************************************}
  2. BEGIN  {GENERIC}
  3.   (* NOTE: Your arrays go from 1 to 1200 *)
  4.   FOR x := -22 to 12 DO    {zero out SM matrix}
  5.     BEGIN
  6.       (* so you can either do the following to zero them *)
  7.       SM[x+23] := 0; w[x+23] := 0; l[x+23] := 0;
  8.     END;
  9.   (* OR you can do this:
  10.   for x:= 1 to 35 do
  11.     begin
  12.       SM[x]:= 0; w[x] := 0; l[x] := 0;
  13.     end;
  14.   *)
  15.   lastyear := 116;     {adjust manually for each run}
  16.   FOR year := 124 downto lastyear DO
  17.     BEGIN
  18.       Assignfile (year, filename);
  19.       assign (infile, filename); reset (infile);
  20.       num := 0;
  21.       WHILE NOT eof (infile) DO
  22.         BEGIN  {WHILE}
  23.           readln (infile, ateam, hteam, ascore, hscore, spread, d, TV);
  24.           IF (ateam<197) AND (hteam<197) AND (ABS(spread)<100.0) THEN  {add to matrix}
  25.             BEGIN
  26.               num := num + 1;  {REMEMBER -- spread points to AT not HT} {proceed with regular HT regimen}
  27.               cs := -spread;   {cs = converted spread = points to HT}
  28.               LC := LineCell(cs);
  29.               write (year,'/');
  30.             {  SM[LineCell] := 6;
  31.               w[LineCell] := 6;
  32.               l[LineCell] := 6; }
  33.             END
  34.         END;  {WHILE}
  35.       write (year,'/');
  36.       close (infile);
  37.      { IF year = lastyear THEN writeln (lastyear) ELSE write (year,'/'); }
  38.  
  39.     END;  {FOR}
  40. END.  {GENERIC}      
Just in the main body, I left the functions and procedures alone...
Regards Benny
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: MrPink on June 02, 2025, 12:12:27 pm
Benny,
Your wise input was the ticket!  Thank you. Tunnel vision on my part, to not-see the array range discrepancy. Isn’t that always the case though? Viewing in the micro or macro, just enough to be cause-blinded....

For the record, I started with a carryover program that held the 1 to 1200 range, when I more-specifically needed the -22 to 12 range.

Now fixed and moving on – until the next challenge comes along. Said above, the forum is an active godsend for me in terms of genuine helpfulness and confidence.
Thank you,
Mr. Pink
FPC 3.2.2
Title: Re: Accessing A Previous-Iteration File – Having Code That Runs
Post by: Handoko on June 03, 2025, 06:38:24 pm
If you understand what a 201 error is, you should able to fix the bug yourself.

 --------------------
201 Range check error


If you compiled your program with range checking on, then you can get this error in the following cases:
--------------------
Source: https://www.freepascal.org/docs-html/user/userap4.html (https://www.freepascal.org/docs-html/user/userap4.html)

Most errors listed in the link above are relatively easy to be solved. Error 201 and 200 probably are the most common errors made by beginners.
TinyPortal © 2005-2018