Solved

File of records related question.

Posted on 2004-08-12
1
232 Views
Last Modified: 2010-04-05
Hi,

i just need some information regarding a file of records.

U see i have this record type :
TGsmRecord = record
  DateAdded : TdateTime;
  GsmNumber : String[25];
 end;

and a file of TGsmRecord where i save all my TGsmrecords in. and i just do Write(File,TgsmRecordVar);
I noticed each record takes up 40 bytes in the file. When i looked at the file i noticed something about the Shortstring Gsmnumber.
1.K.v..@.0111111111ewList....`..`C..,... is one record in the file where Gsmnumber equaled 0111111111 (10 chars). Notice the text after the 0111111111 part, it says "ewList" which comes from viewlist which is part of a name used for one of my controls in the program (a listview).

I like to know if this is normal ? it's probably because The shortstring has always a static length. But i find it weird that when i load up my records from the file again. The number is recognized as just 0111111111. and the "Garbage" doesn't affect my records / program at all.

I just like to know if it would ever make my program crash or sumthing or make the loaded Gsmnumber have a diffrent value from the one saved into the file due to the garbage.

0
Comment
Question by:joyrider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
LRHGuy earned 50 total points
ID: 11784898
it's normal for there to be uninitialized "trash" in records, unless you initialize them...

Before saving, try something like:

var
  R:tGsmRecord;
begin
  fillchar(R,sizeof(R),0);  //clear out record
  R.Dateadded:=  //put in date
  GSMNumber:= //put in number
  write(File,R);  //save to file
end
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 48
Delphi 2 77
Tidtcpserver listening on multiports? 1 45
Firemonkey BASS_Init into a thread 17 55
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question