Jump to content




printer issues



  • You cannot reply to this topic
12 replies to this topic

#1 jewelshisen

  • Members
  • 164 posts

Posted 21 December 2012 - 11:28 AM

I have a program that is supposed to print out two lines of text. However when I run the program it always tries to print a single line. How can i seperate them?

#2 AndreWalia

  • Members
  • 294 posts
  • LocationSt.Louis, MO

Posted 21 December 2012 - 11:30 AM

print("This is my first line!")
print("This is my second line!")

Ignore everything I just said

#3 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 21 December 2012 - 11:31 AM

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

#4 jewelshisen

  • Members
  • 164 posts

Posted 21 December 2012 - 11:54 AM

View PostNDFJay, on 21 December 2012 - 11:31 AM, said:

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?

#5 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 21 December 2012 - 11:55 AM

View Postjewelshisen, on 21 December 2012 - 11:54 AM, said:

View PostNDFJay, on 21 December 2012 - 11:31 AM, said:

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?

what are you trying to print? it should work with 2 seperate print functions to print on seperate lines but compiling then into 1 makes the code cleaner, both ways should work

post your code if it still doesnt work

#6 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 21 December 2012 - 12:12 PM

View Postjewelshisen, on 21 December 2012 - 11:54 AM, said:

View PostNDFJay, on 21 December 2012 - 11:31 AM, said:

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said... try this

n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()


#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 01:14 PM

Also please note that this is the wrong section to post this. Please request this to be moved to the "Ask a Pro" section. Click "report" on any reply or the OP and type in the box the request to move to the correct section :) and if you ever need any help again post it directly to the "Ask a pro" section.

Also it is good practise to include the code that you have currently got so that we can take a look at it and suggest fixes to you :)

#8 jewelshisen

  • Members
  • 164 posts

Posted 21 December 2012 - 01:15 PM

View PostNDFJay, on 21 December 2012 - 12:12 PM, said:

View Postjewelshisen, on 21 December 2012 - 11:54 AM, said:

View PostNDFJay, on 21 December 2012 - 11:31 AM, said:

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said... try this

n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()

YES! It fixed it! See everytime i tried to use \n to make a new line it just returned a ? and kept on the same line!

#9 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 21 December 2012 - 01:27 PM

View Postjewelshisen, on 21 December 2012 - 01:15 PM, said:

View PostNDFJay, on 21 December 2012 - 12:12 PM, said:

View Postjewelshisen, on 21 December 2012 - 11:54 AM, said:

View PostNDFJay, on 21 December 2012 - 11:31 AM, said:

plain text:
print("this is line 1 \n this is line 2")

defined functions
print(line1.."\n"..line2)

the \n tells the print function to print on the next line

Oh. I was trying to use two seperate print functions! So i just need to compile them into one print function?


forget everything I said... try this

n = peripheral.wrap("left") --n is the printer
n.newPage()
n.write("Text for line 1 here")
n.setCursorPos(1,2)
n.write("Tesxt for line 2 here")
n.endPage()

YES! It fixed it! See everytime i tried to use \n to make a new line it just returned a ? and kept on the same line!

its a bit odd, the wiki says it works the same as the term and mon API's but apparently not, theres probably something we're missing but either way it works now ^_^

#10 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 21 December 2012 - 01:36 PM

term.write also ignores '\n'. Support for '\n' is implemented in the write and print functions from bios.lua . You can easily take those 2 functions and adjust it to support monitors and/or printers.

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)

#11 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 21 December 2012 - 01:44 PM

View PostOrwell, on 21 December 2012 - 01:36 PM, said:

term.write also ignores '\n'. Support for '\n' is implemented in the write and print functions from bios.lua . You can easily take those 2 functions and adjust it to support monitors and/or printers.

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)

Thats actually a good point, I've spent so much time in the "Ask A Pro" section lately I didnt even notice it was in the wrong place lol I think I need sleep, my brains not functioning right... maybe after one more line of code

#12 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 21 December 2012 - 01:46 PM

View PostOrwell, on 21 December 2012 - 01:36 PM, said:

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)

I mentioned it :P

#13 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 21 December 2012 - 01:56 PM

View PostTheOriginalBIT, on 21 December 2012 - 01:46 PM, said:

View PostOrwell, on 21 December 2012 - 01:36 PM, said:

Also, I don't see this mentioned earlier so I'll say it. This post is in the wrong section. Programs is reserved for actual published programs, it just makes finding stuff easier. :)

I mentioned it :P
Oh yes, you mentioned it quite lengthy. :) Didn't notice that earlier. <_<





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users