Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

How to declare a string constant in project parameters? 3 weeks 5 days ago #18933

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 116
  • Thank you received: 0
I want to use this construction:
{$if defined(VendorStr)}
const Vendor = VendorStr; // ????
{$else}
const Vendor = 'Unknown';
{$endif}

Than I add user definition to project parameters: -dVendorStr:='Self'
However, it does not work...

What should I do to get the desired result?

In C/C++ I use preprocessor directive ## to convert macros to string literal... 

Please Log in or Create an account to join the conversation.

Last edit: by Roman.

How to declare a string constant in project parameters? 3 weeks 5 days ago #18934

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 116
  • Thank you received: 0
If you add the -Sm parameter, then everything compiles, but with very strange effects for Cyrillic strings, for example, with -dVendorStr:='это это' compiles successfully, but -dVendorStr:='этоэто' no longer compiles... In addition, it is unclear in what encoding this string constant is obtained...

Please Log in or Create an account to join the conversation.

How to declare a string constant in project parameters? 3 weeks 5 days ago #18935

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1208
  • Thank you received: 188
Please look here  
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

How to declare a string constant in project parameters? 3 weeks 3 days ago #18936

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 116
  • Thank you received: 0

Please look here  
Yes sir, that was the first thing I read! However, it either doesn't work at all, or it doesn't work with the result I want.

So I add command line macro support -Sm, and then I define a command line macro -dVendosStr:='BooFoo' . I expect the following code
{$if defined(VendorStr)}
const Vendor = VendorStr;
{$else}
const Vendor = 'Unknown';
{$endif}
to set the constant Vendor to 'BooFoo'. But I get a compile error. What did I do wrong?

If I modify my macro by inserting a space -dVendosStr:='Boo Foo', everything magically compiles! What changed?!

What character encoding does this constant come in the code in? When I try to output it, I see black diamonds with question marks (I use Cyrillic string and UTF8 in my project).

Maybe I don't understand something, so please clarify how exactly I should do it.

Please Log in or Create an account to join the conversation.

Last edit: by Roman.

How to declare a string constant in project parameters? 3 weeks 2 days ago #18937

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1208
  • Thank you received: 188
Please,
make a simple project to test and fix
PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

How to declare a string constant in project parameters? 3 weeks 1 day ago #18938

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 116
  • Thank you received: 0
 

File Attachment:

File Name: test_2025-04-08.zip
File Size:197 KB


The attached archive contains a project with 4 build targets:
1. Undefined - compiles successfully
2. English 1 word - does not compile
3. English 2 words - compiles successfully
4. Cyrillic - compiles successfully, but is displayed incorrectly

All settings are made in the "User Options" section of project
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Roman.

How to declare a string constant in project parameters? 3 weeks 1 day ago #18939

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1208
  • Thank you received: 188
I hope it's OK now
PilotLogic Core Programmer
The following user(s) said Thank You: Roman

Please Log in or Create an account to join the conversation.

Last edit: by Matis A..

How to declare a string constant in project parameters? 3 weeks 19 hours ago #18942

  • Roman
  • Roman's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 116
  • Thank you received: 0
Thank you very much, sir!

Please Log in or Create an account to join the conversation.

  • Page:
  • 1