Small Basic – New Line

Today I'd like to introduce about new line (line break) codes of a multi-line text in Small Basic.

There are three types of new line codes.

  • CR+LF : used in Windows, MS-DOS
  • CR (carriage return) : used in some cases
  • LF (line feed) : used in Unix, Mac OS X

Those codes can be defined as follows in Small Basic.

CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
CR = Text.GetCharacter(13)
LF = Text.GetCharacter(10)

Basically, CRLF will be the default new line code for Small Basic and Windows.  But for many reasons, sometimes CR or LF can be used even in a Small Basic program.

About output, we can use only CRLF.  But about input, we should be aware of CR or LF as a new line code.

Example 1 - File Input

Some text files are created in other OS's.  So for example, File.ReadContents() may return text with CR or LF as the new line.  But in this case, we can use File.ReadLine() to avoid manipulating line codes.

Example 2 - Multi-Line Text Box Input

Input text in multi-line text box has CRLF.  But pasted text from clipboard may have CR or LF.

And in browser, Controls.GetTextBoxText() returns text with CR.  The details in this browser case are written as a TechNet Wiki article.

Comments (1)
  1. Nice topic! I love digging deep on topics like this!

Comments are closed.

Skip to main content