Skip to content

Instantly share code, notes, and snippets.

@tylerjohnst
Created November 29, 2011 21:50
Show Gist options
  • Select an option

  • Save tylerjohnst/1406714 to your computer and use it in GitHub Desktop.

Select an option

Save tylerjohnst/1406714 to your computer and use it in GitHub Desktop.
Ugh JScript
# Barcode generation in Windows JScript
number = WSHInputBox('Consignment Barcodes', 'How many barcodes do you want to generate?', '1')
number = parseInt(number)
if number >= 0
number += 1
else
return
while number -= 1
derp = new ActiveXObject('Scriptlet.TypeLib')
uid = derp.Guid.split('-').join('').substring(1,13)
printed = ["! 0 100 175 1",
"BARCODE CODE128A 40 67 20 #{uid}",
"STRING 12X16 40 12 CONSIGNMENT",
"STRING 8X16 20 100 Gray's College",
"STRING 8X16 50 120 Bookstore",
"END"]
fso = new ActiveXObject('Scripting.FileSystemObject')
file = "\\barcode.txt"
text = fso.CreateTextFile(file, 2, true)
for string in printed
text.Write("#{string}\n")
text.Close()
WScript.Sleep(3000)
wsh = new ActiveXObject("WScript.Shell")
wsh.run("copy #{file} lpt1")
<?xml version="1.0" encoding="ISO-8859-1"?>
<%- require 'coffee-script' %>
<job id="ParseBarcodes">
<script language="VBScript">
<![CDATA[
Function WSHInputBox(Message, Title, Value)
WSHInputBox = InputBox(Message, Title, Value)
End Function
]]>
</script>
<script language="JScript">
<![CDATA[
<%= CoffeeScript.compile(File.open('barcodes.coffee')) %>
]]>
</script>
</job>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment