Jump to content


Photo

Unknown name "Char"


  • Please log in to reply
5 replies to this topic

#1 ielite

ielite
  • Members
  • 723 posts

Posted 08 October 2017 - 05:43 PM

When you create a new visual components project and save it and then try to add a OnKeyPress event to the form, you will get a "Syntax Error: Unknown name "Char" [line: 11, column: 63, file: Form1]" Shouldn't the unit with the Char declaration be added to the project?

#2 Laksekjønn

Laksekjønn
  • Members
  • 455 posts

Posted 08 October 2017 - 10:50 PM

...the IDE should add the System.types unit automatically.

#3 Dennis07

Dennis07
  • Administrators
  • 40 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 10 October 2017 - 02:08 PM

Unfortunately, "Char" is not an intrinsic type in both JS and SmartPascal, equally to "Byte". This means you have to declare it manually as a "String" or use System.Types in your unit.

#4 ielite

ielite
  • Members
  • 723 posts

Posted 10 October 2017 - 07:42 PM

My point was, in the version before Alpha 2.99, I didn't have to do anything, it was automatically added. But now when I run the app in the Alpha version, it doesn't know Char. Yes, I can add the System.Types, but is this what the SMS team expects?
  • Czar likes this

#5 Dennis07

Dennis07
  • Administrators
  • 40 posts
  • LocationBerlin, Germany
  • Enterprise Edition

Posted 12 October 2017 - 01:04 PM

This is the official way we recommend. And no, it did not work in previous versions, at least not in the predecessor of 2.9.9 ALPHA, as you can see on the attached screenshot.
I am really sorry there has to be done this workaround, but that's just "how it is".
If you don't want to declare an extra type for this, just use String in any context, it will behave 100% like Char because System.Types.Char is only an alias for System.String.

2017-10-12_120212.png

#6 ielite

ielite
  • Members
  • 723 posts

Posted 12 October 2017 - 04:19 PM

Sorry, I should have investigated further.

<p>
in the version I had before the alpha release, OnKeyPress was declared as such

procedure Form1KeyPress(Sender: TObject; aChar: String);

and now it is:

procedure Form1KeyPress(Sender: TObject; const Character: Char);

</p>


You would think, if I double click on the event in the object inspector and it is added to the project code, the unit would be added......just like when i drop a component on the form and I do not have to add the componnents unit.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users