Skip to content

Strings

drewmccluskey edited this page Nov 27, 2018 · 13 revisions

Strings

In SGML, to implement text into a game, you must use strings. Strings are lines of text stored within a variable which can be drawn on the screen or stored as data. Strings are always written within quotation marks. String functions in SGML allow you to check what text a string holds, the character count of a string, replace text in a string, change variables to strings, change the case of text, and so on. An example of the creation of a string is like this:

str = “Hello World!”;

To force a line break, use the # symbol within the string, like so

str = “This is line one.#This is line two.”;

To use the # symbol within the string, put a \ before it.

str “\#selfie”

All letters, digits, and symbols can be used within strings so long as your font chosen supports them. Any unsupported characters within a font will be replaced with a ▯ symbol.

str1 = “There are 2-3 items in this room! :)”

String Functions:

  • ansi_char
  • chr
  • ord
  • real
  • is_string
  • string
  • string_byte_at
  • string_byte_length
  • string_set_byte_at
  • string_char_at
  • string_ord_at
  • string_copy
  • string_count
  • string_delete
  • string_digits
  • string_format
  • string_insert
  • string_length
  • string_letters
  • string_lettersdigits
  • string_lower
  • string_pos
  • string_repeat
  • string_replace
  • string_replace_all
  • string_upper
  • string_height
  • string_height_ext
  • string_width
  • string_width_ext

Other functions can check what keyboard input has been pressed. These functions are as follows:

  • clipboard_has_text
  • clipboard_get_text
  • clipboard_set_text

Clone this wiki locally