Storing htmlText in Arrays - arrays

Im creating a simple program that will compare user input to a predetermined string (for memorization help). So far, after the user pushes space a code will run to break the user input text into individual characters (in an array) to test it against the original.
When the user pushes space and one of the letters is wrong, I want that letter to turn a different color. Is there any way to store htmlText in an array, or can anyone think of a way to make that letter turn the color?
Is there any way to write the program at all? Am I able to keep the text in a string and compare it (the spaces and punctuation need to be ignored)?

You can change color without htmlText.
Use setTextFormat.
example:
var format:TextFormat = textField.getTextFormat(wrongLetterBeginIndex, wrongLetterEndIndex);
format.color = 0xFF0000;
textField.setTextFormat(format, wrongLetterBeginIndex, wrongLetterEndIndex);

Related

Convert content of array to short string

Not sure if there is any good solution to do this but trying to wrap my head around it anyway.
Lets say that I have an array with items, maybe around 1000 items, representing all objects a user can add to their "inventory". Next, the user can select as many items it wants from that array and add to their own inventory.
Next I would like the user to be able to copy the content of that inventory, into a short string of numbers/letters that the user could send to another user (in plain text) and that user would be able to get the exact same inventory by just typing in the same short string, like "aFdEdfSf998872" or something smilar. Kinda like a url-shortner I guess.
To clarify, the order of the array that the items are picked from is always the same. The order of copied inventory does not need to be in the original order
My first thought was of course to just copy the index of each object into plain text but that could potentially make the string very long if there is a lot of objects.
Any one has any good ideas or pointer how this could be achieved or am I trying something impossible?

If a line of text is separated into multiple text leaves in the accessibility tree, is it still accessible well?

Below is a picture of my current accessibility tree. You can see that the 4 text leaves in it are separated, but it still forms only one line of content. Is this still accessible well ("well" meaning screen readers can detect that they form one complete sentence), or should all of the text leaves be combined into one leaf?
If they should be combined, how can you concatenate variables into the text in React, while keeping it as one single leaf? This is my current code: <p>{cloudiness}% ({cloudinessDescription})</p>
How they are read aloud depends on the screen reader being used. VoiceOver reads it as one phrase, but that doesn't mean others will. Having it split up wouldn't be a nice experience, but it doesn't mean it's not accessible.
If you really want to make sure it's read as one phrase but don't like the noise of the template literal inside the JSX (I agree), why not define the string somewhere else until you are able to test on multiple screen readers?
const cloudinessSummary = `${cloudiness}% (${cloudinessDescription})`;
return <p>{cloudinessSummary}</p>;

How to count the width of text sprite?

I need to wrap text nicely. E.g. "WWWW WWWW" takes more space than "1111 1111".
I have a design to make a for loop and add words one by one and see if text is too long to fit the row.
How to count properly the text.textWidth() without drawing text to the screen 1st?
System.Wait() seems to be required to make textwidth value refresh, is there any workaround for this? I don't want to add sleep into for loop, it would take ages.
len(text.text) to count the text, use len(str(text.text)) if combinated number and text
checkout full documentation here

LabVIEW: How do I break a loop when it matches a value in the array and returns the index

I have a combobox which has an array of Strings such as "Alice", "Bob",and "Charlie" and a string box where user can type. If user types "Bob"in the string box I want to print its index in the combobox, which is 1. Similarly if it is "Charlie" then I want to print "2". I would like to perform this with conditional exit with a for loop, but I am not sure how to return the index when the values are matched.
Thanks
Need to handle the case where the index is not found.
Need to put "String" outside the For Loop so the value is only read once instead of being read on every iteration.
The answer above is correct because you said in your question that you wanted to use the conditional terminal. There is a simpler way without the conditional terminal. I'm including the simpler way here for completeness. The picture below exactly what the picture above does but with a lot less wiring.
I got it working with this.
I converted Combo box to an array of strings and passed to a loop where I compared each instance of combo box with a string and if they are the same then exit then the last index gets printed.

character strings into arrays

This is/isn't homework...the printing of the list IS homework and that works great, the iscntrl() and Array stuff is 6 weeks from now stuff and giving me grief.
I want to create an array filled with the first 32 TLAs of the Ascii table so that when I print out a column / row chart of Decimal to Ascii code I can use iscntrl() to flag that it's an un-printable character. In its place I want to grab the next TLA in the array and print that instead of the non-graphical character.
I have the iscntrl() working fine. Just can't figure out the array thing. All the examples in the books I have and online want to demo grabbing input from the user and tossing it into the array. I want to give the array a list at the beginning in the code and pull from that.
Can someone either give me a good link for what I need or just tell me how to do the whole process?
I've got 32 three letter items and I need to populate the array and pull them out via a for loop.
Thanks.
You can declare an array like this, and pre-fill its values:
const char *ControlCharacterNames[] = {
"NUL",
"SOH",
"STX",
"ETX",
// etc
};
Then, you can access ControlCharacterNames as an array in your code.
http://publications.gbdirect.co.uk/c_book/chapter6/initialization.html, chapter "6.7.2. More initialization".
Long story short, you probably need something like
char *TLAs[] = { "TL1", "TL2", "TL3", "FYI", "WTH", /* ...and so on...*/ };
and then pull the one you need using it's index
printf(TLAs[3]); // print "FYI", the 4th TLA
Hope I understood your question right.

Resources