Compile error: "Illegal unit name md2xhtmlu".
lazarus / 61-Beginners
----------------------------------------------------------------------
bulrush · 2016-07-02 16:10
Freepascal 3.0.0 and Lazarus 1.6.0
I'm making another new unit. The filename is md2xhtmlp.pas. The unit
name is: "Unit mdtoxhtmlu;". This class contains one class, namely
Tmd2xhtml. Here's all the code with and above 'implementation'.
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i Unit
mdtoxhtmlu; {$mode objfpc}{$H+} interface uses Classes, SysUtils,
FileUtil, Regexpr; type { Tmd2xhtml } Tmd2xhtml = class(TObject)
private FMdFilename: string; FXhtmlFilename: string; var
FMdText: string; var FXhtmlText: String; function
GetMdFilename: string; function GetMdText: string; function
GetXhtmlText: string; procedure SetMdfilename(AValue: string);
procedure SetMdText(AValue: string); procedure
Setxhtmlfilename(AValue: string); procedure SetXhtmlText(AValue:
string); tslMD:Tstringlist; // Markdown as TStringList.
tslPOS:integer; //Current line in tslMD.strings[]. 0-based.
mdcurline:string; //One line from tslMD. lastHdrId:integer;
//Every header needs a different id. This part is sequential.
function GetOneLine:string; //Get one line to check if it's a
bullet, para, etc. function Procpara:string; //Get all lines up to
next blank line. function ProcUnnumBullet(ins:string):string;
//Process unnumbered bullets function
ProcNumBullet(ins:string):string; //Process numbered bullets.
public constructor Create; destructor Destroy; override;
property MdText: string read GetMdText write SetMdText; //Markdown
for input property XhtmlText: string read GetXhtmlText write
SetXhtmlText; //XHTML for output. property MdFilename: string read
Fmdfilename write Setmdfilename; //Read/write. property
XhtmlFilename: string read Fxhtmlfilename write Setxhtmlfilename;
end; //end Tmd2xhtml implementation { Tmd2xhtml } //Many procedures
removed from here. end. //unit end
At first I thought the unit name didn't like numbers. Then I thought
the unit name was limited to 8 characters, but I still get the same
error whether I take out the digit from the unit name or limit the
unit name to 8 characters.
What is wrong here? What is the limit on unit names?
The wiki entry for units (http://wiki.freepascal.org/Unit) does not
mention if the .pas filename has to match the unit name.
Thank you! I'm still learning here.
----------------------------------------------------------------------
molly · 2016-07-02 16:13
Unit name must match file name on disk.
----------------------------------------------------------------------
bulrush · 2016-07-02 16:21
It worked! Thanks.
----------------------------------------------------------------------
molly · 2016-07-02 16:29
Congratz
if not mentioned explicitly then it might be that this restriction is
perhaps not true for all supported platforms. Just guessing, as i do
not know for sure that is the reason.