UtterAccess.com

Welcome Guest ( Log In | Register ) · View New Posts · View Unanswered Topics

 
Reply to this topicStart new topic
> sending hex code to printer without "
 
   
dkmarsh
post Apr 27 2007, 12:19 AM
Post #1

UtterAccess Addict
Posts: 140



I have an application that needs to send a hex code to a printer. The problem I am having is that it is sending a hex 22 charactor (which is a ") at the start and end of string.

How can I stop it sending the hex 22 at the start and end of the string ?

The variable is defined as:

Public g_open_code As String

g_open_code = Chr$(27) & Chr$(112) & Chr$(0) & Chr$(5) & Chr$(80)


The code that issues the command is:

Open w_strportname For Output As #w_freefile

Write #w_freefile, g_open_code

Close #w_freefile
Go to the top of the page
 
+
datAdrenaline
post Apr 27 2007, 02:00 AM
Post #2

UtterAccess VIP and Access Wiki Moderator
Posts: 12,743
From: Northern Virginia, USA



The behavior you are seeing is a feature of the Write # statement. It was set up that way to work in conjuction with the Input # statement. The Input # statement can enterpret its data as a specific format ... and if the data is a string, Write # will put dbl-quotes around it. To prevent this from happening, I beleive you can use the Print # statment instead.

*Note: I am unable to verify this at the current moment, so ... I may be a little off, I have not used the Write# in quite some time ... but I am virtually certain the Print # statement will do what you want to do.


--------------------
Brent Spaulding | datAdrenaline | Access MVP
Sometimes I think I have 1000 kids -- then I realize -- Hey I do! :) ... Pay it Forward, lives will be touched forever!
Go to the top of the page
 
+
strive4peace2010
post Apr 27 2007, 02:04 AM
Post #3

UtterAccess Editor
Posts: 19,589
From: Colorado



Hi Brent,

oh,,,, can you use the Write or Print statement to send escape sequences to a printer??? I have been looking for a way to do this!


--------------------
Warm Regards,
Crystal
, Microsoft MVP

Free Data Dictionary Tool
Access Basics -- free tutorial
Email Crystal

(: Have an awesome day
Go to the top of the page
 
+
datAdrenaline
post Apr 27 2007, 03:00 AM
Post #4

UtterAccess VIP and Access Wiki Moderator
Posts: 12,743
From: Northern Virginia, USA



Try something like this:

CODE
Public Sub Foo()

    

    Dim x As Integer

    Dim intChannel As Integer  'The channel to communicate thru

    Dim strDestination As String  'PORT or Filename to interact with

    

    For x = 1 To 511

        Close #x

    Next x

    

    intChannel = FreeFile()

    strDestination = Printer.DeviceName 'This is the windows default printer, special characters

                                        'will cause probs ... I think.

    'strDestination = "LPT1"   'the parallel port

    

    Open strDestination For Output As #intChannel

        'Sample "messages" to the printer

        Print #intChannel , [the esc character and code]

        Print #intChannel , "TESTING 12345"

        Print #intChannel , Chr(12)

    Close #intChannel

    

End Sub


NOTE!! ... This is AIR CODE ... I don't have a printer hooked up to test it!!


--------------------
Brent Spaulding | datAdrenaline | Access MVP
Sometimes I think I have 1000 kids -- then I realize -- Hey I do! :) ... Pay it Forward, lives will be touched forever!
Go to the top of the page
 
+
strive4peace2010
post Apr 27 2007, 11:24 AM
Post #5

UtterAccess Editor
Posts: 19,589
From: Colorado



Hi Brent,

thank you much, my friend! I didn't test it yet either, but saved it and next time I want to do that, I will!


--------------------
Warm Regards,
Crystal
, Microsoft MVP

Free Data Dictionary Tool
Access Basics -- free tutorial
Email Crystal

(: Have an awesome day
Go to the top of the page
 
+
dkmarsh
post May 7 2007, 10:52 PM
Post #6

UtterAccess Addict
Posts: 140



Thanks so much. I changed the write to a parint and the " are now gone.

However, I am having a problem where it is adding a carridge return, then line break (hex 0D 0A) at the end of the string.

This mans that instead of pruinting "" it is pritning a blank line.

How can I make it just send the specified hex string ?
Go to the top of the page
 
+
datAdrenaline
post May 11 2007, 02:07 PM
Post #7

UtterAccess VIP and Access Wiki Moderator
Posts: 12,743
From: Northern Virginia, USA



... Real short on time ... but investigate the use of:

Put #

I think that is just a raw send and does not get any "extra" codes/chars appended.


--------------------
Brent Spaulding | datAdrenaline | Access MVP
Sometimes I think I have 1000 kids -- then I realize -- Hey I do! :) ... Pay it Forward, lives will be touched forever!
Go to the top of the page
 
+
BuddyM
post Apr 30 2009, 03:09 AM
Post #8

UtterAccess Addict
Posts: 92
From: South Africa



Hi Brent,

I found this thread extremely helpful with my simular problem I was having. Thank you! Just a quick question...

I have a printer shared over the network that I need to print to. I have used the code as described above. Works perfectly when I have the printer set up local on LPT1 however, it seems to have a problem when working over a network.

I have got the name as shared on the network in the code i.e.

CODE
Set Application.Printer = Application.Printers("SurvOBPr")


still no glory though, what am I missing here?


--------------------
Mel
Go to the top of the page
 
+
datAdrenaline
post Apr 30 2009, 06:48 AM
Post #9

UtterAccess VIP and Access Wiki Moderator
Posts: 12,743
From: Northern Virginia, USA



Hello Buddy ...

Are you printing out a Report ... or are you trying to write directly to the printer port like the sample code is? ....


--------------------
Brent Spaulding | datAdrenaline | Access MVP
Sometimes I think I have 1000 kids -- then I realize -- Hey I do! :) ... Pay it Forward, lives will be touched forever!
Go to the top of the page
 
+
BuddyM
post May 4 2009, 02:31 AM
Post #10

UtterAccess Addict
Posts: 92
From: South Africa



I'm printing straight to the printer port like the sample code. The problem is it is not picking up the printer over the network. I have done a test page on the network from one of the PC's which will be using the database. Printer setup is fine. I need the code to pick up the network printer which is not local on that PC.

I am hoping there is code which will enable me to do this.


--------------------
Mel
Go to the top of the page
 
+

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 8th September 2010 - 04:35 AM