Barcode Extender test script

Started by spl, August 29, 2025, 05:06:46 AM

Previous topic - Next topic

spl

Below worked well for me selecting either Barcode 39 or a QR Code. Based on Jim's omnibus update for 8/27. I'm sure Jim would appreciate more tests and feedback.
;Barcode/QR Code Test for Barcode Extender
;Extender Author: Jim Taylor
;latest version 8/27/2025
;
;Stan Littlefield 8/29/2025 (using WB2025C)
;===========================================================================
IntControl(73,1,0,0,0)
GoSub UDFS
AddExtender(DirScript():"wbOmniBAR.dll")
;set parameters
text = "This is a test for:wbOmniBAR.dll"
;select format from either a barcode or qrcode
;see extender help for all format types
;===========================================================================
format = @Code39
;format = @QRCode
;===========================================================================
width =  500
height = 500
margin = 10
filename = Dirscript():"TestFile.png"
If fileexist(filename) Then filedelete(filename)
;create barcode from parameters
barEncode(text, format, width, height, margin, filename)
;display barcode text from saved file
If fileexist(filename)
   Message("Text in Filename",barDecode(filename):@LF:@LF:"Saved as: ":filename)
else
   Message("Error","Could Not Create: ":filename)
endif
IntControl(99,"wbOmniWV2.dll",0,0,0)
Exit

:WBERRORHANDLER
geterror()
Terminate(@TRUE,"Error Encountered",errmsg)
;===========================================================================

:UDFS

#DefineSubRoutine geterror()
   wberroradditionalinfo = wberrorarray[6]
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
   Return(errmsg)
#EndSubRoutine
Return
;===========================================================================
Stan - formerly stanl [ex-Pundit]

bottomleypotts

I haven't had a chance to look at Jims extender for a while. However, I have a project where this will come in very handy. Thank you!

spl

While the test script is still valid, further testing discovered C++ error for some types. For now,
@Aztec
@Code39
@Code93
@Code128
@DataBar
@DataMatrix
@PDF417
@QRCode

should work with no issue, and other types resolved in due time.
NOTE: the filename parameter is optional, and if ignored output will be sent to clipboard. This provides an excellent opportunity to test pasting the bar/qr code into an application like Excel.
Stan - formerly stanl [ex-Pundit]

JTaylor

I have posted an update.  Most of the problems were me being dense.  Wasn't thinking about certain formats requiring specific types of data such as EAN/ISBN barcodes requiring a valid ISBN/EAN.  There is now validation in place so you don't get RunTime errors and left wondering why.

See the Help for specifics.

https://www.data-n-stuff.com/anonymous/wbOmnibus.zip

Jim

bottomleypotts

Jim,

I know that there are standards around ISBN/EAN barcodes. But I would ask that your code still allow non-standard barcodes to be able to be generated. We used them (for reasons that elude me now) in one project. And the people in charge of the project would like to maintain their current use of barcodes -- dont ask me why, I don't know! It's a barcode.

JTaylor

There are 2-3 formats that allow most anything.  Since most readers read a variety of formats you will probably be able to find something that works.  Plus, to be somewhat pedantic, I am not sure you can have a non-standard barcode unless you create your own scanner/reader :-)

Guessing they are using either a Cod39, Code93 or Code128.

Jim

spl

Below is an small update to the test script, based on changes made to extender. An additional parameter was added for validation of the barEncode() function, and an updated list of formats [see help file]. The script allows encoding a number as either EAN13 or QRCode. If EAN13 is selected it will raise an error response, based on selecting @TRUE as final parameter, then the WB errorhandler will kick in, ensuring the script will complete. Selecting QRCode will create the output png but when I checked it with my iPhone it displayed as a phone number in (999) 999-9999. Point being one should know more about expected outcomes and choose text and format wisely.
;Barcode/QR Code Test for Barcode Extender
;Extender Author: Jim Taylor
;latest version 8/27/2025
;
;Stan Littlefield 8/29/2025 (using WB2025C)
;updated with changes made to extender 8/30/2025
;===========================================================================
IntControl(73,1,0,0,0)
GoSub UDFS
AddExtender(DirScript():"wbOmniBAR.dll")
;set parameters
text = "7117098841"
;select format from either a barcode or qrcode
;see extender help for all format types
;===========================================================================
format = @EAN13
;format = @QRCode
;===========================================================================
width =  500
height = 500
margin = 10
filename = Dirscript():"TestFile.png"
If fileexist(filename) Then filedelete(filename)
;create barcode from parameters
If barEncode(text, format, width, height, margin, filename,@True)
   ;display barcode text from saved file
   If fileexist(filename)
      Message("Text in Filename",barDecode(filename):@LF:@LF:"Saved as: ":filename)
   else
      Message("Error","Could Not Create: ":filename)
   endif
