Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] How to make your turing programs use the printer.
Index -> Programming, Turing -> Turing Tutorials
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dan




PostPosted: Wed Aug 21, 2002 1:54 pm   Post subject: [Tutorial] How to make your turing programs use the printer.

How to uses to a printer in Turing


It a simple code but you have to have a printer that is on LPT1 or on another LPT port.


The code:


code:

var dataout :int %the var can have any name you want

open: dataout, "LPT1", put %set the file name to the port of your printer
put:dataout, "STRING TO SEND TO PRINTER" %string to print
close: dataout %close the connection to the printer


Ex.

code:

var dataout :int
var name, address, age, phone :string

put "Address book maker 3000"
put ""
put ""
put "Name: "..
get name
put "Age: "..
get age
put "Phone Number: "..
get phone
put "Address: "..
get address

cls
open: dataout, "LPT1", put
put:dataout, name, "      ", age
put:dataout, " "
put:dataout, address
put:dataout, phone
close: dataout %close the connection to the printer




if you have any questions or coments about this tutorial RE and let us know.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
Blindmelon_53




PostPosted: Wed Apr 21, 2004 9:16 am   Post subject: (No subject)

I know this is an old topic but I was going to ask if anyone knows if there is any way that you could set it up so that you could use a network printer when you have the ip of the printer. Thanks
Dan




PostPosted: Wed Apr 21, 2004 12:31 pm   Post subject: (No subject)

humm intresting question. in windows u can make a netwrok printer maped to a priter port and it whould work then, but this whould have to be done out side of turing and could not be done by turing.

you could try puting in the network path to the priter but i do not think that will work for some reason. also the net comands may make it posable if u whont to try to figger out the protcal used to send network print jobs.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Blindmelon_53




PostPosted: Wed Apr 21, 2004 1:24 pm   Post subject: (No subject)

Im going to try and figure out what you said about the protocol and mapping idea through windows. Ill post my progress.

The reason I origonally posted the question is because at school we use a network printer which has an ip address. Now if I had any rights what so ever on the computers I might be able to try to map the printer or find the protocol used for printing on a network but that is all blocked, we cant even right click in anything except a word processor Laughing lol which is why I was wondering about the command through turing but like I said I'll try to figure out the above at home and ill post my progress.

Thanks Hacker Dan
Dan




PostPosted: Wed Apr 21, 2004 5:21 pm   Post subject: (No subject)

ya my shcool has the same no rights system. u probly will not be able to get it to print over the netwrok unless there is some new turing comand or seting to 4.x or 4.0.5 that i am unaware of. to figger out the proticals u will ether have to look them up on some site or get a packsniffer and see how it all works.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Delos




PostPosted: Wed Apr 21, 2004 7:07 pm   Post subject: (No subject)

I remember something like this from my compSci class. We had a network printer, and just using the usual LPT worked fine printing to that printer.

However, I doubt that answers your question. To print to a seperate IP, i.e. a printer in a room to which your computer is not currently associated with...you'd probably have to outsource it. I don't think Turing can handle that...
Tony




PostPosted: Wed Apr 21, 2004 7:24 pm   Post subject: (No subject)

well you could sent data directly to the IP using Net. stream but I have no idea how that would be interprited on the other side Confused maybe if you had a server side app that would recieve the file, buffer it and print it locally Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Blindmelon_53




PostPosted: Thu Apr 22, 2004 7:32 am   Post subject: (No subject)

I havn't been able to work on the ip address printing since I havent been at school but I decided to look at USB printing. I havnt seen anyone get it to work yet but what I've been trying to do is to sub where Dan's program says LPT1 with the direct command to my USB printer but I was unsuccessful with that, so I figured I would just link it to the USB port since all the LPT1 is is a port, but still no go. Does anyone have any suggestions for this? Thanks

This is one example of what I have been doing:
code:

var dataout :int %the var can have any name you want

open: dataout,"C:/windows/system32/drivers/USBPRINT.SYS ", put

put:dataout, "STRING TO SEND TO PRINTER" %string to print
close: dataout %close the connection to the printer
Sponsor
Sponsor
Sponsor
sponsor
Blindmelon_53




PostPosted: Thu Apr 22, 2004 8:09 am   Post subject: (No subject)

OK guys progress on USB printing made. The way my printer works it will turn on when data is sent to it which is what is happening now when I run the program however it still will not print anything. The way you have to call your printer is
1. You have to share your printer (like you would on a network)
2. You need to know your computer name (put Sys.GetComputerName works)
3.you call it like a network printer (ie. //ATHLONXP/Lexmark )
ATHLONXP being the computer name of course and Lexmark the printer
EXAMPLE

code:

var dataout :int %the var can have any name you want

open: dataout,"//ATHLONXP/Lexmark ", put %set the file name to the port of your printer

put:dataout, "STRING TO SEND TO PRINTER" %string to print
close: dataout %close the connection to the printer


That all there is to getting your programs to recognize a USB printer.
Now as far as printing I'm not sure. It seems like the document to be printed is so small that it cant even print for some reason.

When I run the program it spools and everything and the printer makes the noise like when you turn it on but it wont print. Ill keep working on it any way.

As for using a network printer at school, I think if you could get the share name of the printer you could easily call the printer the same way we did here. Another posibility could be that you type a line like this //RM-213/IP ADDRESS HERE . Anyways gonna go eat.

IDEAS ALWAYS WELCOME
Jas




PostPosted: Tue May 10, 2005 9:42 am   Post subject: (No subject)

wat if u want to print out the output that is on the screen? Can u somehow save the output on a variable and put it in the "STRING TO SEND TO PRINTER" part?
Andy




PostPosted: Tue May 10, 2005 6:38 pm   Post subject: (No subject)

if its on the screen, then why not just click the print button in the gui bar?
Jas




PostPosted: Tue May 10, 2005 9:23 pm   Post subject: (No subject)

ya i know about that, but my teacher said the program should give the user an option if he wants to print the output. (in this case a customer bill).
Tony




PostPosted: Wed May 11, 2005 1:55 pm   Post subject: (No subject)

Jas wrote:
the program should give the user an option if he wants to print the output. (in this case a customer bill).

well the user has an option to press that print button Wink

anyways, a bill is all text, there are no loaded .jpg images (well not supposed to be), so just send that string to the printer.

And by that I ofcourse mean all your data should be in variables and you're supposed to be able to put the text together again. Or just keep a vertual buffer somewhere and add info to it every time you add something new to the screen.
beard0




PostPosted: Mon Sep 19, 2005 12:24 pm   Post subject: Re: [Tutorial] How to make your turing programs use the prin

This code allows you to print to any printer installed (user's choice). It pops up the normal dialogue with # of copies, print range, etc.
code:

var dataout :int %the var can have any name you want

open: dataout, "printer", put %yes, litterally the string "printer"
put:dataout, "STRING TO SEND TO PRINTER" %string to print
close: dataout %close the connection to the printer
jamonathin




PostPosted: Tue Feb 21, 2006 12:57 pm   Post subject: (No subject)

I know this is an old topic, but I have a question.

I know you cannot print images in turing without using the print button located at the top of the page. But if you compile your program into .exe format, the print button doesn't work. I'm guessing Turing doesn't throw that info in when compliling. Anyone know a way around this?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 21 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: