Recent

Author Topic: what could be going on with this?  (Read 1741 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
what could be going on with this?
« on: May 31, 2019, 08:24:17 am »
The apt.txt file is at X:\

There is something going on I don't understand.

I renamed the apt.txt file to Tapt.txt.
Then created a  empty text file with Notepad called apt.txt.
Copied the contents of Tapt.txt to the new apt.txt and it worked.

The attributes on the file were Read Only = bank and Hidden = Blank.

 
 




Code: Pascal  [Select][+][-]
  1.  procedure TForm1.FormCreate(Sender: TObject);
  2.   var valid : boolean;
  3.       Loc : String = '';
  4.       FileName :String;
  5.   begin
  6.    Loc := 'X:\apt.txt';
  7.    form1.caption := Loc;
  8.    valid := fileexists(Loc);     <---     returns False;
  9.    ListBox1.Clear;
  10.    ListBox1a.Clear;
  11.    ListBox2.Clear;
  12.    ListBox3.Clear;
  13.    ListBox4.Clear;
  14.    ListBox5.Clear;
  15.    ListBox6.Clear;
  16.    LoadAllListBoxes;
  17.    ListBox7.Clear;
  18.   end;        


Code: Pascal  [Select][+][-]
  1. Procedure TForm1.PreProcessAptDotDat(aFile : String);
  2.    Var
  3.     DataFile    : TextFile;
  4.     LineIn      : ANSIString    = '';
  5.      Begin
  6.      Listbox2.Clear;
  7.      Valid := FileExists(aFile);
  8.      if Not Valid then begin exit; end;
  9.       AssignFile(DataFile, aFile);
  10.      try
  11.       Reset(DataFile);
  12.       while not eof(DataFile) do begin
  13.         Readln(DataFile, LineIn);
  14.         LineIn := Trim(LineIn);
  15.         Listbox2.Items.Add(LineIn);
  16.       end;{end While Loop}
  17.       CloseFile(DataFile);
  18.      except  on E: EInOutError do  begin  ShowMessage('Error with: ' + 'apt.Dt'); end;
  19.     end;
  20.    end;  
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: what could be going on with this?
« Reply #1 on: May 31, 2019, 01:07:55 pm »
do you really have a drive on your system labeled X: ?
The only true wisdom is knowing you know nothing

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: what could be going on with this?
« Reply #2 on: May 31, 2019, 05:26:01 pm »
Yea, My kid saw somewhere on the web where they were selling SSD's  for 100 bucks so we bought two. They were Intel SSD.

I'm not sure why he named it X: So now I have a C:, D:, E:, F:, K: and X:
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

BeniBela

  • Hero Member
  • *****
  • Posts: 906
    • homepage
Re: what could be going on with this?
« Reply #3 on: May 31, 2019, 06:46:14 pm »
I used to install all my programs under P:\ and my user data under U:\

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: what could be going on with this?
« Reply #4 on: June 01, 2019, 02:05:58 am »
How about this?  :)

Code: Pascal  [Select][+][-]
  1. Function TwndGUI.LoadAptDotDat
  2. (strFile: String; Out strOut: String; booTrim: Boolean): Boolean;
  3. Var
  4.  fs : TFileStream;
  5.  str: String;
  6.  
  7.  iBytes, iRetry: Integer;
  8. Begin
  9.   Try
  10.    Result:= False;
  11.     If Not FileExists(strFile) Then Exit;
  12.    fs:= TFileStream.Create(strFile, fmOpenRead);
  13.     Try
  14.      SetLength(str, fs.Size);
  15.      iRetry:= 0;
  16.       While True Do
  17.        Begin
  18.         Try
  19.          iBytes:= 0;
  20.          iBytes:= fs.Read(str[1], fs.Size);
  21.           If iBytes = fs.Size
  22.           Then
  23.            Begin
  24.              If booTrim Then Trim(str);
  25.              strOut:= str;
  26.              Result:= True; // Success
  27.              Break;
  28.            End;
  29.         Except
  30.          On E: Exception Do
  31.           Begin
  32.            Inc(iRetry);
  33.            If iRetry = 11 Then Raise; // try 10 times
  34.           End;
  35.         End;
  36.        End;
  37.     Finally
  38.      fs.Free;
  39.     End;
  40.   Except
  41.    On E: Exception Do ShowMessage
  42.    ('Error LoadAptDotDat'+sLineBreak+E.ClassName+slineBreak+E.Message);
  43.   End;
  44. End;

Can be used like this for example ...
Code: Pascal  [Select][+][-]
  1. procedure TwndGUI.Button1Click(Sender: TObject);
  2. var
  3.  strFileName, strLoadedFile: String;
  4. begin
  5.   strFileName:= Application.Location+'MyText.txt';
  6.  
  7.   If LoadAptDotDat(strFileName, strLoadedFile, True)
  8.   Then ListBox1.Items.Add(strLoadedFile)
  9.   Else ShowMessage('Failed'); // or do something else ...
  10. end;
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: what could be going on with this?
« Reply #5 on: June 01, 2019, 08:48:39 am »
I used to install all my programs under P:\ and my user data under U:\

Not a bad idea.
In my cse I would need an E: driver for errors and a F: drive for Failures.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: what could be going on with this?
« Reply #6 on: June 01, 2019, 10:00:37 am »
In my cse I would need an E: driver for errors and a F: drive for Failures.
Then I would loose my features drive.....
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: what could be going on with this?
« Reply #7 on: June 01, 2019, 04:35:57 pm »
@RAW

Don't see my post. Wow downloaded the routines a nd try them out.Thanks.
« Last Edit: June 01, 2019, 04:38:10 pm by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018