locked
TextWindow: Smal Basic RRS feed

  • Question

  • Thanks for the forum. I have been using Small Basic for just about a week now, I'm like wow! After this short time I have written a pretty decent kind of a thing with multiple chioce questions. As you know I'm completely new at this sort of thing, + an old man (50), so some of the langage is still really foreign, though I have figured some things out on my own. I account that to the folks that put this jewel together.

    Now, finally, my question...

    Some of my questions are pretty long, or some of the answers are just as long. So, they actually go from one end of the TextWindow to the other. I've tried TextWindow.WriteLine("") and it makes a space between some lines but not all. I'll try an example...

    The answer is yes, so one two three four five six seven eight nine, and ten. (Is what I get)

    What I want to do is...

    The answer is yes, so

    one two three four five

    six seven eight nine, and ten.

    Just to make the whole thing look a little more uniform. Obviously in this case i do not want the space between the lines but hopefully you get the idea. I now you guys are really busy but if you could take a minute I would greatly appreciate it. Thanks again for making this so easy, it is what I have always wanted to be able to do. Best Regards.

    Tuesday, March 12, 2013 3:18 AM

Answers

  • Oh, I admit I haven't tested CR properly! ASCII 13 is the standard EoL code for Macs though!

    But I believe that when Smal Basic reads a text file and finds ASCII 13 only, it considers it as EoL anyways.

    However, I need to make more tests!  ^_^


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Thursday, March 14, 2013 4:50 PM
    • Marked as answer by Acutth62 Friday, March 15, 2013 3:46 PM
    Thursday, March 14, 2013 4:47 PM
    Answerer
  • Thanks GoToLoop, I'll keep an eye out.
    • Marked as answer by Acutth62 Friday, March 15, 2013 3:46 PM
    Friday, March 15, 2013 3:46 PM

All replies

  • TextWindow.WriteLine("What I want to do is...")
    TextWindow.WriteLine("The answer is yes, so")
    TextWindow.WriteLine("one two three four five")
    TextWindow.WriteLine("six seven eight nine, and ten.")

    or

    CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
    TextWindow.WriteLine("What I want to do is..." + CRLF + "The answer is yes, so" + CRLF + "one two three four five" + CRLF + "six seven eight nine, and ten.")


    Nonki Takahashi


    Tuesday, March 12, 2013 8:25 AM
  • Although ASCII 13 + ASCII 10 is Windows/DOS standard for end-of-line (EoL), only a single ASCII 13 or ASCII 10 is enough to skip a line!  :D

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Tuesday, March 12, 2013 3:51 PM
    Answerer
  • Thanks, will give both a try.
    Tuesday, March 12, 2013 7:12 PM
  • Thanks, a little over my head but maybe I can do some more research and figure it out.
    Tuesday, March 12, 2013 7:13 PM
  • The TextWindow.WriteLine("What I want to do is...")  solution by Nonki is the most straight forward especially if it's a small program.

    If your working through the curriculum ch 2.4 is on the Text object.

    Here's a sample of what you could do especially if the program got bigger, not as straight forward though. This solution could be expanded by then using the Array object to set quest[q], ans[n][a] and length[m].

    quest1 = "Enter Answer: Y/N "
    ans1Y = "The answer is yes, so one two three four five six seven eight nine, and ten."
    ans1N = "The answer in no, so eleven twelve thirteen forteen fifteen sixteen, and seventeen."
    
    TextWindow.Write(quest1)
    input = TextWindow.Read()
    TextWindow.WriteLine("")
    
    If Text.ConvertToUpperCase(input) = "Y" Then
      length = Text.GetLength(ans1Y)/3 'output is spread over 3 lines
      TextWindow.WriteLine(Text.GetSubText(ans1Y, 1, length))
      TextWindow.WriteLine(Text.GetSubText(ans1Y, length+1, length))
      TextWindow.WriteLine(Text.GetSubText(ans1Y, length*2+1, length))
    ElseIf Text.ConvertToUpperCase(input) = "N" Then
      length = Text.GetLength(ans1N)/3
      TextWindow.WriteLine(Text.GetSubText(ans1N, 1, length))
      TextWindow.WriteLine(Text.GetSubText(ans1N, length+1, length))
      TextWindow.WriteLine(Text.GetSubText(ans1N, length*2+1, length))
    EndIf
    

    Thursday, March 14, 2013 2:43 AM
  • GoToLoop,

    Only ASCII 13 is not enough to skip a line.  Just carriage return (cursor returns to the top of line).

    Try:

    CR = Text.GetCharacter(13)
    LF = Text.GetCharacter(10)
    TextWindow.Write("First line" + CR)
    TextWindow.Write("Second line" + LF)
    TextWindow.Write("Third line" + CR + LF)
    TextWindow.Write("Fourth line")
    


    Nonki Takahashi


    Thursday, March 14, 2013 12:15 PM
  • Oh, I admit I haven't tested CR properly! ASCII 13 is the standard EoL code for Macs though!

    But I believe that when Smal Basic reads a text file and finds ASCII 13 only, it considers it as EoL anyways.

    However, I need to make more tests!  ^_^


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Thursday, March 14, 2013 4:50 PM
    • Marked as answer by Acutth62 Friday, March 15, 2013 3:46 PM
    Thursday, March 14, 2013 4:47 PM
    Answerer
  • Thanks Jibba, this will be very helpful as I intend on creating a few more small programs of this type.
    Friday, March 15, 2013 3:44 PM
  • Thanks again Nonki, you're a huge help.
    Friday, March 15, 2013 3:44 PM
  • Thanks GoToLoop, I'll keep an eye out.
    • Marked as answer by Acutth62 Friday, March 15, 2013 3:46 PM
    Friday, March 15, 2013 3:46 PM