?
Solved

File of records related question.

Posted on 2004-08-12
1
Medium Priority
?
243 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 200 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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