Working with strings
BlitzMax Forums/BlitzMax Beginners Area/Working with strings
| ||
I'm looking for a way to collect input to a custom gui textbox (without using blitz gui) and displaying it on a multiple line textbox (editable by the user) any suggestions? |
| ||
I can deal with the input side of things, I just need to know the best way to store the textbox content and how I go about converting it to display on multiple lines |
| ||
I would store each textbox entry as a type instance and display each on a seperate line. |
| ||
If you want to do your own multiline textbox you will need to seperate the line into single strings. Simplest way to do so is using the linebreak character as seperation character for the string.split() method which returns an array of string after that you just render line after line. To store it, you can write each string with writeline to a file and get it back by using readline. |
| ||
can you write a quicky example for me? sorry :) |
| ||
' its assumed that you have an array lines:string[] which is filled with the textlines 'according my descripting above with the .split method from blitzmax string module for local i:int = startLine to endLine drawtext lines[i], x, y + (i-startLine)*15 next save and read works through the regular stream readline / writeline commands using the lines array |
| ||
Ive got: Type Gui_Textbox Field X,Y,W,H Field Content$ End Type Gui_Textbox_list:Tlist = createlist() |
| ||
I think ill just go to sleep and give up :( |
| ||
Instead of Content, make it Content:string[] And save line for line in it. As well you will perhaps need 2 numbers that specifiy the first and last textline to draw in case you have more text than can be rendered at once ie you need a scrollbar. |
| ||
Ok, really confused, started trying to write a small test to get used to arrays... why wont this work?! Names:String[1] Names[0] = "Name1" Names[1] = "Name2" |
| ||
You need to initialize the array with "size", which in your case is 2.... 0 being the first entry, 1 being the second. So, Namess:String[2] |
| ||
But this dont work either: Names:String[2] Names[0]= "Test" Names[1]= "Test2" |
| ||
Oh Im so dumb, I just had to declare it as either a local or global, sorry |
| ||
How can I add more elements to the array, whilst retaining the origional elements? i.e. Local Test:String[10] blah blah blah but then I need to add say two more onto the end resulting in an array with 12 elemts if you see what I mean? |
| ||
By using Slicing (see docs for more specific information) this means test = test[.. newNumberOfElements] |
| ||
got it up and running... kinda, Here is the file: http://www.mediafire.com/?511fjm6dzgx Could someone run it and possibly tell me why it kinda goes wrong when the last character in any given line is a space? Also tell me what you think cos its my first attempt at a blitzmax program, and I decided to jump in at the deep end and try to build a simple gui. Cheers |
| ||
also it wont delete back over a line, im stuck!! Help! |