Here is the code:
namespace VSDS.Data.Columns;
interface
uses
System.Collections.Generic;
type
ColumnList = class
public
fColumnList : List<String>;
constructor;
function GetColumnList( includeID : Boolean := False ) : String;
function GetColumnList( prefix : String; includeID : Boolean := False ) : String;
function GetColumnParameters( paramChar : Char; includeID : Boolean := False; includeName : Boolean := True ) : String;
procedure InitColumnList; virtual;
procedure Remove( fieldname : string );
end;
implementation
constructor ColumnList;
begin
fColumnList := new List<String>;
InitColumnList;
end;
method ColumnList.InitColumnList;
begin
// just a stub
end;
method ColumnList.GetColumnList(includeID: Boolean := false);
begin
result := GetColumnList( '', includeID );
end;
method ColumnList.GetColumnList(prefix: String; includeID: Boolean := false);
var
s : String;
I : Integer;
name : String;
LeftBracket : String := '[';
RightBracket : String := ']';
begin
if prefix.Length > 0 then begin
LeftBracket := '';
RightBracket := '';
end;
if includeID
then s := prefix + LeftBracket + 'ID' + RightBracket
else s := '';
for I := 0 to fColumnList.Count-1 do begin
name := fColumnList[I];
if length( s ) = 0
then s := s + prefix + LeftBracket + name + RightBracket
else s := s + ', ' + prefix + LeftBracket + name + RightBracket;
end;
result := s;
end;
method ColumnList.GetColumnParameters(paramChar: Char; includeID: Boolean := false; includeName: Boolean := true);
var
s : String;
I : Integer;
name : String;
function IncludedName : String;
begin
if includeName
then result := '[' + name + '] = '
else result := '';
end;
begin
name := 'ID';
if includeID
then s := IncludedName + paramChar + 'ID'
else s := '';
for I := 0 to fColumnList.Count-1 do begin
name := fColumnList[I];
if length( s ) = 0
then s := s + IncludedName + paramChar + name
else s := s + ', ' + IncludedName + paramChar + name;
end;
result := s;
end;
method ColumnList.Remove(fieldname: string);
begin
var index := fColumnList.IndexOf( fieldname );
if &index < 0 then exit;
fColumnList.RemoveAt( &index );
end;
end.
Here is a compiler error:
c:\Users\Mark\documents\visual studio 2013\Projects\VSDSRest\VSDSRest.Web\App_Code\Database\DatabaseColumnLists.pas(33,4): error E52: (E52) Type "ColumnList" does not contain a declaration that matches this method signature: method ColumnList.GetColumnList(includeID: Boolean)
Not sure why it is complaining. The hyperlink goes to:
method ColumnList.GetColumnList(includeID: Boolean := false);
begin
result := GetColumnList( '', includeID );
end;
And it kind of grays out the first 4 characters of that first line, which means 3 blanks and the “m”?
I don’t know why it is confused. I copied this code from another solution that compiles fine (though I’m not sure if it has the red line problem.)
… time passes …
And another odd compiler error is this one:
Warning 15 (N7) Potential overload: method ColumnList.GetColumnList(prefix: String; includeID: Boolean): String c:\Users\Mark\documents\visual studio 2013\Projects\VSDSRest\VSDSRest.Web\App_Code\Database\DatabaseColumnLists.pas 35
Warning 16 (N7) Potential overload: method ColumnList.GetColumnList(prefix: String; includeID: Boolean) c:\Users\Mark\documents\visual studio 2013\Projects\VSDSRest\VSDSRest.Web\App_Code\Database\DatabaseColumnLists.pas 35
… time passes …
I VERIFIED that that same code COMPILES in the other solution. Same “web site”, same .Net version project. odd
… time passes …
One difference I spot is that the one that works has more things in the uses. But I don’t see how that could change it.
… time passes …
Oh, I think I see. The one that doesn’t work has the code in the web site project. The one that compiles ok has that same code in a separate assembly that is USED by the web site project.
I guess I will refactor out what doesn’t work and see if it works outside the web site project.
… time passes …
So I made a new class library project. I CUT the folder that was under App_Code and pasted into the new class library project. It did the operation, but an Exception was raised and a dialog came up that didn’t give specific, just exception.
Now when I compile it, I get the red lines and other errors. I probably need to add some references. Perhaps that was the problem in the Web Site project.
… time passes …
When I told it to complete the classes, it didn’t put the STRING return value in the implementation. That looks to have been the problem the compiler was complaining about. (now that I can see some red lines)