# Convert XString (or List\<char\>) to char\*

**URL:** <https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495>\
**Category:** Uncategorized\
**Created:** [December 6, 2018, 10:28am UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495 "2018-12-06T10:28:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yzheka-m](https://avatars.discourse-cdn.com/v4/letter/y/ac91a4/32.png) [@yzheka-m](https://forum.xod.io/u/yzheka-m)\
**Post date:** [December 6, 2018, 10:28am UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/1 "2018-12-06T10:28:06Z")

</div>

How can i convert value from string input to char\*  
auto text = getValue\<input\_TEXT\>(ctx);  
here text is represented as XString of List but when I try to compile I get error \xod\__packages_\_\packages\arduino\hardware\avr\1.6.21\cores\arduino/Print.h:75:12: note: no known conversion for argument 1 from ‘xod::List\<char\>’ to ‘const Printable&’

here code snippet where I use it  
void evaluate(Context ctx) {  
auto display = getValue\<input\_DEV\>(ctx);  
auto cursorX = getValue\<input\_CURSOR\_X\>(ctx);  
auto cursorY = getValue\<input\_CURSOR\_Y\>(ctx);  
auto textSize = getValue\<input\_TEXT\_SIZE\>(ctx);  
auto text = getValue\<input\_TEXT\>(ctx);  
display-\>setTextSize(textSize);  
display-\>setCursor(cursorX,cursorY);  
display-\>print(text);  
}

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 6, 2018, 3:56pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/2 "2018-12-06T15:56:28Z")

</div>

Hi yzheka-rn

**You can thank [nkrkv](https://forum.xod.io/u/nkrkv) for this one**

Simple way:

```auto
auto TXTString = getValue<input_String>(ctx);
// Reserve a character buffer that is big enough for sure to hold the whole string.
// Do not use a too big buffer: each character occupies 1 byte of RAM for the
// duration of the current node `eveluate`’ion
char TXT[64];
// move the data from XString to the plain C string
dump(TXTString, TXT);
// the rest is the same...

```

**Or this one adapts to the string length at the cost of a couple of CPU cycles**

```auto
auto TXTString = getValue<input_String>(ctx);
// `length` returns the number of characters and you need an extra one to keep the
// terminal NUL-character used in C string representation. Initialize to 0’s to
// ensure the last char is indeed NUL
char TXT[length(TXTString) + 1] = { 0 };
// move the data from XString to the plain C string
dump(TXTString, TXT);

```

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 6, 2018, 5:17pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/3 "2018-12-06T17:17:06Z")

</div>

Hey yzheka-m  
Can I ask what library you are implementing? As the code looks very familiar a TFT display by any chance? I have done quite a few of them recently and I am working on another one now.  
The adafruit gfx library?

---

<div class="post-metadata">

**Author:** ![yzheka-m](https://avatars.discourse-cdn.com/v4/letter/y/ac91a4/32.png) [@yzheka-m](https://forum.xod.io/u/yzheka-m)\
**Post date:** [December 6, 2018, 6:02pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/4 "2018-12-06T18:02:31Z")

</div>

You are right. It is adafruit library for nokia lcd screen adaptation

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 6, 2018, 6:03pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/5 "2018-12-06T18:03:49Z")

</div>

if you want it will be completed soon I can let you know when I upload it ?

---

<div class="post-metadata">

**Author:** ![yzheka-m](https://avatars.discourse-cdn.com/v4/letter/y/ac91a4/32.png) [@yzheka-m](https://forum.xod.io/u/yzheka-m)\
**Post date:** [December 6, 2018, 6:04pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/6 "2018-12-06T18:04:21Z")

</div>

Would be great, thanks

---

<div class="post-metadata">

**Author:** ![bradzilla84](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/bradzilla84/32/659_2.png) [@bradzilla84](https://forum.xod.io/u/bradzilla84)\
**Post date:** [December 7, 2018, 11:09pm UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/7 "2018-12-07T23:09:26Z")

</div>

Hi yzheka-m  
**MCUFRIEND\_kbv** has been published.  
It is an extended version of the adafruit gfx library it is compatible with a wide range of control chips can you please check yours against the list 🙂

---

<div class="post-metadata">

**Author:** ![yzheka-m](https://avatars.discourse-cdn.com/v4/letter/y/ac91a4/32.png) [@yzheka-m](https://forum.xod.io/u/yzheka-m)\
**Post date:** [December 8, 2018, 7:11am UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/8 "2018-12-08T07:11:42Z")

</div>

Awesome. As soon as I will be near pc I check

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [December 10, 2018, 7:11am UTC](https://forum.xod.io/t/convert-xstring-or-list-char-to-char/1495/9 "2018-12-10T07:11:42Z")

</div>

Closed on December 10, 2018, 7:11am UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
