Solved

File of records related question.

Posted on 2004-08-12
1
221 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
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now