965 views
in GUI Development by
Hello EmWi community,

is there a way to convert a character array to a string variable inside the EmWi-IDE?

1 Answer

0 votes
by

Hello,

create a string with a length corresponding to the number of characters within the array and then loop through the array elements and assign the characters one by one to the string. The following is the code:

// The array containing the characters to compose the string
// and the number of characters to pick from the array.
array char theArray[...];
var int32  noOfChars = ...;

// Create a new string with length matching exactly the number
// characters you want to copy from the array
var string theString = string( ' ', noOfChars );
var int32  i;

// Loop through the array and copy the characters into the 
// string
for ( i = 0; i < noOfChars; i = i + 1 )
  theString[i] = theArray[i];

Hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...