<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'saving records' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'saving records' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 22:50:28 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 22:50:28 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176467/saving-records/</link>
      <description>i have a program which deals with RECORDS file structure. Now i want to save the entries i obtained after running the program on a text file and be able to retrieve this data when i run the program again so that i dont need to retype and retype data everytime i run the program. Thanks in advance guys!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176467/saving-records/</guid>
      <pubDate>Fri, 14 Mar 2003 05:37:44 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176512/re-saving-records/#176512</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by sweeney at  2003-3-14 9:23:15&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: i have a program which deals with RECORDS file structure. Now i want to save the entries i obtained after running the program on a text file and be able to retrieve this data when i run the program again so that i dont need to retype and retype data everytime i run the program. Thanks in advance guys!&lt;br /&gt;
: &lt;br /&gt;
I did a reply but my code was all crap lol here is a better explamation!&lt;br /&gt;
&lt;br /&gt;
ok&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
var
 F : text;
 mystring : string;

begin
write(' Please enter a string: ');
readln(mystring);
assign(f, 'C:\test.txt');
rewrite(f);
writeln(f, mystring);
close(f)
end.
&lt;/pre&gt;&lt;br /&gt;
this will rewite your answer every time do this to make the file then change the rewrite() to reset() and that will allow you to do it over and over!&lt;br /&gt;
hope this helps! am just trying to find a way to read it now!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176512/re-saving-records/#176512</guid>
      <pubDate>Fri, 14 Mar 2003 09:22:20 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176586/re-saving-records/#176586</link>
      <description>: i have a program which deals with RECORDS file structure. Now i want to save the entries i obtained after running the program on a text file and be able to retrieve this data when i run the program again so that i dont need to retype and retype data everytime i run the program. Thanks in advance guys!&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
To save and Read a record, use the following:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
TYPE
    Person = record
       Name : String;
       Age  : Byte;
       Address : String;
    End;

VAR
   Bob : Person;

PROCEDURE Save(P : Person);
VAR
   F : File;
Begin
     Assign(F,'Save.Dat'); Rewrite(F,1);
     BlockWrite(F, P, SizeOf(P));
     Close(F);
End;

FUNCTION Load(VAR P : Person) : Boolean;
VAR
   NumRead : Word;
   Temp : Person;
