Code:
cDBFFields += "`"+(cFieldName)+"` TEXT NULL "+ e","
Error:
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Why is this not allowed? It is code to construct an SQL statement. Currently it seems the compiler errors only occurs in the statements within a 2nd DO CASE, no error (yet?) after the CASE .. INSERT but error XS00023 for all following cDBFFields += statementof CASE.. Create
Dick
DO CASE
CASE Type="INSERT"
cDBFFields += cFieldquot+cFieldName+cFieldquot +",
CASE cType="CREATE"
DO CASE
CASE cDataType="C"
IF nFieldLen>255
cDBFFields += "`"+(cFieldName)+"` TEXT NULL "+ e","
ELSE
cDBFFields += "`"+(cFieldName)+"` VARCHAR("+NTrim(nFieldLen) +") NULL "+e","
ENDIF
CASE cDataType="M"
cDBFFields += "`"+(cFieldName)+"` TEXT NULL "+ e","
CASE cDataType="L"
cDBFFields += "`"+(cFieldName)+"` CHAR(1) NULL "+ e"," // For logic we only store Y or N
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Dick,
it is difficult to see what exactly causes the problem from the code you have included.
My first impression is that you are missing an end quote in the line after the "INSERT" case.
I also don't understand why you have separate +e"," in all cases, where you could have included the comma in the string before the + , but that is maybe not relevant. And why do you have cFieldName between parentheses ?
Can you upload the whole function/method ?
Robert
it is difficult to see what exactly causes the problem from the code you have included.
My first impression is that you are missing an end quote in the line after the "INSERT" case.
I also don't understand why you have separate +e"," in all cases, where you could have included the comma in the string before the + , but that is maybe not relevant. And why do you have cFieldName between parentheses ?
Can you upload the whole function/method ?
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Hello Robert,
The quote was lost in copying it seems. And the +e is also done by the forum editor, it is a square opening bracket, a comma and a square closing bracket. Like this (hopes it works this time by adding some spaces...)
cDBFFields += "`"+cFieldName+"` TEXT NULL "+ [ , ]
But currently the error seems gone. I did also get:
Error XS0118 'cFieldName' is a variable but is used like a type.
And I thought, just like you, why do I have parentheses around the name? It works well without it (although in VO it also works with them).
I've removed them and now both errors seem gone.
Thanks!
Dick
The quote was lost in copying it seems. And the +e is also done by the forum editor, it is a square opening bracket, a comma and a square closing bracket. Like this (hopes it works this time by adding some spaces...)
cDBFFields += "`"+cFieldName+"` TEXT NULL "+ [ , ]
But currently the error seems gone. I did also get:
Error XS0118 'cFieldName' is a variable but is used like a type.
And I thought, just like you, why do I have parentheses around the name? It works well without it (although in VO it also works with them).
I've removed them and now both errors seem gone.
Thanks!
Dick
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Dick,
for toename van kennis, would you post the "e" line and apply the "" bracket around?
ARGH: the empty line should be simply code /code, contained in brackets...
Life was easier in NG times
for toename van kennis, would you post the "e" line and apply the "
Code: Select all
ARGH: the empty line should be simply code /code, contained in brackets...
Life was easier in NG times
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Error XS0023 Operator '+' cannot be applied to operand of type 'string'
Dick,
That explains the problem:
The compiler interprets your code
cDBFFields += "`"+(cFieldName)+"` TEXT NULL "+ e","
as
<string> += <string> + <Cast to cFieldName> + <string> + <string>
The +<string> after the cast is a 'unary +' like in
? +10
and there is no 'unary +' operator for string (but there is for numbers)
So the problem is that the parenthesized expression is seen as a cast.
We actually already have a ticket and test for this:
https://github.com/X-Sharp/XSharpDev/bl ... g/C708.prg
Robert
That explains the problem:
The compiler interprets your code
cDBFFields += "`"+(cFieldName)+"` TEXT NULL "+ e","
as
<string> += <string> + <Cast to cFieldName> + <string> + <string>
The +<string> after the cast is a 'unary +' like in
? +10
and there is no 'unary +' operator for string (but there is for numbers)
So the problem is that the parenthesized expression is seen as a cast.
We actually already have a ticket and test for this:
https://github.com/X-Sharp/XSharpDev/bl ... g/C708.prg
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu