Hi Everyone! I’m new to Xojo and to programming, and would like to create some desktop tools to automate portions of my day-to-day work tasks. In particular, I’d like to create something like this: https://www.zerosack.org/keyword_modifier_tool
Essentially, a keyword mod tool that can sit on the background of my desktop computer. When building out the program. I’m using the TextArea control.
I have a button, and in the Action I have
TextArea1.Text = “+” + TextArea1.Text
This works great for one keyword, but when I pasted in additional keywords from my clipboard it doesn’t work. I would like to read in multiple lines of keywords and also read for pairs split keywords (long tail keywords) like this:
first last
new old
middle
one two three
I would like the result to be:
+first +last
+new +old
+middle
+one +two +three
The link has this going to an input and output window. I was thinking it would be really cool to have the input window and output window or text area be the same window/textarea. So the when the button is pressed the keywords change into modified keywords with the plus signs in the same window.
My main question is–Is there a way of reading multiple lines and split text in the TextArea control or keyword? Or a way of sectioning lines in the TextArea?
I’m already trying work this out for looping the program–but am getting stuck on the syntax errors. I’m thinking something like this:
While Loop Until End of Character is read (still reading through the docs to figure out how to do this)
// loop to read if + is detected
If + then skip
end
if no plus then add one in
detect if any more words on the line
add another plus sign to the second word or third works/etc...
end
Please let me know if textarea isn’t the correct thing to use–I’ve tried text field–but it doesn’t allow for multiple lines. Any pointers to how I can work with text is really appreciated. Thanks!
Hi and welcome to Xojo! There are a number of great resources for beginners available
First, if you’re an absolute beginner to programming, there’s the textbook. It teaches you to program as well as use Xojo at the same time. Great two-in-one system.
There’s also a manual that comes with Xojo that teaches you the ins and outs of using the IDE, the language, and the features within. You can find that in the Documentation folder next to your installation of Xojo. There’s also an online reference http://documentation.xojo.com
Lastly, when you’re ready to learn from examples, there’s a folder full of example projects next to your Xojo install called “Example Projects” It helps when you don’t intend to reinvent the wheel. Do not copy and paste code from example projects, that won’t help you at all.
Look at the Split command. Transform your text into an array, add the “+” to each individual entry, then use Join to put them back into a string and put that into your TextArea. You might consider 2 loops, one to split on endofline, and then split each line on the space character.
Thanks TIm H! I now have a ton of questions about the Split command!
Currently reading through the docs to better frame my questions Any pointers to where I can find some examples about how transform my text into an array would be super helpful–I did find this post on the forum–but is strA a placeholder? Working through the coding but it doesn’t seem to store anything? Or maybe it needs to be initialized?
// then make sure that there are at least 2 lines in the array so that they can be assigned (otherwise, one gets an outofBounds exception)
if lines.Ubount < 1 then
redim lines(1) // this gives us two lines (at index 0 and 1)
end
// now replace the lines
lines(0) = strA
lines(1) = strA
// and store it back in the textarea:
TextArea1.Text = Join (lines, EndOfLine)
Hi Markus! I would really like to see your example–but the link has a 404 error, or any pointers to how I can get something like this to work out would be greatly appreciated