@@ -103,6 +103,8 @@ TSourceFileInfo = class(TObject)
103103 fFilterIdxToFileTypeMap: TDictionary<Integer,TSourceFileType>;
104104 // / <summary>Value of DefaultFileName property.</summary>
105105 fDefaultFileName: string;
106+ // / <summary>Value of <c>RequirePascalDefFileName</c> property.</summary>
107+ fRequirePascalDefFileName: Boolean;
106108 // / <summary>Filter string for use in open / save dialog boxes from
107109 // / descriptions and file extensions of each supported file type.
108110 // / </summary>
@@ -153,10 +155,18 @@ TSourceFileInfo = class(TObject)
153155 read GetFileTypeInfo write SetFileTypeInfo;
154156
155157 // / <summary>Default source code file name.</summary>
156- // / <remarks>Must be a valid Pascal identifier. Invalid characters are
157- // / replaced by underscores.</remarks>
158+ // / <remarks>If, and only if, <c>RequirePascalDefFileName</c> is
159+ // / <c>True</c> the default file name is modified so that name is a valid
160+ // / Pascal identifier.</remarks>
158161 property DefaultFileName: string
159162 read fDefaultFileName write SetDefaultFileName;
163+
164+ // / <summary>Determines whether any value assigned to
165+ // / <c>DefaultFileName</c> is converted to a valid Pascal identifier or
166+ // / not.</summary>
167+ property RequirePascalDefFileName: Boolean
168+ read fRequirePascalDefFileName write fRequirePascalDefFileName
169+ default True;
160170 end ;
161171
162172
@@ -178,6 +188,7 @@ constructor TSourceFileInfo.Create;
178188 inherited Create;
179189 fFileTypeInfo := TDictionary<TSourceFileType,TSourceFileTypeInfo>.Create;
180190 fFilterIdxToFileTypeMap := TDictionary<Integer,TSourceFileType>.Create;
191+ fRequirePascalDefFileName := True;
181192end ;
182193
183194destructor TSourceFileInfo.Destroy;
@@ -232,19 +243,24 @@ procedure TSourceFileInfo.SetDefaultFileName(const Value: string);
232243var
233244 Idx: Integer; // loops through characters of filename
234245begin
235- // convert to "camel" case
236- fDefaultFileName := StrStripWhiteSpace(StrCapitaliseWords(Value ));
237- // replaces invalid Pascal identifier characters with underscore
238- if (fDefaultFileName <> ' ' )
239- and not TCharacter.IsLetter(fDefaultFileName[1 ])
240- and (fDefaultFileName[1 ] <> ' _' ) then
241- fDefaultFileName[1 ] := ' _' ;
242- for Idx := 2 to Length(fDefaultFileName) do
243- if not TCharacter.IsLetterOrDigit(fDefaultFileName[Idx])
244- and (fDefaultFileName[Idx] <> ' _' ) then
245- fDefaultFileName[Idx] := ' _' ;
246- Assert((fDefaultFileName <> ' ' ) and IsValidIdent(fDefaultFileName),
247- ClassName + ' .SetFileName: Not a valid identifier' );
246+ if fRequirePascalDefFileName then
247+ begin
248+ // convert to "camel" case
249+ fDefaultFileName := StrStripWhiteSpace(StrCapitaliseWords(Value ));
250+ // replaces invalid Pascal identifier characters with underscore
251+ if (fDefaultFileName <> ' ' )
252+ and not TCharacter.IsLetter(fDefaultFileName[1 ])
253+ and (fDefaultFileName[1 ] <> ' _' ) then
254+ fDefaultFileName[1 ] := ' _' ;
255+ for Idx := 2 to Length(fDefaultFileName) do
256+ if not TCharacter.IsLetterOrDigit(fDefaultFileName[Idx])
257+ and (fDefaultFileName[Idx] <> ' _' ) then
258+ fDefaultFileName[Idx] := ' _' ;
259+ Assert((fDefaultFileName <> ' ' ) and IsValidIdent(fDefaultFileName),
260+ ClassName + ' .SetFileName: Not a valid identifier' );
261+ end
262+ else
263+ fDefaultFileName := Value ;
248264end ;
249265
250266procedure TSourceFileInfo.SetFileTypeInfo (const FileType: TSourceFileType;
0 commit comments