Begin
     {$I-}
     Assign(F,'Save.Dat'); Reset(F,1);
     {$I+}
     If IOResult &amp;lt;&amp;gt; 0 Then
     Begin
          WriteLn('File Not Found!);
          Load := False;
          Exit;
     End;
     BlockRead(F, Temp, SizeOf(Temp),NumRead);
     Close(F);
     If NumRead &amp;lt;&amp;gt; SizeOf(Temp) Then
     Begin
          WriteLn('File Wrong Size!);
          Load := False;
          Exit;
     End;
     P := Temp;
     Load := True;
End;

Begin
     If Load(Bob) = False Then
     Begin
          Bob.Name    := 'Bob';
          Bob.Age     := 33;
          Bob.Address := '1234 ABC Drive';
          Save(Bob);
          WriteLn('Your info has been saved!);
     End
     ELSE
     Begin
          WriteLn('Your info has been loaded!);
          WriteLn('  Your name is :',Bob.Name);
          WriteLn('  Your age is  :',Bob.Age);
          WriteLn('  Your live at :',Bob.Address);
     End;
End.
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Anyways this is just an example. The Record passing to the procedures may not work (I didn't test it), but the Loading and Saving should be right.&lt;br /&gt;
&lt;br /&gt;
 hope this helps,&lt;br /&gt;
   Phat Nat&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176586/re-saving-records/#176586</guid>
      <pubDate>Fri, 14 Mar 2003 16:08:52 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176616/re-saving-records/#176616</link>
      <description>: To save and Read a record, use the following:&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: TYPE
:     Person = record
:        Name : String;
:        Age  : Byte;
:        Address : String;
:     End;
: 
: VAR
:    Bob : Person;
: 
: PROCEDURE Save(P : Person);
: VAR
:    F : File;
: Begin
:      Assign(F,'Save.Dat'); Rewrite(F,1);
:      BlockWrite(F, P, SizeOf(P));
:      Close(F);
: End;
: 
: FUNCTION Load(VAR P : Person) : Boolean;
: VAR
:    NumRead : Word;
:    Temp : Person;
: Begin
:      {$I-}
:      Assign(F,'Save.Dat'); Reset(F,1);
:      {$I+}
:      If IOResult &amp;lt;&amp;gt; 0 Then
:      Begin
:           WriteLn('File Not Found!);
:           Load := False;
:           Exit;
:      End;
:      BlockRead(F, Temp, SizeOf(Temp),NumRead);
:      Close(F);
:      If NumRead &amp;lt;&amp;gt; SizeOf(Temp) Then
:      Begin
:           WriteLn('File Wrong Size!);
:           Load := False;
:           Exit;
:      End;
:      P := Temp;
:      Load := True;
: End;
: 
: Begin
:      If Load(Bob) = False Then
:      Begin
:           Bob.Name    := 'Bob';
:           Bob.Age     := 33;
:           Bob.Address := '1234 ABC Drive';
:           Save(Bob);
:           WriteLn('Your info has been saved!);
:      End
:      ELSE
:      Begin
:           WriteLn('Your info has been loaded!);
:           WriteLn('  Your name is :',Bob.Name);
:           WriteLn('  Your age is  :',Bob.Age);
:           WriteLn('  Your live at :',Bob.Address);
:      End;
: End.
: &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
How will i modify the program because part of my code goes like this..&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
CONST

max= 50;

TYPE
:     Person = record
:        Name : String;
:        Age  : Byte;
:        Address : String;
:     End;
:     People = array(1..max) of person;
: VAR
      friends : people;


&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
my program should be able to save &amp;lt;tt&amp;gt;RECORD of friends&amp;lt;/tt&amp;gt; everytime i needed to (this might be before quitting the program or when the user calls the &amp;lt;tt&amp;gt;save function&amp;lt;/tt&amp;gt;) and retrieve the saved file (i need to save it on a &amp;lt;tt&amp;gt;*.txt&amp;lt;/tt&amp;gt; format) everytime i start the program. You're help Phat Nat is very well appreciated. Thanks.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176616/re-saving-records/#176616</guid>
      <pubDate>Fri, 14 Mar 2003 22:04:04 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176674/re-saving-records/#176674</link>
      <description>: : To save and Read a record, use the following:&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;pre class="sourcecode"&gt;
: : TYPE
: :     Person = record
: :        Name : String;
: :        Age  : Byte;
: :        Address : String;
: :     End;
: : 
: : VAR
: :    Bob : Person;
: : 
: : PROCEDURE Save(P : Person);
: : VAR
: :    F : File;
: : Begin
: :      Assign(F,'Save.Dat'); Rewrite(F,1);
: :      BlockWrite(F, P, SizeOf(P));
: :      Close(F);
: : End;
: : 
: : FUNCTION Load(VAR P : Person) : Boolean;
: : VAR
: :    NumRead : Word;
: :    Temp : Person;
: : Begin
: :      {$I-}
: :      Assign(F,'Save.Dat'); Reset(F,1);
: :      {$I+}
: :      If IOResult &amp;lt;&amp;gt; 0 Then
: :      Begin
: :           WriteLn('File Not Found!);
: :           Load := False;
: :           Exit;
: :      End;
: :      BlockRead(F, Temp, SizeOf(Temp),NumRead);
: :      Close(F);
: :      If NumRead &amp;lt;&amp;gt; SizeOf(Temp) Then
: :      Begin
: :           WriteLn('File Wrong Size!);
: :           Load := False;
: :           Exit;
: :      End;
: :      P := Temp;
: :      Load := True;
: : End;
: : 
: : Begin
: :      If Load(Bob) = False Then
: :      Begin
: :           Bob.Name    := 'Bob';
: :           Bob.Age     := 33;
: :           Bob.Address := '1234 ABC Drive';
: :           Save(Bob);
: :           WriteLn('Your info has been saved!);
: :      End
: :      ELSE
: :      Begin
: :           WriteLn('Your info has been loaded!);
: :           WriteLn('  Your name is :',Bob.Name);
: :           WriteLn('  Your age is  :',Bob.Age);
: :           WriteLn('  Your live at :',Bob.Address);
: :      End;
: : End.
: : &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: How will i modify the program because part of my code goes like this..&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: CONST
: 
: max= 50;
: 
: TYPE
: :     Person = record
: :        Name : String;
: :        Age  : Byte;
: :        Address : String;
: :     End;
: :     People = array(1..max) of person;
: : VAR
:       friends : people;
: 
: 
: &lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: my program should be able to save &amp;lt;tt&amp;gt;RECORD of friends&amp;lt;/tt&amp;gt; everytime i needed to (this might be before quitting the program or when the user calls the &amp;lt;tt&amp;gt;save function&amp;lt;/tt&amp;gt;) and retrieve the saved file (i need to save it on a &amp;lt;tt&amp;gt;*.txt&amp;lt;/tt&amp;gt; format) everytime i start the program. You're help Phat Nat is very well appreciated. Thanks.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Thank you, I try to help whenever I can.&lt;br /&gt;
Is there any particular reason why you need to save it as a .txt file?&lt;br /&gt;
Do you need to access it in an outside database because the file will be smaller when it is saved as data (in this case between 100-200 bytes) and the code for doing it is smaller (about 3-4 lines). If you can use the Data format, I would suggest it (as done above) otherwise this would be how you use it as text:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
CONST
    max= 50;

TYPE
    Person = record
       Name : String;
       Age  : Byte;
       Address : String;
    End;
    People = array(1..max) of person;
VAR
   friends : people;

PROCEDURE Save(Info : People);
Begin
     Assign(T, 'People.Txt'); Rewrite(T);
     For X := 1 to max Do
     Begin
          WriteLn(T, Info[X].Name);
          WriteLn(T, Info[X].Age);
          WriteLn(T, Info[X].Address);
     End;
     Close(T);
End;

PROCEDURE Load(Info : People);
Begin
     Assign(T, 'People.Txt');
     {$I-}  Reset(T);  {$I+}
     If IOResult &amp;lt;&amp;gt; 0 then
     Begin
          WriteLn('File not found!');
          Exit;
     End;
     For X := 1 to max Do
     Begin
          ReadLn(Info[X].Name);
          ReadLn(Info[X].Age);
          ReadLn(Info[X].Address);
          If EOF(T) Then Break;   { In case the file isn't long enough }
     End;
     Close(F);
End;

Begin        {Used like this:}
     Load(People); 
     Save(People);
End.
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This is how it would be done. The only problam with doing it as text (as you may be able to see) is that if you have 100 different variables in your record, it would take a LONG time to write out all the WriteLn(...); lines. Anyways, hope this helps.&lt;br /&gt;
&lt;br /&gt;
   Phat Nat&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176674/re-saving-records/#176674</guid>
      <pubDate>Sat, 15 Mar 2003 10:01:14 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: saving records</title>
      <link>http://www.programmersheaven.com/mb/pasprog/176467/176757/re-saving-records/#176757</link>
      <description>I'll try that Phat Nat. Thanks a lot again. =)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/176467/176757/re-saving-records/#176757</guid>
      <pubDate>Sat, 15 Mar 2003 22:35:37 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>