Jump to content
Sign in to follow this  
IElite

Unknown name "Char"

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

 

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
On 11/10/2017 at 3:05 AM, Czar said:

Agreed that dropping a tw3editbox should result in system.types being added to the uses. Just got caught out on this very issue.

Next update will do this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×