This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Skullblade's profile picture

[Solved] [SSP] Bug with "\" --Not a bug

Started by Skullblade, 06 January 2013 - 09:39 AM
Skullblade #1
Posted 06 January 2013 - 10:39 AM
EDIT:This is not a bug…
———————————

I have only tested this with SSP and computercraft 1.48
when ever i do a program that prints or writes "\" I get the error
bios:338: [string "program"]:1: unfinished string

example program-string should be finished…

print("\")

also i have current version of forge and no other changes to computercraft or other bugs.

if someone could tell me if everyone has this problem or is it just me?
dissy #2
Posted 06 January 2013 - 10:45 AM
The backslash is the escape character. That means any character after a backslash loses any special meaning.

Using print("\") means you have an open parenthesis, an open double quote, then the backslash means the next character is literal and not special, so you are telling it to print a double quote mark. However you still need a closing double quote to be valid, which is missing.

To print a literal backslash, you must escape the specialness of the backslash.
print("\\")

Edit:
Additionally you use the same method to print out a double quote mark.
print("\"")
The first " starts the string, the second " is not special but literal because of the backslash before it, and the third " is ending the string.

Using just print("\") is similar to using print("a)
Skullblade #3
Posted 06 January 2013 - 11:22 AM
thx for the quick reply

Edit:Just tried it; works like a charm :)/>