A byte walks into a bar and orders a pint. Bartender asks him "What's wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."
Even verder kijken dan je neus lang is dus
Overigens snap ik de topictitle "[Perl] Inline Java" niet; ik maak er "[VB.Net] Perl string conversie" van.
[ Voor 56% gewijzigd door RobIII op 31-03-2008 14:55 ]
There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery.
Je eigen tweaker.me redirect
Over mij
Verwijderd
1
| string Send = string.Format("\x1B%-12345X@PJL RDYMSG DISPLAY = \"{0}\"\r\n\x1B%-12345X\r\n", Message); |
maw, volgens mij klopt je string.format niet
[ Voor 4% gewijzigd door Verwijderd op 31-03-2008 14:52 ]
Ik krijg het niet voor elkaar om die quotes te escapen.. blijf daar maar errors op krijgen:Verwijderd schreef op maandag 31 maart 2008 @ 14:51:
Ik heb het toen op deze manier gedaan:
code:
1string Send = string.Format("\x1B%-12345X@PJL RDYMSG DISPLAY = \"{0}\"\r\n\x1B%-12345X\r\n", Message);
maw, volgens mij klopt je string.format niet(DISPLAY = \"{0}\")
1
| sendString = String.Format("\x1B%-12345X@PJL RDYMSG DISPLAY = \"{0}\"\r\n\x1B%-12345X\r\n", message); |
Behalve door de quotes als dubbele quotes uit te voeren:
1
| """" |
Dat is dus een quote met 2 quotes eromheen...
[ Voor 10% gewijzigd door k0ewl op 31-03-2008 15:14 ]
A byte walks into a bar and orders a pint. Bartender asks him "What's wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."
There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery.
Je eigen tweaker.me redirect
Over mij
Ik had hem alRobIII schreef op maandag 31 maart 2008 @ 15:52:
Een quote escapen in VB(.Net) = ""
totale code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
| Imports System Imports System.Text Imports System.Net Imports System.Net.Sockets Imports System.Xml Imports System.Math Module PrinterHack Dim socket As Socket Dim printer_port As Integer = 9100 Dim Messages() As String = { _ "IK VERVEEL ME", _ "LETTERS BIJNA OP", _ "POMPIDOM", _ "INSERT COIN", _ "CALL SERVICE", _ "OM NOM NOM NOM", _ "RADIATION LEAK", _ "PRESS ANY BUTTON", _ "UW RECLAME HIER?" _ } Sub Main(ByVal args() As String) Console.WriteLine("HP Display Hack") While (True) Call Connect(args(0)) If args(1) = "Weather" Then Call DisplayWeather() ElseIf args(1) = "Messages" Then Call DisplayMessages() End If Call Disconnect() System.Threading.Thread.Sleep(60000) End While End Sub Sub Connect(ByVal IpAddress As String) Dim ipEndPoint As IPEndPoint ipEndPoint = New IPEndPoint(Dns.GetHostEntry(IpAddress).AddressList(0), printer_port) socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) socket.Connect(ipEndPoint) End Sub Sub Disconnect() If socket.Connected Then socket.Disconnect(True) End If End Sub Sub DisplayMessages() Dim sendData() As Byte Dim sendString As String Dim Iterator As Random Dim result Dim message Iterator = New Random message = Messages(Iterator.Next(UBound(Messages))) sendString = String.Format("\x1B%-12345X@PJL RDYMSG DISPLAY = ""{0}""\r\n\x1B%-12345X\r\n", message) sendData = Encoding.ASCII.GetBytes(sendString) result = socket.Send(sendData, sendData.Length, 0) If result = 0 Then Console.WriteLine("Couldn't send: " & sendString) End If End Sub Sub DisplayWeather() Dim URL = "http://www.google.com/ig/api?weather=eindhoven,nederland" Dim XMLParser As XmlDocument = New XmlDocument() Dim XMLNode As XmlNodeList Dim message Dim sendString Dim sendData Dim result As Integer XMLParser.Load(URL) XMLNode = XMLParser.GetElementsByTagName("condition") message = XMLNode.Item(0).Attributes(0).Value sendString = String.Format("\x1B%-12345X@PJL RDYMSG DISPLAY = ""{0}""\r\n\x1B%-12345X\r\n", message) sendData = Encoding.ASCII.GetBytes(sendString) result = socket.Send(sendData, sendData.Length, 0) If result = 0 Then Console.WriteLine("Couldn't send: " & message) End If End Sub End Module |
A byte walks into a bar and orders a pint. Bartender asks him "What's wrong?" Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked a bit off."
Zou het aan de type printer liggen? HP LaserJet 4100
[edit]
Ik heb hem inmiddels aan de praat....
Ik heb de volgende regel aangepast.
1
| sendString = String.Format(ChrW(27) + "%-12345X@PJL RDYMSG DISPLAY = " + ChrW(34) + "{0}" + ChrW(34) + ControlChars.Cr + ControlChars.Lf + ChrW(27) + "%-12345X" + ControlChars.Cr + ControlChars.Lf, message) |
[ Voor 58% gewijzigd door LuCarD op 01-04-2008 15:26 ]
Programmer - an organism that turns coffee into software.
A Soldiers manual and a pair of boots.