* * *

Recent Posts

Pages: [1] 2 3 ... 10
1
General / Re: need help with calender
« Last post by rhong7 on Today at 12:41:32 pm »
Code: Pascal  [Select]
  1. procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  2. begin
  3.   if fileexists('highscore.dat') then
  4.   begin
  5.    while not eof(highscorefile) do
  6.     begin
  7.     for i:=1 to 10 do
  8.     write(highscorefile, rank[i]);
  9.     end;
  10.   end;
  11. end;
  12.  
  13.  
  14. procedure TForm1.FormCreate(Sender: TObject);
  15. begin
  16.   edit1.clear;
  17.   edit2.clear;
  18.   assignfile(highscorefile, 'highhscore.dat');
  19.   if not fileexists('highhscore.dat') then
  20.   begin
  21.     rewrite(highscorefile);
  22.     closefile(highscorefile);
  23.   end;
  24.  
  25.  
  26.  
  27.   if fileexists('highscore.dat') then
  28.   begin
  29.    while not eof(highscorefile) do
  30.     begin
  31.     for i:=1 to 10 do
  32.     read(highscorefile, rank[i]);
  33.     end;
  34.   end;
  35.   for i:=1 to 10 do
  36.   if rank[i].score <> 0 then
  37.    begin
  38.     sgdata.Cells[1,i]:=rank[i].name;
  39.     sgdata.cells[2,i]:=inttostr(rank[i].score);
  40.    end;
  41.   end;                            

like this?
2
General / Re: Dealing with STDOUT with ProcThreadPool.DoParallel
« Last post by molly on Today at 12:26:19 pm »
Could someone please tell me what have I done wrong?  :-\
No idea. Are you saying that the snippet you pasted gives you distorted output ?

It should work, at least it does for me.

Do note that i don't manually open output though, i just use writeln.

Are you perhaps writing to output at another location (and forgot about it) ?
3
General / Re: need help with calender
« Last post by rvk on Today at 12:23:08 pm »
Ok.

You have a "if not fileexists('highhscore.dat') then"
You need to add the same (or use else) for "if fileexists".

In that case you just open the file and loop through the file with an "while not EOF" (you learned that earlier) in that other topic and fill in rank until you get to 10.

At FormClose you do the same but for writing.

(The reason you need to do a while loop in the beginning is so you make sure when you have less then 10 records in the file, you don't crash. Writing only 10 records shouldn't be a problem because you don't care about anything other than the first 10. Or do you?)

also the score is all 0 but i just want them to be invisible
Just don't fill the StringGrid if the value is 0 for that rank.

oh and also when click the button the name becomes Form1 instead of the on i typed.
That's because you didn't use the parameter Namee to fill the new score-rank but the variable Name (which is the caption of the form).

Now you also see it is best not to use variable which can be confused with properties of another component (like the form). So Name, Width, Top, Left are all names of your own-variables you need to avoid.
4
You must have had a mixup of versions. TStringHashList used to be in lcl before version 1.8 and got the strings from lclstrconsts. Now it is in components/lazutils and uses the strings from lazutilsstrconsts as GetMem writes. So, if you run Lazarus 1.8RC but find TStringHashList in lcl your installation somewhere must have had a path pointing to the wrong directory.

Yes, reinstallation of into a clean directory and a clean user profile folder is usually the quickest way to solve these issues.
5
General / Re: need help with calender
« Last post by rhong7 on Today at 12:19:45 pm »
oh and also when click the button the name becomes Form1 instead of the on i typed.
6
General / Re: need help with calender
« Last post by rhong7 on Today at 12:17:42 pm »
also the score is all 0 but i just want them to be invisible
7
General / Re: need help with calender
« Last post by rhong7 on Today at 12:15:45 pm »
yupp everything works perfect, but when i close it and compile it again nothing is on the scoreboard
8
I uninstalled 1.8 and reinstalled it and the problem went away.

9
General / Re: need help with calender
« Last post by rvk on Today at 12:00:09 pm »
You have a read on the file in FormCreate before you even opened the file.

For now first forget about reading and writing (just remove that first line in FormCreate) and see of the rest of the code works.
10
You need lrsListMustBeEmpty instead of rsListMustBeEmpty, declared in unit LazUtilsStrConsts.
Pages: [1] 2 3 ... 10

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus