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

Unexpected behaviour \t

Started by Engineer, 26 March 2013 - 12:52 AM
Engineer #1
Posted 26 March 2013 - 01:52 AM
Hello,

I dont know if this like this in LUA or just a bug in CC. So I ask you pro's if this isnt a bug or if its standard.

Test code:

print( "x\tx" ) --> outputs "x x"
Shouldnt this out put something like: "x x" (much or less then 5 spaces)

Big test code, wasnt it?

But maybe this doesnt even exist in LUA, maybe im mixing up Java and LUA again.. :/

Thanks for reading,

Engineer
theoriginalbit #2
Posted 26 March 2013 - 01:54 AM
there is no way to display tab atm so \t is replaced with a space
Alekso56 #3
Posted 26 March 2013 - 01:56 AM
From the LUA manual: (just in case) (TheOriginalBIT already answered the question)

Literal strings can be delimited by matching single or double quotes, and can contain the following C-like escape sequences:
  • \a — bell
  • \b — backspace
  • \f — form feed
  • \n — newline
  • \r — carriage return
  • \t — horizontal tab –space instead
  • \v — vertical tab – space instead
  • \\ — backslash
  • \" — quotation mark
  • \' — apostrophe
  • \[ — left square bracket
  • \] — right square bracket
Engineer #4
Posted 26 March 2013 - 02:02 AM
there is no way to display tab atm so \t is replaced with a space
Darn! Too bad it isnt implemented. I like the feature of /t because you can nicely make columns of text.
Than I need to use something like this.. I guess..

local t = {'s','o','m','e','t','h','i', 'n', 'g'}
local x = {'i','d','e','m'}

write( "X:  T:" )
for i = 1, #t do
   term.setCursorPos( 5, i + 1 )
   write( t[i] )
end

for i = 1, #x do
   term.setCursorPos( 1, i + 1 )
   write( x[i] )
end

It'll work.


From the LUA manual: (just in case) (TheOriginalBIT already answered the question)

Literal strings can be delimited by matching single or double quotes, and can contain the following C-like escape sequences:
  • \a — bell
  • \b — backspace
  • \f — form feed
  • \n — newline
  • \r — carriage return
  • \t — horizontal tab –space instead
  • \v — vertical tab – space instead
  • \\ — backslash
  • \" — quotation mark
  • \' — apostrophe
  • \[ — left square bracket
  • \] — right square bracket

Thanks man, I couldnt find anything about this on the webs!
And also thanks BIT :P/>
dissy #5
Posted 26 March 2013 - 11:06 AM
Darn! Too bad it isnt implemented. I like the feature of /t because you can nicely make columns of text.

Check out textutils.tabulate for an alternative way