Answered Generating a QR Barcode

jongpau

Member
Just to add more work to your plate. As an alternative you could use phantom.js and and a bit of javascript you can generate a QR code to file in an assortment of image file types. This is a cross OS platform if you are interesting using on Linux as well-as Windows.
Hi there!

How do you call this from within OE? Do you call a web service? Any chance of showing some sample code of how to implement it?
 

Cecil

19+ years progress programming and still learning.
So I sat down for about 10 mins about how to actually do this using phanon.js and I realize it might be even easier to create QR code using node.js from the command line. I wrote a very very simple javascript code witch uses qr-image npm package ( library's for for node.js)

In my testing I was using Windows but node.js is cross OS complaint.

So you will need to download and install node.js: Download | Node.js
Install the QR-image package:
npm install qr-image
This is my quick and dirty javascript code. "Use it at your own discretion. Blar Blar Blar".
This is like a wrapper for the qr-image package and producint the qrcode image to disk.

qr-generator.js
Code:
var qr = require('qr-image');
var fs = require('fs');

//Test for the number of pass parameters.
if (process.argv.length <= 3) {
    console.log("Usage: " + __filename + " QRCODE filepath");
    process.exit(-1);
}

// Get the first and second prameters.
// Actually node.js see the executalble and the node.js script as the first and second parameters.
var qrCodeData = process.argv[2];
var imageFile  = process.argv[3];

// generate the QR code Image
var code = qr.image(qrCodeData , { type: 'png' });

//Writes the binary image to disk
code.pipe(require('fs').createWriteStream( imageFile ));

process.exit(0);
from OpenEdge you would simply use the OS-COMMAND statement:

Code:
oscomline = substitute('node qr-generator.js &1 &2,
                                                     QUOTE('SOME DATA'),
                                                     "qrimage.png").

OS-COMMAND value(oscomline).
Ref:
GitHub - alexeyten/qr-image: Yet another QR code generator
qr-image
 

Cecil

19+ years progress programming and still learning.
In fact I would even challenge my self to write a pure QR code generator in OpenEdge and have it produce a PNG file. However to the limitation on bitwise logic shifting and other stuff it just too difficult to code.
 

joey.jeremiah

ProgressTalk Moderator
Staff member
cool stuff!

if i get some free time, i'll add the docxfactory barcode generator to the progress standard libraries project. the code is already there and working so it shouldn't be a big job.

so it'll actually be a c/c++ library with a progress 4gl wrapper but it will be cross platform.

docxfactory supports a pretty extensive list of 1d and 2d barcodes.
 

Osborne

Active Member
The error message is usually due to a .NET component being referenced missing from the assemblies file. As a quick test try the following:
  1. Place the ThoughtWorks.QRCode.dll file in the Progress/Project working directory - MESSAGE SESSION:TEMP-DIRECTORY VIEW-AS ALERT-BOX.
  2. As per this site - OpenEdge 11.7 Documentation - add the ThoughtWorks.QRCode.dll file via the "Local Assemblies" tab.
  3. Save the assemblies.xml in the same directory as the ThoughtWorks.QRCode.dll file and quit Assembly References. You may need to restart the session so these will be picked up.
  4. Try writing a line of code such as DEFINE VARIABLE oEncoder AS ThoughtWorks.QRCode.Codec.QRCodeEncoder NO-UNDO. and then checking syntax. If you get this error it means Progress is not referencing the components:
Invalid datatype specified: ThoughtWorks.QRCode.Codec.QRCodeEncoder. Specify a datatype such as 'character' or the name of a class. (5638)
** Could not understand line 1. (196)

This should hopefully get you started.
 

Osborne

Active Member
What happens when you run something similar to this - replace C:\DirectoryofDLL with the directory ThoughtWorks.QRCode.dll is stored in:
Code:
DEFINE VARIABLE oAssembly AS System.Reflection.Assembly NO-UNDO.

oAssembly = System.Reflection.Assembly:LoadFile("C:\DirectoryofDLL\ThoughtWorks.QRCode.dll").

MESSAGE VALID-OBJECT(oAssembly) VIEW-AS ALERT-BOX.
 
Top