未声明的标识符: [英] Undeclared identifier:

查看:85
本文介绍了未声明的标识符:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有各种EXCEL床单

I have an EXCEL sheets witgh various

C:\ Documents and Settings \ delfi \ MilkDataMgr \ FtsExcel.pas(2056):未声明的标识符: smrBgm167GallonsGrosssDA'

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.

推荐答案

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';

在您的代码中,编译器抱怨无法识别标识符 smrBgm229GallonsGross .查看您的代码. you 声明了这样的标识符吗?如果不是这样,那么您就不能指望编译器知道您的要求,并且错误消息是很合理的.

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.

(如果您使用的是Perl,编译器可能已经知道了您想要的东西.在某些情况下,所谓的裸字"将被解释为字符串文字而不是标识符.但这是Perl,而不是Delphi.)

(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.)

到目前为止,我只看了提到 smrBgm229GallonsGross 的第一行代码.但是,还有五行代码,在其中查找名称的索引,然后将值分配给变量,这些行将需要正确地声明变量.在我的示例中,我使用了虚构的变量名称 ColumnName 来表示您当时恰好要处理的任何输入列的名称.我假设您要遍历循环中的列列表,因此您将对每个列执行相同的操作,从Excel电子表格中获取一个值,并将其传输到数据库中的相应列中,该列也由制成的变量名称 RealColumnName .

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.

这篇关于未声明的标识符:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