else
   Message("Encoding Failed",text:@LF:@LF:"Could not be encoded with:":format)
endif
IntControl(99,"wbOmniWV2.dll",0,0,0)
Exit

:WBERRORHANDLER
geterror()
Terminate(@TRUE,"Error Encountered",errmsg)
;===========================================================================

:UDFS

#DefineSubRoutine geterror()
   wberroradditionalinfo = wberrorarray[6]
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
   Return(errmsg)
#EndSubRoutine
Return
;===========================================================================
Stan - formerly stanl [ex-Pundit]

spl

The attached zip contains a .wbt script and png file used by the script. You do not need to have the extender in order to run the script, but it does require Excel to be installed. The intent is to example a use for files created by the Extender.

The script is very modest:
  • Open a blank Excel workbook, terminates if Excel not found
  • Creates 2 header columns, formats row height/column width
  • Inserts QR Code into cell B2
  • prompts to either save or terminate Excel, script exits

You should be able to highlight the code in cell B2 with an iphone or similar and check the text before quitting Excel - to verify the QR inserted correctly.

Appreciate anyone giving this a whirl, and hopefully build up more interest for Jim's Extender.

[EDIT]

And for anyone playing with the Extender, if you use the barDecode() function
png = Dirscript():"Farquad.png"
text = barDecode(png)

you get (often used to add contacts)

BEGIN:VCARD
VERSION:2.1
N;CHARSET=UTF-8:Farquad;Albernatrhy
FN;CHARSET=UTF-8:Albernatrhy Farquad
TEL;CELL:800-444-4441
TEL;HOME;VOICE:800-444-4444
ORG;CHARSET=UTF-8:Farquad Stuff
TITLE;CHARSET=UTF-8:CEO
TEL;WORK;FAX:
ADR;CHARSET=UTF-8;WORK;PREF:;;111 Misery Lane;Toledo;Ohio;USA
EMAIL:ABFarquad@frarquad.com
URL:https:\\farquad.org
END:VCARD
Stan - formerly stanl [ex-Pundit]

spl

Here is a final script for this thread. It creates a standard QR vCard with Jim's Extender. It includes multi-line text with format and basic elements for a vCard [ready to add to a contact list]. If there is a difference of opinion about the format, indicate the change.
;Create QR Code for basic vCard content
;Extender Author: Jim Taylor
;latest version 8/29/2025
;
;Stan Littlefield 9/1/2025 (using WB2025C)
;===========================================================================
IntControl(73,1,0,0,0)
GoSub UDFS
AddExtender(DirScript():"wbOmniBAR.dll")
;set vCard text, standard elements and format
;NOTE must use :: for : with WB multi-line text
text = $"BEGIN::VCARD
VERSION::3.0
N::Farquad;Albernathy;
FN::Albernathy Farquad
TEL;TYPE=work,VOICE::(111) 555-1212
TEL;TYPE=home,VOICE::(404) 386-1017
EMAIL::aFarquad@farquad.com
ORG::Farquad Designs LLC
TITLE::CEO
ADR;TYPE=WORK,PREF::;;151 Moore Avenue;Grand Rapids;MI;49503;United States of America
URL::https:://www.farquaddesigns.com
END::VCARD$"

format = @QRCode
width =  500
height = 500
margin = 10
filename = Dirscript():"TestvCard.png"
If fileexist(filename) Then filedelete(filename)
;create barcode from parameters
If barEncode(text, format, width, height, margin, filename,@True)
   ;display barcode text from saved file
   If fileexist(filename)
      Message("vCard Created",barDecode(filename):@LF:@LF:"Saved as: ":filename)
   else
      Message("Error","Could Not Create: ":filename)
   endif
else
   Message("Encoding Failed",text:@LF:@LF:"Could not be encoded with:":format)
endif
IntControl(99,"wbOmniWV2.dll",0,0,0)
Exit

:WBERRORHANDLER
geterror()
Terminate(@TRUE,"Error Encountered",errmsg)
;===========================================================================

:UDFS

#DefineSubRoutine geterror()
   wberroradditionalinfo = wberrorarray[6]
   lasterr = wberrorarray[0]
   handlerline = wberrorarray[1]
   textstring = wberrorarray[5]
   linenumber = wberrorarray[8]
   errmsg = "Error: ":lasterr:@LF:textstring:@LF:"Line (":linenumber:")":@LF:wberroradditionalinfo
   Return(errmsg)
#EndSubRoutine
Return
;===========================================================================
Stan - formerly stanl [ex-Pundit]

SMF spam blocked by CleanTalk