Quantcast
Channel: 'Data Storage and Reproduction Cont.' Thread RSS Feed
Viewing all articles
Browse latest Browse all 8

Re: Data Storage and Reproduction Cont.

$
0
0
: :
: : USES Crt, Dos;
: : CONST
: :      Numbers : Array[0..35] Of Char =
: :       ('0','1','2','3','4','5','6','7','8','9','A','B',
: :        'C','D','E','F','G','H','I','J','K','L','M','N',
: :        'O','P','Q','R','S','T','U','V','W','X','Y','Z');
: : 
: : VAR
: :    Year     : Word;
: :    Month    : Byte;
: :    Day      : Byte;
: :    Hour     : Byte;
: :    Minute   : Byte;
: :    Second   : Byte;
: :    TempS    : String;
: :    FileName : String;
: : 
: : Begin
: :      ClrScr;
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,5);Write('Enter Year   : '); ReadLn(Year);
: :      Str(Year MOD 100,TempS);
: :      If Length(TempS) < 2 Then TempS := '0'+TempS;
: :      FileName := TempS;
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,6);Write('Enter Month  : '); ReadLn(Month);
: :      FileName := FileName + Numbers[Month];
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,7);Write('Enter Day    : '); ReadLn(Day);
: :      FileName := FileName + Numbers[Day];
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,8);Write('Enter Hour   : '); ReadLn(Hour);
: :      FileName := FileName + Numbers[Hour];
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,9);Write('Enter Minute : '); ReadLn(Minute);
: :      Str(Minute,TempS);
: :      If Length(TempS) < 2 Then TempS := '0'+TempS;
: :      FileName := FileName + TempS;
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      GotoXY(1,10);Write('Enter Second : '); ReadLn(Second);
: :      FileName := FileName + Numbers[Second DIV 2];
: : 
: :      GotoXY(1,1); WriteLn('Filename = "',FileName,'.DAT"');
: :      Readkey;
: : End.
: : 

: :
: : Hope this isn't too confusing.
: : Phat Nat
:
: Alright, a few things Im not to clear about...
:
: I think what you say about hexadecimals and creating a numerical system using all the letters of our alphabet is fairly straightforward. I had, however, difficulty translating some of your ideas into code simply because I dont understand some basic commands:
:
:
: Str(Year MOD 100,TempS);
: 

:
: I know what Str does, but MOD 100 doesnt mean much to me. The help system didnt help simply because it has verious subdefinitions of mod and i didnt know which one too look up.
: Consequently, Im also not too sure what your using TempS for.
:
: Also, is there any way to perhaps get the answers to your questions, ie (time, date) from the computer instead of having to manually tip them in?
:
: Finally, where in you program would i find space for ASSIGN(F, Filename.TXT).. How would I even use progper code to tell TP that Filename is the name of my TXT file.
:
: thanks soo much!
: NinthAngle

Hey. The reason I'm using the MOD function is because I want a 2-digit year, not a four digit year. So, If I use YEAR MOD 100, it will only give me the part of the year that's under 100. As Zibadian said it's the modulas. Take 235 for example. If you divide 235 by 50, you get 4.7
So the whole part (4) is what DIV would give you. 4*50 = 200, so MOD would give you 235-200 = 35.

The TempS is used because if I did:
Str(Minute,FileName);

It would erase everything that's already in the Filename string. This way I can just add the TempS onto the end of the FileName string.
*NOTE* I didn't really need to use the TempS for the Year variable, I just did it for conformity.

As for getting the date & time from the system, you already learned how to get the time and the date is the same, but with the GetDate() function. The filename would just need to be opened using the FILENAME string that we created.

Phat Nat


Viewing all articles
Browse latest Browse all 8

Trending Articles