Undeclared identifier:

I have an EXCEL sheets witgh various

C:\Documents and Settings\delfi\MilkDataMgr\FtsExcel.pas(2056):Undeclared identifier: smrBgm167GallonsGrosssDA'

procedure convertXSLToDelfi(fuel: TFtsFuelTypes; const prefix: string); var ColumnNameMap : TStrings; i : Integer; other : string; begin { ColumnNameMap := TStrings; } ColumnNameMap := TStringList.Create; ColumnNameMap.Values['smrBgm229GallonsGross']:=' smrBgm167GallonsGrosssDA'; i := ColumnNameMap.IndexOfName(smrBgm229GallonsGross); if i >= 0 then smrBgm229GallonsGross:= ColumnNameMap.Values[smrBgm229GallonsGross] else smrBgm229GallonsGross:= smrBgm229GallonsGross; end;

a detailed issue is in this link, i folowed the solution offered there how to create Delphi 4 structure to map column names in XLS to column names in SQL

I am just picking up threads kindly help me out.

Answer1:

In the code I gave you, notice that the value inside the brackets for the Values property was quoted. It's a string. Maybe you meant to have "smrBgm229GallonsGross" in quotes, too, like this:

ColumnNameMap.Values['smrBgm229GallonsGross'] := 'smrBgm167GallonsGrosssDA';

In your code, the compiler complains that it doesn't recognize the identifier smrBgm229GallonsGross. Look at your code. Have you declared such an identifier? If not, then you can't expect the compiler to know what you're asking of it, and the error message makes perfect sense.

(If you were using Perl, the compiler might have known what you wanted. There are certain situations where a so-called "bareword" will be interpreted as a string literal rather than an identifier. But that's Perl, not Delphi.)

So far, I've only been looking at the first line of code that mentions smrBgm229GallonsGross. However, there are five more lines of code, where you look up the index of the name and then assign values to a variable, and those will need a proper declaration of a variable. In my example, I used the made-up variable name ColumnName to represent the name of whatever input column you happen to be processing at the time. I assumed you would be iterating over a list of columns in a loop, so you would do the same thing for each column, taking a value from your Excel spreadsheet and transferring it into a corresponding column in the database, which was represented by the also-made-up variable name RealColumnName.

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:Undeclared identifier: