-1

I need to build a string which contains Alt Codes, specifically Alt-16 (Arrow symbol). I have a line of text (aka a string). I append a Carriage return, then want an ARROW symbol and the new line of text. This line will then be passed to PPT. If I manually go into PPT, into a text box, I can hit Alt+16, and get the arrow symbol. This is what I programatically want to do. Alt symbols found here.

Here is what I am trying, but it gives me a totally different symbol.

line := line + #13  + Chr(VK_MENU) + #16 + NewLine;

How do I build a string with ALT Codes as part of the string?

Ken White
  • 123,280
  • 14
  • 225
  • 444
user1009073
  • 3,160
  • 7
  • 40
  • 82
  • Do you want to use alt codes to type, or do you want to insert an arrow symbol into a Delphi string? Because the way to do the latter does not involve doing the former. – David Heffernan Jul 01 '19 at 19:48
  • The arrow code is represented by Alt+16. I will be placing a string into a text box within PPT. I need the string to contain the arrow character, aka Alt+16. In effect, I have a LINE, and then I say PPT.TextBox.text := Line. Does that make sense? The ppt part is working. I just need to embed the Alt+16 in the middle of the string. – user1009073 Jul 01 '19 at 20:01
  • OK. I guess you are set on implementing your solution. Good luck. – David Heffernan Jul 01 '19 at 20:18
  • I am open to another approach, just I don't know what it would be. I am setting the text property (of a powerpoint element), and I need an arrow symbol as part of the text... If there is another way, i am delighted to try it. – user1009073 Jul 01 '19 at 20:30
  • I think what David is trying to say, is that Alt+Nr is just a way to input characters, but the character itself is not called an Alt-character, and there are other ways to input them. You could try to look up your character in the character map (Windows program), or on a website like `https://unicode-table.com/en/`. Depending on your Delphi version, you can just paste the character in your source code, or use the [`Chr` function](http://www.delphibasics.co.uk/RTL.asp?Name=Chr) to convert a numeric value to a character. – GolezTrol Jul 01 '19 at 21:08
  • Then ask about that, and don't insist on alt codes. It's a really common problem here, known as an XY question. Google that. – David Heffernan Jul 01 '19 at 21:09
  • 1
    [Windows Character Map (charmap.exe)](https://en.wikipedia.org/wiki/Character_Map_(Windows)) shows the uncode code point of the character, as well as the Alt-code (Alt-keystroke), if available. As you'll notice, these values are not the same. The Alt-code is only for direct typing in. You can't just add 'Alt' plus a number to a string. Btw, please tell us your Delphi-version. – GolezTrol Jul 01 '19 at 21:17
  • `Chr(VK_MENU)` isn't what you think it is, I'm afraid. `VK_MENU` is a key code, not a letter you can convert using `Chr`. The `Alt` key is a modifier key, which means a direct conversion to a character isn't going to give you the results you expect. – Ken White Jul 01 '19 at 23:18
  • Try [Decode/Encode Unicode text](https://www.online-toolz.com/tools/text-unicode-entities-convertor.php) or #$25BA – FredS Jul 01 '19 at 23:41

1 Answers1

3

Not that those characters are not called Alt-codes or Alt-characters. The Alt-codes are just a way to type some special character, but they can't be used as such in a string.

You can just type in that character using the Alt-code, or copy it from the alt codes website. You can use the character as-is in the string. The code below would work fine:

// Show it
ShowMessage('►'); 
// Or use it in your string:
line := line + #13  + '►' + NewLine;
GolezTrol
  • 114,394
  • 18
  • 182
  • 210