Forum > LCL
Lazarus string Insert error
(1/1)
JD:
Hi there everyone,
I keep getting the error "Wrong number of parameters" on this line of code
Insert('<< Name >>' , strFieldIsEmptyError, 10);
where strFieldISEmptyError := 'The field cannot be empty';
I did some snooping & I found that the compiler looks in db.pas for the definition on the string insert command assuming that I want to insert a record into a table.
I changed the line to
--- Code: ---System.Insert('<< Name >>' , strFieldIsEmptyError, 10);
--- End code ---
and then to
--- Code: ---UTF8Insert('<< Name >>' , strFieldIsEmptyError, 10);
--- End code ---
and both times I got an error saying "Variable identifier expected".
The code works in Delphi so I'd like to know the Lazarus equivalent for the Delphi string Insert procedure.
Thanks a lot
Leledumbo:
Here's the documentation of System's Insert. What is the type of strFieldISEmptyError? If it's a constant or property, then definitely a compile error would come.
JD:
--- Quote from: Leledumbo on March 17, 2010, 04:24:34 am ---Here's the documentation of System's Insert. What is the type of strFieldISEmptyError? If it's a constant or property, then definitely a compile error would come.
--- End quote ---
strFieldISEmptyError is a resourcestring. That may be the problem. I'll try the code with an ordinary string variable.
Leledumbo:
--- Quote ---strFieldISEmptyError is a resourcestring. That may be the problem.
--- End quote ---
Aha, so that's it. A resourcestring is actually a constant instead of a variable. Since Insert modifies its parameter, you can't use pass resourcestring to it.
JD:
--- Quote from: Leledumbo on March 17, 2010, 10:20:25 am ---
--- Quote ---strFieldISEmptyError is a resourcestring. That may be the problem.
--- End quote ---
Aha, so that's it. A resourcestring is actually a constant instead of a variable. Since Insert modifies its parameter, you can't use pass resourcestring to it.
--- End quote ---
I changed the code to
--- Code: --- strErrorString := strFieldIsEmptyError;
UTF8Insert('<< First Name >>', strErrorString, 10);
MessageError(Self, strDataEntryError, strErrorString);
--- End code ---
Thanks for the tip. :D
Navigation
[0] Message Index