? Data? HELP! (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Data? HELP!

  • #1 ✎ 76 Tiger2 Say I have a code similar to this: Acls Restore @1 Read c$ Locate 25,10 Print c$ @1 Data "Horses" Data "Dragons" Data "Lizards" So how do I make it so that each individual string prints under the other or in any specified place. When I tried a code similar to this, they all printed on top of each other making it look like one. Posted
  • #2 ✎ 474 SquareFingers If you want strings printed at different locations on the screen, you need different LOCATE numbers just before the PRINT. Posted
  • #3 ✎ 76 Tiger2 Dont know what you mean Posted
  • #4 ✎ 51 seggiepants It looks like your code as written will print out "Horses" at 25, 10 and exit. You want it to write Horses on line 10, Dragons on line 11 and Lizards on line 12 right? We are going to need to add some things to do that. A counter to keep track of where to write, and a loop to go through all of the data. The loop needs to know when to stop. Either when we go off screen or run out of data. For the data we can either have a sentinel value that lets us know to stop as the last data entry. Or we could have a data line with the total number of entries before the list. My example goes with the sentinel value, and I chose "" as the value to stop on. Just seemed easier to add more stuff later that way. ACLS RESTORE @1 Y = 10 READ C$ WHILE C$ != "" AND Y < 30 LOCATE 25, Y PRINT C Y = Y + 1 READ C$ WEND END @1 DATA "Horses" DATA "Dragons" DATA "Lizards" DATA "" Y keeps track of where to print. The and Y < 30 part stops us from going off screen. The first READ C$ primes the loop, the second one gets the next value to look at in the loop. We stop when we get to the empty string. Reading past the end of data will cause an error. Hope that helps let me know if you have questions or if I have bugs or syntax errors in the example code. Posted
  • #5 ✎ 76 Tiger2 Thanks. How might I load data to different pages that way if I scroll down inside the game a new list of words appear? I thought about using @ symbols for each page, but then I thought that in the dictionary I was creating, I wanted the player to be able to add words if he wanted to. So how would I make it so when they type in a word they want to add, a new 'data' line is add with the typed in word in the code? Hope that makes sense... Posted Edited by Tiger2
  • #6 ✎ 76 Tiger2 Can you explain a bit more clearly how to make sure the computer automatically puts it all in alphabetical order or the order I choose? Posted
  • #7 ✎ 474 SquareFingers Self-modifying code is generally a bad idea. To save an array of string data, the SAVE command can be used. Also, don't even try to figure out ahead of time where the page-breaks go, if the quantity of data is not known, or is changeable. Do it just after you get the data, or just before you draw a page. Posted
  • #8 ✎ 51 seggiepants I made you a present 25D48V8V. It is a small dictionary application. Feel free to use it as a base for your own application. It sounds like you are making a Japanese/English Dictionary. It won''t do multiple definitions or a scrolling description area right now. But I think it should be close to what you want. At the very least it should show what I meant about saving/loading files, and sorting. I also put in a binary search function for O(LogN) searching. There are some text based add-ons like UCASE$, SPLIT, and WINDOW_PRINT that may be useful too. Get it while you can, the dictionary is full of 80's toy biographies from Wikipedia. who knows what words will trip the filter. Edit: - Added a screen shot. - Noticed a bug in the window_print function when handling return/line feed. - Let me know if the link goes down. Posted Edited by seggiepants
  • #9 ✎ 76 Tiger2 Thanks, but the key didn't work Posted