in a module, how do I define a constant that is equal to chr(9) so the tab char ?
I can do it in a method that returns a chr(9)
but when you deal with text import or export you need a lot of chr(9) or chr(13)
and it would compile far more efficient if I can have a constant instead of a method call
Eli, the structure “&uNNNN” creates a string literal of the Unicode code point NNNN. This must be provided as hex, not decimal, so the letter “Z” is &u5A.
[quote=161188:@Dave S]but what you CANNOT do is define it as a CONSTANT via the drop down menu
Const kTab=&u9
msgbox str(ascb(kTab)) ‘’ this show 9 like it should
but if you define it in the side panel (under Constants)… it returns 38
because the constant became “&u9” not &u9 (ie… quotes were added)[/quote]
I thought about that. The issue is automatic assignment. The IDE takes anything that looks like a string as … a string. The IDE could indeed take &u09 as chr(9) but then how would it deal with “&universe” as a string ? Maybe it would be nice to be able to signal Xojo that a constant is a unicode point, maybe as &&u09 ?
In the meantime, it does not seem out of this world to enter &u09 instead of Tab…
[quote=161195:@Wayne Golding]This module has kTab as a global constant = ChrB(9).
Just import the module into your project.[/quote]
This is brilliant, but I need to understand. How did you come up with this line ?
#tag Constant, Name = kTab, Type = String, Dynamic = False, Default = \"\\t", Scope = Public
In particular, how is Default = \"\\t" built ? What is the relationship between \t and chr(9) ? Is it akin to word’s ^t ? What if I want with the same principle to create an EndOfLine with &u0D+&u0A ?
Michel I hacked the project with a hex editor. There’s a whole bunch of stuff you just can’t do with the IDE that is perfectly possible.
I have a project that writes data driven listbox subclass modules so I can design my listboxes (column widths, alignment, headings etc.) in a wysiwig fashion. Saves me hours of getting the look right and automates the repetitive tasks. This is an example of a generated listbox.
[quote=161202:@Wayne Golding]Michel I hacked the project with a hex editor. There’s a whole bunch of stuff you just can’t do with the IDE that is perfectly possible.
[/quote]
Unsupported & if it breaks … well …
Use &u09[quote=161205:@Michel Bujardet]I got it. I exported Wayne’s module to XML, and found that the default value was there as byte. So I was able to add kRet, which is &u0D+&u0A :
Again - if it breaks steps to reproduce creating the file would be requested & “Oh I hacked it in” might turn into “not a bug” since you can’t recreate this from the IDE
Thanks Kem, good to know. I’ve never used &uNNNN for constants created in the IDE, because I only just figured out now, that the data type needs to be Integer.
Constant Name: Tab
Default value: &u9
Type: Number