---------------------------------------------------------------------- --- Knud van Eeden --- 13 Juny 2009 - 02:45 pm ----------------------- BBCBASIC for Windows: How to create a 2D QR barcode image file from a given input text string? --- This image has been automatically created by this program, and contains the text of a URL pointing to this web page (you can optionally read its text back using e.g. your mobile phone with a 2D QR barcode reader application installed on it)=== Tagging can be handy, e.g. by putting a sticker or image of a 2D barcode on any item === E.g. -Tagging your (own or other) possessions for quick categorization (no manual typing necessary, just point your barcode reading device (mobile phone) to it) -just scan the barcode sticked on an item -to get a text list of things to take with you on vacation (e.g. for travel insurance purposes) -make a quick inventory (e.g. text list of all your items (hardware, DVDs, CDs, books, ..) in a house or shop) -Inform yourself or other people about something -printing or showing it together with your information, to avoid typing it by hand -article in a magazine or newspaper (e.g. containing a short review of it, and or a URL to the article on the Internet) -article on the Internet (e.g. containing URL shown in the web page) -article on your mobile telephone screen (e.g. containing URL) -Print it on surface of item -pricing or more text information about your items (in a shop) -stick it on a wall (e.g. in a cubicle) (they can scan the image via their mobile phone, to see the corresponding text) -exchange address or business card information (just point your mobile phone to the screen of another mobile phone to read the text) -T-shirts (just point the mobile phone via the barcode to e.g. a URL) -Shop windows (just point the mobile phone via the barcode to e.g. a URL) -Cars (e.g. URL which can be read using mobile phone) ... --- In general everywhere manual typing the same text would be tedious taking too much time, and prone with errors. Using (1D or 2D) barcode tagging you get the same information without errors, usually within seconds, in a systematic way (so that it can e.g. optionally easily be stored in a database) === This program creates a QR bar code .png image. This image can contain up to about 4000 text characters (e.g. numbers or alphanumeric text) === Print the barcode image e.g. out on a sticker, put it on paper, or add the image to a web page. === You can then e.g. read the corresponding (long) text back from this barcode image using any 2D barcode reading device E.g. typically your mobile telephone (running a 2D barcode reading application) -Apple iPhone (apps to read 2D barcode are e.g. QuickMark (recommended), Snappr, ...) -Google Android -Nokia -Sony-Ericsson -Samsung -Windows Mobile telephone ... === Note: Q. Why using 2D barcode instead of 1D barcode? A. The advantage of using a 2D barcode over a 1D barcode [| || ||||] is that it contains much more text information on a smaller area (typically 4000 characters instead of 10 to 30 characters), and can be easily read by most mobile phones (e.g. the Apple iPhone needs almost always a special lens attached to it, e.g. by clicking it in a special casing if you want to read a 1D barcode. But 2D barcode can be easily read by it). QR 2D barcode has error correction built in (up to 30% percent of its barcode area can be damaged and then still be read). === Steps: Overview: 1. -E.g. create the following program: --- cut here: begin --------------------------------------------------
REM --- MAIN --- REM INPUT "string to convert to QR barcode (e.g. Hello World) = " s$ : IF ( s$ = "" ) THEN : s$ = "Hello world" : REM default text string : ENDIF : INPUT "file to store the result (e.g. c:\temp\yourfilename.png) = " fileName$ : IF ( fileName$ = "" ) THEN : fileName$ = "c:\temp\ddd.png" : REM default filename : ENDIF : PROCGraphicCreateBarcodeQrSimplest( s$, fileName$ ) : REM *QUIT : END : : : REM --- LIBRARY --- REM : REM library: graphic: create: barcode: qr: simplest <description></description> <version>1.0.0.0.2</version> (filenamemacro=creagrqs.bbc) [kn, ri, sa, 13-06-2009 14:42:30] DEF PROCGraphicCreateBarcodeQrSimplest( s$, fileName$ ) : LOCAL urlmonI : LOCAL resultI : LOCAL url$ : urlmonI = 0 : resultI = 0 : REM Send your text string to Google API which online converts text to a QR barcode url$ = "http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=" + s$ + "&choe=UTF-8" : REM Now download the resulting .png file from the Google web site (using the Microsoft Windows API 'URLDownloadToFile') SYS "LoadLibrary", "URLMON.DLL" TO urlmonI : SYS "GetProcAddress", urlmonI, "URLDownloadToFileA" TO `URLDownloadToFile` : SYS `URLDownloadToFile`, 0, url$, fileName$, 0, 0 TO resultI : IF ( resultI = 0 ) THEN : PRINT; fileName$ + " successfully downloaded" : OSCLI( "cmd.exe /c start " + fileName$ ) : ELSE : PRINT; fileName$ + " not successfully downloaded" : ENDIF : ENDPROC :--- cut here: end ---------------------------------------------------- 2. -Run the program 1. -Input the text string which you want to convert to a barcode 1. -E.g. This is my xxx laptop serial number 1234567, bought 1 January 2009 2. -Input the filename in which you want to store the result (it must (always) have the extension .png here) 1. -E.g. c:\yourfilename.png 3. -This text is send using HTTP GET as an URL to a Google website, where they using a Google API convert this text to a .png image. Using the Microsoft Windows API URLDownloadToFile that image is then downloaded to your harddisk 4. -Optionally test the result, use e.g. your mobile telephone (here the Apple iPhone was used, running the 2D barcode reading app 'QuickMark') to see if you can read the text back from the image 5. -You can then e.g. show this image together with your information (e.g. print this image on a sticker, which you put on any item) 6. -By passing the given input text (e.g. from a database) and image filename as command line parameters to a similar program (using @cmd$ and converted to an executable .exe file) you can further automatic create many 2D barcode images at once from a list of given input texts 7. -Tested successfully on Microsoft Windows XP Professional (service pack 3), running BBCBASIC for Windows v5.90b Microsoft Internet Explorer v7 Apple iPhone 3G v2 === Book: see also: === Diagram: see also: === File: see also: === Help: see also: === Image: see also:![]()
![]()
![]()
=== Internet: see also: --- Download and install a demo version of BBCBASIC for Windows http://rtrussell.co.uk/bbcwin/download.html --- Barcode: 1D: 2D: Link: Overview: Can you give an overview of links? http://www.knudvaneeden.com/tinyurl.php?urlKey=url000304 === Podcast: see also: === Screencast: see also: === Table: see also: === Video: see also: --- ----------------------------------------------------------------------