[Lazarus] Assign not working on text files (fwd)

Michael Van Canneyt michael at freepascal.org
Mon Nov 10 08:52:58 CET 2014


Hello,

Sent to me, but I am forwarding it to the list because it contains a question for everyone.

There is no global class chart, to my knowledge. 
The FPC docs have a chart, but it only covers non-visual components (essentially, the FCL classes).
With fpdoc there is a tool that creates a class chart in postscript (fpclasschart).

Michael.

---------- Forwarded message ----------
Date: Sun, 9 Nov 2014 19:45:46 +0000 (UTC)
From: Stefanos Beligiannis <smpel at yahoo.com>
To: Michael Van Canneyt <michael at freepascal.org>
Subject: Re: [Lazarus] Assign not working on text files

Thank you Michael,
Thank you Bart,

The problem solved with your advice.
Another problem issued below, (I didn't mention it) with a close(f) solved also by changing it to closefile(f)

Michael thank you because you explanation made me understand better what's in it.

I have to study the classes carefully to develop in Lazarus and it would be very helpful that diagram of the classes which I can't find it to download.

Any way does anybody has tried to program platforms like AutoCAD and ArcGIS through Lazarus? As new in Lazarus I would appreciated any opinion on using dll libraries.

Brgds
Stefanos
 

_______________________________________________________________________________________________________________________________________________________________________________
From: Michael Van Canneyt <michael at freepascal.org>
To: Lazarus mailing list <lazarus at lists.lazarus.freepascal.org>
Cc: Stefanos Beligiannis <smpel at yahoo.com>
Sent: Sunday, November 9, 2014 5:50 PM
Subject: Re: [Lazarus] Assign not working on text files





On Sun, 9 Nov 2014, Bart wrote:

> On 11/9/14, Stefanos Beligiannis <smpel at yahoo.com> wrote:
>
>> If somebody has met this problem please advise.
>> ----------------code var    f : text;
>>    fn,nam : string;
>>
>> begin
>>      fn:=Edit2.Caption;
>>      {$I-}
>>      assign(f,fn);
>>      if (not FileExists(fn)) then Rewrite(f) else Append(f);
>>      {$I+}----------------- end codecompiler error
>> report-----------------  startk2u.pas(92,18) Error: Wrong number of
>> parameters specified for call to "Assign"k2u.pas(93,44) Hint: Local variable
>> "f" does not seem to be initialized----------------- end
>> use Lazarus # 1.2.6
>>
>>
>>
>
> Use TextFile instead of Text, use AssignFile instead of Assign.
> Alternatively prepend both Text and Assign with system. (note the dot!).


Explanation:

The code most likely is inside a TForm. TForm descends from TPersistent.
TPersistent has a .Assign() method, which is totally unrelated to the Assign() of the system unit.

When compiling your code, the compiler needs to know which Assign() to use.
It finds first the TPersistent.Assign, stops searching and gives an error
because it has different arguments from the system version.

By prepending your "text" and "assign" with system: system.text, system.assign,
the compiler does not search in TPersistent and finds the correct routines.

Michael.




More information about the Lazarus mailing list