| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666 |
- **********************
- C++ʵÏÖ
- **********************
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <ctype.h>
- /* ------------------------ */
- /* System Variables */
- /* ------------------------ */
- static int StrCnt;
- static char StrFunction [64][257];
- /* ---------------------- */
- /* Standard Prototypes */
- /* ---------------------- */
- extern int asc (char *);
- extern char *mid (char *, int, int);
- char FindMod10Digit(char *);
- char *CalcMSICheckDigit(char *);
- /* ------------------- */
- /* User's Prototypes */
- /* ------------------- */
- static int TRUE = 1;
- static int FALSE = 0;
-
- long IDAutomation_UPCe(char *pcDataToEncode, char *szReturnVal, long iSize);;
- long IDAutomation_Codabar(char *pcDataToEncode, char *szReturnVal, long iSize);;
- long IDAutomation_Code128a(char *pcDataToEncode, char *szReturnVal, long iSize);;
- long IDAutomation_Code128b(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Code128c(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Interleaved2of5(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Interleaved2of5Mod10(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Code39(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Code39Mod43(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_EAN8(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_EAN13(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_UPCa(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_MSI(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Postnet(char *pcDataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Code128(char *DataToEncode, int ApplyTilde, char *szReturnVal, long iSize);
- long IDAutomation_Code128HumanReadable(char *DataToEncode, int ApplyTilde, char *szReturnVal, long iSize);
- long IDAutomation_UCC128(char *DataToEncode, char *szReturnVal, long iSize);
- long IDAutomation_Code93(char *DataToEncode, char *szReturnVal, long iSize);
- /* --------------------- */
- /* Run Time Functions */
- /* --------------------- */
- //CMemLeadDetect memLeakDetect;///mem leak
- char* strupr(char* str)
- {
- char returnString[512];
-
- /*//char *returnString = new char[512] ;*/
- int PrintBuffer=0;
- int x=0;
- for (x=1;x<= (int)strlen(str);++x)
- {
- int CurrentValue = asc(mid(str, x, 1));
- if (CurrentValue >= 97 && CurrentValue <= 122)
- PrintBuffer += sprintf(returnString + PrintBuffer ,"%c", CurrentValue - 32);
- else
- PrintBuffer += sprintf(returnString + PrintBuffer ,"%c", CurrentValue );
- }
- sprintf(str,"%s",returnString);
- return (char*)str;
- }
- char* strrev(char* str)
- {
- if (NULL==str)return str;
- int l=strlen(str)-1;
- if (1==l)return str;
- int x=0;
- for(x=0;x<l;x++,l--)
- {
- str[x]^=str[l];
- str[l]^=str[x];
- str[x]^=str[l];
- }
- l=0;
- return (char*)str;
- }
- extern char *mid(char *S, int start, int length)
- {
- if(++StrCnt==64)
- {
- StrCnt = 0;
- }
-
- if (start > (int) strlen(S))
- {
- StrFunction[StrCnt][0]='\0';
- }
- else
- {
- strncpy (StrFunction[StrCnt], &S [start-1], length);
- }
- StrFunction[StrCnt][length]='\0';
-
- return StrFunction[StrCnt];
- }
- extern int asc(char *z)
- {
- static int q;
- q = 0;
- memmove(&q,z,1);
- return q;
- }
- /* ---------------------- */
- /* User Subs/Functions */
- /* ---------------------- */
- long IDAutomation_Code128a(char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
- int C128Start;
- int C128StartA;
- int C128StartB;
- int C128StartC;
- int C128Stop;
- int weightedTotal;
- int I;
- int CurrentChar;
- int CurrentValue;
- int CheckDigitValue;
- int CheckDigit;
- char C128CheckDigit;
- //char C128CurrentChar;
- int C128CurrentChar;
- int BufferCounter = 0;
- C128StartA=203;
- C128StartB=204;
- C128StartC=205;
- C128Stop=206;
- /* Here we select character set A */
- C128Start=C128StartA;
- /* <<<< Calculate Modulo 103 Check Digit >>>> */
- /* Set WeightedTotal to the value of the start character */
- weightedTotal=C128Start-100;
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Get the ASCII value of each character */
- CurrentChar=(asc(mid(DataToEncode,I,1)));
- /* Get the Code 128 value of CurrentChar according to chart */
- if(CurrentChar<135) {CurrentValue=CurrentChar-32;}
- if(CurrentChar>134) {CurrentValue=CurrentChar-100;}
- /* Multiply by the weighting character */
- CurrentValue=CurrentValue*I;
- /* Add the values together to get the weighted total*/
- weightedTotal=weightedTotal+CurrentValue;
- }
- /* divide the WeightedTotal by 103 and get the remainder, this is the CheckDigitValue*/
- CheckDigitValue = (int) (weightedTotal % 103);
- /* Now that we have the CheckDigitValue, find the corresponding ASCII character from the table */
- if(CheckDigitValue < 95 && CheckDigitValue > 0)
- {
- CheckDigit = CheckDigitValue + 32;
- }
- if(CheckDigitValue > 94)
- {
- CheckDigit = CheckDigitValue + 100;
- }
- if(CheckDigitValue == 0)
- {
- CheckDigit = 194;
- }
- C128CheckDigit=CheckDigit;
- /* for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- C128CurrentChar = asc((mid(DataToEncode,I,1)));
- //if(C128CurrentChar==' ')
- if(C128CurrentChar==32)
- {
- //C128CurrentChar=(char)194;
- C128CurrentChar=194;
- }
- //BufferCounter += sprintf(DataToPrint + BufferCounter, "%c", DataToEncode[I-1]);
- BufferCounter += sprintf(DataToPrint + BufferCounter, "%c", C128CurrentChar);
- //strcat(DataToPrint,&C128CurrentChar);
- }
- */
- /* Check for spaces or "00" and print ASCII 194 instead */
- /* place changes in DataToPrint */
- BufferCounter = 0;
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- C128CurrentChar=DataToEncode[I-1];
- if(C128CurrentChar==' ')
- {
- C128CurrentChar = (char)194;
- }
- BufferCounter += sprintf(DataToPrint + BufferCounter, "%c", C128CurrentChar);
- }
- /* Get PrintableString */
- sprintf(PrintableString,"%c%s%c%c",C128Start,DataToPrint,C128CheckDigit,C128Stop);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- long IDAutomation_Code128b(char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToPrint[512];
- //DataToPrint = new char;
- char PrintableString[512];
- //PrintableString = new char[512];
- int BufferCounter = 0;
- int C128Start;
- int C128StartA;
- int C128StartB;
- int C128StartC;
- int C128Stop;
- int weightedTotal;
- int I;
- int CurrentChar;
- int CurrentValue;
- int CheckDigitValue;
- int CheckDigit;
- char C128CheckDigit;
- char C128CurrentChar;
- C128StartA=203;
- C128StartB=204;
- C128StartC=205;
- C128Stop=206;
- /* Here we select character set A */
- C128Start=C128StartB;
- /* <<<< Calculate Modulo 103 Check Digit >>>> */
- /* Set WeightedTotal to the value of the start character */
- weightedTotal=C128Start-100;
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Get the ASCII value of each character */
- CurrentChar=(asc(mid(DataToEncode,I,1)));
- /* Get the Code 128 value of CurrentChar according to chart */
- if(CurrentChar<135) {CurrentValue=CurrentChar-32;}
- if(CurrentChar>134) {CurrentValue=CurrentChar-100;}
- /* Multiply by the weighting character */
- CurrentValue=CurrentValue*I;
- /* Add the values together */
- weightedTotal=weightedTotal+CurrentValue;
- }
- /* divide the WeightedTotal by 103 and get the remainder, this is the CheckDigitValue */
- CheckDigitValue = (int) (weightedTotal % 103);
- /* Now that we have the CheckDigitValue, find the corresponding ASCII character
- from the table */
- if(CheckDigitValue<95 && CheckDigitValue>0) {CheckDigit=CheckDigitValue+32;}
- if(CheckDigitValue>94) {CheckDigit=CheckDigitValue+100;}
- if(CheckDigitValue==0) {CheckDigit=194;}
- C128CheckDigit=CheckDigit;
- /* Check for spaces or "00" and print ASCII 194 instead */
- /* place changes in DataToPrint */
- BufferCounter = 0;
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- C128CurrentChar=DataToEncode[I-1];
- if(C128CurrentChar==' ')
- {
- C128CurrentChar = (char)194;
- }
- BufferCounter += sprintf(DataToPrint + BufferCounter, "%c", C128CurrentChar);
- }
- /* Get PrintableString */
- sprintf(PrintableString,"%c%s%c%c",C128Start, DataToPrint,C128CheckDigit,C128Stop);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- } //end Code128B()
- long IDAutomation_Code128c(char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- char TempOnlyCorrectData[512];
- //TempOnlyCorrectData = new char[512];
- int C128Start;
- int C128Stop;
- int weightedTotal;
- int WeightValue;
- int I;
- int CurrentValue;
- int CheckDigitValue;
- char C128CheckDigit;
- int PrintBuffer = 0;
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode,I,1))) != 0)
- {
- PrintBuffer += sprintf(TempOnlyCorrectData + PrintBuffer, "%s", mid(DataToEncode,I,1));
- }
- }
-
- /* Check for an even number of digits, add 0 if not even */
- int rem = (int) (strlen(TempOnlyCorrectData) % 2);
- if(rem == 1)
- {
- sprintf(OnlyCorrectData, "0%s", TempOnlyCorrectData);
- }
- else
- sprintf(OnlyCorrectData, "%s", TempOnlyCorrectData);
- /* Assign start & stop codes */
- C128Start=205;
- C128Stop=206;
- /* <<<< Calculate Modulo 103 Check Digit and generate DataToPrint >>>> */
- /* Set WeightedTotal to the Code 128 value of the start character */
- weightedTotal=105;
- WeightValue = 1;
- PrintBuffer = 0;
- for(I=1;I <= (int)strlen(OnlyCorrectData);I = I + 2)
- {
- /* Get the value of each number pair */
- CurrentValue = atoi(mid(OnlyCorrectData, I, 2));
- /* Get the DataToPrint */
- if(CurrentValue < 95 && CurrentValue > 0)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentValue + 32);
- }
- if(CurrentValue>94)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentValue + 100);
- }
- if(CurrentValue==0)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", (char)194);
- }
- /* Multiply by the weighting character */
- CurrentValue=CurrentValue * WeightValue;
- /* Add the values together to get the weighted total*/
- weightedTotal = weightedTotal + CurrentValue;
- WeightValue = WeightValue + 1;
- }
- /* Divide the weighted total by 103 and get the remainder, this is the CheckDigitValue
- */
- CheckDigitValue = (int)(weightedTotal % 103);
- /* Now that we have the CheckDigitValue, find the corresponding ASCII character
- from the table */
- if (CheckDigitValue<95 && CheckDigitValue>0)
- {
- C128CheckDigit=CheckDigitValue+32;
- }
- if(CheckDigitValue>94)
- {
- C128CheckDigit=CheckDigitValue+100;
- }
- if (CheckDigitValue==0)
- {
- C128CheckDigit = (char)194;
- }
- /* Get PrintableString */
- sprintf(PrintableString,"%c%s%c%c",C128Start,DataToPrint,C128CheckDigit,C128Stop);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Codabar(char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
-
- int I;
- int PrintBuffer = 0;
- /* Check to make sure data is numeric, $, +, -, /, or :, and remove all others. */
- for(I = 1;I <= (int)strlen(DataToEncode);I++)
- {
- if((int) asc(mid(DataToEncode, I, 1)) > 0 && isdigit(asc(mid(DataToEncode,I,1))))
- PrintBuffer += sprintf(OnlyCorrectData + PrintBuffer, "%s", mid(DataToEncode, I, 1));
- else if(DataToEncode[I - 1] == '$' || DataToEncode[I - 1] == '+' || DataToEncode[I - 1] == '-' ||
- DataToEncode[I - 1] == '/' || DataToEncode[I - 1] == '.' || DataToEncode[I - 1] == ':')
- PrintBuffer += sprintf(OnlyCorrectData + PrintBuffer, "%s", mid(DataToEncode,I,1));
- }
- /* Get Printable String */
- sprintf(PrintableString,"A%sB", OnlyCorrectData);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- long IDAutomation_Interleaved2of5(char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char PrintableString[512];
- //PrintableString = new char[512];
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- char TempString[512];
- //TempString = new char[512];
- int I;
- int CurrentNumberPair = 0;
- char StartCode;
- char StopCode;
- int BufferCounter = 0;
-
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode,I,1))))
- {
- BufferCounter += sprintf(OnlyCorrectData + BufferCounter,"%c", asc(mid(DataToEncode,I,1)));
- }
- }
- BufferCounter = 0;
-
- /* Check for an even number of digits, add 0 if not even */
- if((int)(strlen(OnlyCorrectData) % 2) == 1)
- {
- sprintf(TempString,"%d%s",0, OnlyCorrectData);
- }
- else
- sprintf(TempString,"%s",OnlyCorrectData);
- /* Assign start and stop codes */
- StartCode = (char)203;
- StopCode = (char)204;
- for(I=1;I <= (int)strlen(TempString);I = I + 2)
- {
- /* Get the value of each number pair */
- CurrentNumberPair = atoi(mid(TempString, I, 2));
- /* == Get the ASCII value of CurrentChar according to chart by adding to the value == */
- if(CurrentNumberPair < 94)
- {
- BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", (char)(CurrentNumberPair + 33));
- }
- if(CurrentNumberPair > 93)
- {
- BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", (char)(CurrentNumberPair + 103));
- }
- }
- /* Get Printable String */
- sprintf(PrintableString,"%c%s%c", StartCode, DataToPrint, StopCode);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Interleaved2of5Mod10 (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToEncode2[512];
- //DataToEncode2 = new char[512];
-
- char PrintableString[512];
- //PrintableString = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- int BufferCounter = 0;
- char StartCode;
- char StopCode;
- int I = 0;
- int CurrentNumberPair = 0;
-
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode,I,1))))
- {
- BufferCounter += sprintf(OnlyCorrectData + BufferCounter, "%s", mid(DataToEncode, I, 1));
- }
- }
- BufferCounter += sprintf(OnlyCorrectData + BufferCounter, "%c", FindMod10Digit(OnlyCorrectData));
- /* Check for an even number of digits, add 0 if not even */
- if((int)(strlen(OnlyCorrectData) % 2) == 1)
- sprintf(DataToEncode2, "0%s", OnlyCorrectData);
- else
- sprintf(DataToEncode2, "%s", OnlyCorrectData);
-
- /* Assign start and stop codes */
- StartCode = (char)203;
- StopCode = (char)204;
- BufferCounter = 0;
- BufferCounter += sprintf(PrintableString + BufferCounter, "%c", StartCode);
- for(I = 1;I <= (int)strlen(DataToEncode2);I = I + 2)
- {
- CurrentNumberPair = atoi(mid(DataToEncode2, I, 2));
- if(CurrentNumberPair < 94)
- BufferCounter += sprintf(PrintableString + BufferCounter, "%c", (char)(CurrentNumberPair + 33));
- else
- BufferCounter += sprintf(PrintableString + BufferCounter, "%c", (char)(CurrentNumberPair + 103));
- }
- BufferCounter += sprintf(PrintableString + BufferCounter, "%c", StopCode);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
-
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Code39 (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
- char DataToPrint[512];
- //DataToPrint = new char[512];
-
- char PrintableString[512];
- //PrintableString = new char[512];
- int I;
- int CurrentChar;
- int BufferCounter = 0;
- /* Check for spaces in code */
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Get each character one at a time */
- CurrentChar = asc((mid(DataToEncode,I,1)));
- /* To print the barcode symbol representing a space you will need*/
- /* to type or print "=" (the equal character) instead of a space character.*/
- if(CurrentChar == 32)
- {
- CurrentChar = 61;
- }
- //BufferCounter += sprintf(DataToPrint + BufferCounter,"%c", CurrentChar);
- sprintf(DataToPrint,"%s%c", DataToPrint,CurrentChar);
- }
-
- /* Get Printable String */
- sprintf(PrintableString,"*%s*",strupr(DataToPrint));
-
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Code39Mod43 (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- //char DataToEncode2[512];
- //DataToEncode2 = new char[512];
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
- int I;
- int weightedTotal;
- int CurrentChar;
- char CurrentValue;
- char CheckDigit;
- char CheckDigitValue;
- int bufferCounter = 0;
- /* Get data from user, this is the DataToEncode */
- // sprintf(DataToEncode2,"%s",DataToEncode);
- weightedTotal = 0;
- /* only pass correct data */
- for(I = 1;I <= (int)strlen(DataToEncode);I++)
- {
- // Get each character one at a time
- CurrentChar = asc(strupr(mid(DataToEncode,I,1)));
- // Get the value of CurrentChar according to MOD43
- // 0-9
- if(CurrentChar < 58 && CurrentChar > 47)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = CurrentChar - 48;
- }
- else if(CurrentChar < 91 && CurrentChar > 64)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = CurrentChar - 55;
- }
- else if(CurrentChar == 32) // Space
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", "=");
- CurrentValue = 38;
- }
- else if(CurrentChar == 45) // -
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 36;
- }
- else if(CurrentChar == 46) // .
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 37;
- }
- else if(CurrentChar == 36) // $
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 39;
- }
- else if(CurrentChar == 47) // /
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 40;
- }
- else if(CurrentChar == 43) // +
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 41;
- }
- else if(CurrentChar == 37) // %
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 42;
- }
- else
- {
- CurrentValue = 0;
- }
- // add the values together
- weightedTotal = weightedTotal + CurrentValue;
- }
- // divide the WeightedTotal by 43 and get the remainder, this is the CheckDigit
- CheckDigitValue = (int)((weightedTotal % 43));
- // Assign values to characters
- if(CheckDigitValue < 10) // 0-9
- {
- CheckDigit = CheckDigitValue + 48;
- }
- else if((CheckDigitValue < 36) && (CheckDigitValue > 9)) // A-Z
- {
- CheckDigit = CheckDigitValue + 55;
- }
- else if(CheckDigitValue == 38) // Space
- {
- CheckDigit = 61;
- }
- else if(CheckDigitValue == 36) // -
- {
- CheckDigit = 45;
- }
- else if(CheckDigitValue == 37) // .
- {
- CheckDigit = 46;
- }
- else if(CheckDigitValue == 39) // $
- {
- CheckDigit = 36;
- }
- else if(CheckDigitValue == 40) // /
- {
- CheckDigit = 47;
- }
- else if(CheckDigitValue == 41) // +
- {
- CheckDigit = 43;
- }
- else if(CheckDigitValue == 42) // %
- {
- CheckDigit = 37;
- }
-
- // Get Printable String
- sprintf(PrintableString,"*%s%c*", strupr(DataToPrint), CheckDigit);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Code93(char *DataToEncode, char *output, long iSize)
- {
-
-
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- //char DataToEncode2[512];
- //DataToEncode2 = new char[512];
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
-
- int I;
- char CurrentChar;
- char CurrentValue;
- char CheckDigitC;
- char CheckDigitK;
- char CheckDigitValue;
-
-
-
- int CW = 1;
- int KW = 2;
- int CWSum =0;
- int KWSum =0;
- int bufferCounter = 0;
-
-
-
- /* Get data from user, this is the DataToEncode */
- //sprintf(DataToEncode2,"%s",strupr(DataToEncode));
-
- /* only pass correct data */
- for(I = 1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Get each character one at a time */
- CurrentChar = asc(strupr(mid(DataToEncode,I,1)));
- /* Get the value of CurrentChar according to MOD43 */
- /* 0-9 */
- if(CurrentChar < 58 && CurrentChar > 47)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = CurrentChar - 48;
- }
- else if(CurrentChar < 91 && CurrentChar > 64)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = CurrentChar - 55;
- }
- else if(CurrentChar == 32) /* Space */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", "=");
- CurrentValue = 38;
- }
- else if(CurrentChar == 45) /* - */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 36;
- }
- else if(CurrentChar == 46) /* . */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 37;
- }
- else if(CurrentChar == 36) /* $ */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 39;
- }
- else if(CurrentChar == 47) /* / */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 40;
- }
- else if(CurrentChar == 43) /* + */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 41;
- }
- else if(CurrentChar == 37) /* % */
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s", mid(DataToEncode,I,1));
- CurrentValue = 42;
- }
- else
- {
-
- CurrentValue = 0;
- }
- /* To print the barcode symbol representing a space you will */
- /* to type or print "=" (the equal character) instead of a space character.*/
- if(CurrentChar == 32)
- {
- CurrentChar = 61;
- }
-
- }
- for(I= (int)strlen(DataToEncode);I>0;I--)
- {
- /* Get each character one at a time */
- CurrentChar=asc(strupr(mid(DataToEncode,I,1)));
- /* Get the value of CurrentChar according to 93 */
- if((CurrentChar<58)&&(CurrentChar>47))
- /* 0-9 */
- {
- CurrentValue=CurrentChar-48;
- }
- /* A-Z */
- if((CurrentChar<91)&&(CurrentChar>64))
- {
- CurrentValue=CurrentChar-55;
- }
-
- /* - */
- if(CurrentChar==45)
- {
- CurrentValue=36;
- }
- /* . */
- if(CurrentChar==46)
- {
- CurrentValue=37;
- }
- /* Space */
- if(CurrentChar==32)
- {
-
- CurrentValue=38;
- }
- /* $ */
- if(CurrentChar==36)
- {
- CurrentValue=39;
- }
- /* / */
- if(CurrentChar==47)
- {
- CurrentValue=40;
- }
- /* + */
- if(CurrentChar==43)
- {
- CurrentValue=41;
- }
- /* % */
- if(CurrentChar==37)
- {
- CurrentValue=42;
- }
-
- /* ! */
- if(CurrentChar==33 )
- {
- CurrentValue=43;
- }
-
- /* # */
- if(CurrentChar==35 )
- {
- CurrentValue=44;
- }
- /* & */
- if(CurrentChar==38 )
- {
- CurrentValue=45;
- }
- /* @ */
- if(CurrentChar==64 )
- {
- CurrentValue=46;
- }
- CWSum += CurrentValue * CW;
- KWSum += CurrentValue * KW;
- if (CW == 20) {
- CW = 0;
- }
- if (KW == 15) {
- KW = 0;
- }
- CW++;
- KW++;
- }
- /* divide the WeightedTotal by 47 and get the remainder, this is the CheckDigit for C */
-
- CheckDigitValue = ((int)(CWSum % 47));
-
- /* Assign values to characters for Check digit C */
- /* 0-9 */
- if(CheckDigitValue<10)
- {
- CheckDigitC=CheckDigitValue+48;
- }
-
- /* A-Z */
- if((CheckDigitValue<36)&&(CheckDigitValue>9))
- {
- CheckDigitC=CheckDigitValue+55;
- }
-
- /* = */
- if(CheckDigitValue==38)
- {
- CheckDigitC=61;
- }
- /* Space */
- if(CheckDigitValue==38)
- {
- CheckDigitC=32;
- }
- /* - */
- if(CheckDigitValue==36)
- {
- CheckDigitC=45;
- }
-
- /* . */
- if(CheckDigitValue==37)
- {
- CheckDigitC=46;
- }
-
- /* $ */
- if(CheckDigitValue==39)
- {
- CheckDigitC=36;
- }
- /* / */
- if(CheckDigitValue==40)
- {
- CheckDigitC=47;
- }
-
- /* + */
- if(CheckDigitValue==41)
- {
- CheckDigitC=43;
- }
-
- /* % */
- if(CheckDigitValue==42)
- {
- CheckDigitC=37;
- }
- /* ! */
- if(CheckDigitValue == 43 )
- {
- CheckDigitC=33;
- }
- /* # */
- if(CheckDigitValue == 44 )
- {
- CheckDigitC=35;
- }
- /* & */
- if(CheckDigitValue == 45 )
- {
- CheckDigitC=38;
- }
- /* @ */
- if(CheckDigitValue == 46 )
- {
- CheckDigitC=64;
- }
- /* divide the WeightedTotal by 47 and get the remainder, this is the CheckDigit for K*/
-
- CheckDigitValue = (int)((KWSum+CheckDigitValue) % 47);
-
- /* 0-9 */
- if(CheckDigitValue<10)
- {
- CheckDigitK=CheckDigitValue+48;
- }
-
- /* A-Z */
- if((CheckDigitValue<36)&&(CheckDigitValue>9))
- {
- CheckDigitK=CheckDigitValue+55;
- }
-
- /* Space */
- if(CheckDigitValue == 38)
- {
- CheckDigitK=32;
- }
- /* - */
- if(CheckDigitValue == 36)
- {
- CheckDigitK=45;
- }
-
- /* . */
- if(CheckDigitValue == 37)
- {
- CheckDigitK=46;
- }
-
- /* $ */
- if(CheckDigitValue == 39)
- {
- CheckDigitK=36;
- }
- /* / */
- if(CheckDigitValue == 40)
- {
- CheckDigitK=47;
- }
-
- /* + */
- if(CheckDigitValue == 41)
- {
- CheckDigitK=43;
- }
-
- /* % */
- if(CheckDigitValue == 42)
- {
- CheckDigitK=37;
- }
- /* ! */
- if(CheckDigitValue == 43)
- {
- CheckDigitK=33;
- }
- /* # */
- if(CheckDigitValue == 44)
- {
- CheckDigitK=35;
- }
- /* & */
- if(CheckDigitValue == 45)
- {
- CheckDigitK=38;
- }
- /* @ */
- if(CheckDigitValue == 46 )
- {
- CheckDigitK=64;
- }
- /* Get Printable String */
- sprintf(PrintableString,"(%s%c%c)",strupr(DataToPrint),CheckDigitC,CheckDigitK);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
-
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Postnet (char *DataToEncode, char *output, long iSize)
- {
- /* Enter all the numbers without dashes */
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
-
- int BufferCounter = 0;
- int I;
- int weightedTotal;
- int CheckDigit;
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode,I,1))))
- BufferCounter += sprintf(OnlyCorrectData + BufferCounter,"%s", mid(DataToEncode,I,1));
- }
- /* <<<< Calculate Check Digit >>>>. which is just the sum of the numbers */
- weightedTotal=0;
- for(I = 1;I <= (int)strlen(OnlyCorrectData);I++)
- {
- weightedTotal += atoi(mid(OnlyCorrectData, I, 1));
- }
- /* Find the CheckDigit by finding the number + weightedTotal that = a multiple of 10 */
- /* divide by 10, get the remainder and subtract from 10 */
- I = (int)((weightedTotal % 10));
- if( I!= 0)
- CheckDigit=(10-I);
- else
- CheckDigit=0;
-
- BufferCounter = 0;
- BufferCounter += sprintf(PrintableString + BufferCounter,"(%s%i)", OnlyCorrectData, CheckDigit);
-
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
-
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_EAN8 (char *DataToEncode, char *output, long iSize)
- {
- /* The purpose of this code is to calculate the EAN-8 barcode */
- /* Enter all the numbers without dashes */
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToEncode2[512];
- //DataToEncode2 = new char[512];
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- char PrintableString[512];
- //PrintableString = new char[512];
- int I;
- int Factor;
- int weightedTotal;
- char CurrentChar;
- int CheckDigit;
- int PrintBuffer = 0;
- sprintf(DataToEncode2,"%s",DataToEncode);
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode2);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode2,I,1))))
- {
- PrintBuffer += sprintf(OnlyCorrectData + PrintBuffer,"%c", asc(mid(DataToEncode2,I,1)));
- }
- }
- if(strlen(OnlyCorrectData) >= 7)
- sprintf(DataToEncode2,"%s",mid(OnlyCorrectData, 1, 7));
- else
- sprintf(DataToEncode2,"%s","0005000");
-
- /* <<<< Calculate Check Digit >>>> */
- Factor=3;
- weightedTotal=0;
- for(I = (int)strlen(DataToEncode2);I >= 1;I = I +- 1)
- {
- /* Get the value of each number starting at the end */
- CurrentChar=asc(mid(DataToEncode2,I,1));
- /* multiply by the weighting factor which is 3,1,3,1... */
- /* and add the sum together */
- weightedTotal=weightedTotal+CurrentChar*Factor;
- /* change factor for next calculation */
- Factor=4-Factor;
- }
- /* Find the CheckDigit by finding the number + weightedTotal that = a multiple of 10 */
- /* divide by 10, get the remainder and subtract from 10 */
- I = (int)(weightedTotal % 10);
- if(I!=0)
- CheckDigit=(10-I);
- else
- CheckDigit=0;
- sprintf(DataToEncode2,"%s%i", DataToEncode2, CheckDigit);
- /* Now that have the total number including the check digit, determine character to print */
- /* for proper barcoding */
- PrintBuffer = 0;
- for(I = 1;I <= (int)strlen(DataToEncode2);I++)
- {
- /* Get the ASCII value of each number */
- CurrentChar = asc(mid(DataToEncode2,I,1));
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- if(I==1)
- {
- /* For the first character print the normal guard pattern */
- /* and then the barcode without the human readable character */
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"(%c",CurrentChar);
- }
- if(I==2)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentChar);
- }
- if(I==3)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentChar);
- }
- if(I==4)
- {
- /* Print the center guard pattern after the 6th character */
-
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c*", CurrentChar);
- }
- if(I==5)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentChar+27);
- }
- if(I==6)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentChar+27);
- }
- if(I==7)
- {
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c", CurrentChar+27);
- }
- if(I==8)
- {
- /* Print the check digit as 8th character + normal guard pattern */
- PrintBuffer += sprintf(DataToPrint + PrintBuffer,"%c(", CurrentChar+27);
- }
- }
- /* Get Printable String */
- sprintf(PrintableString,"%s",DataToPrint);
-
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_EAN13 (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- int StringLength = 0;
- int I = 0;
- int Factor = 3;
- int weightedTotal = 0;
- int CurrentChar = 0;
- int DataToPrintBuffer = 0;
- int CheckDigit = 0;
- int LeadingDigit = 0;
- int CurrentEncoding = 0;
- char LPrintableString[512];
- //LPrintableString = new char[512];
- char ActualDataToEncode[20];
- //ActualDataToEncode = new char[20];
- char DataToPrint[20];
- //DataToPrint = new char[20];
-
- char EAN2AddOn[3];
- //EAN2AddOn = new char[3];
-
- char OnlyCorrectData[20];
- //OnlyCorrectData = new char[20];
- char EAN5AddOn[6];
- //EAN5AddOn = new char[6];
- char EANAddOnToPrint[15];
- //EANAddOnToPrint = new char[15];
- char Encoding[20];
- //Encoding = new char[20];
- char Temp[512];
- //Temp = new char[512];
-
- StringLength = (int)strlen(DataToEncode);
- for(I = 0;I < StringLength;I++)
- {
- if(isdigit((int)DataToEncode[I]))
- {
- DataToPrintBuffer += sprintf(OnlyCorrectData + DataToPrintBuffer, "%c", DataToEncode[I]);
- }
- }
- DataToPrintBuffer = 0;
- if(strlen(OnlyCorrectData) < 12 || strlen(OnlyCorrectData) == 16 || strlen(OnlyCorrectData) > 18)
- {
- sprintf(OnlyCorrectData, "%s", "0000000000000");
- }
-
-
- if(strlen(OnlyCorrectData) == 12 || strlen(OnlyCorrectData) == 13)
- {
- sprintf(LPrintableString, "%s", mid(OnlyCorrectData, 1, 12));
- }
- else if(strlen(OnlyCorrectData) == 14)
- {
- sprintf(LPrintableString,"%s", mid(OnlyCorrectData, 1, 12));
- sprintf(EAN2AddOn,"%s", mid(OnlyCorrectData, 13, 2));
- }
- else if(strlen(OnlyCorrectData) == 15)
- {
- sprintf(LPrintableString,"%s", mid(OnlyCorrectData, 1, 12));
- sprintf(EAN2AddOn,"%s", mid(OnlyCorrectData, 14, 2));
- }
- else if(strlen(OnlyCorrectData) == 17)
- {
- sprintf(LPrintableString,"%s", mid(OnlyCorrectData, 1, 12));
- sprintf(EAN5AddOn,"%s", mid(OnlyCorrectData, 13, 5));
- }
- else if(strlen(OnlyCorrectData) == 18)
- {
- sprintf(LPrintableString,"%s", mid(OnlyCorrectData, 1, 12));
- sprintf(EAN5AddOn,"%s", mid(OnlyCorrectData, 14, 5));
- }
-
-
-
- /* <<<< Calculate Check Digit >>>> */
- for(I = (int)strlen(LPrintableString);I >= 1;I--)
- {
- /* Get the value of each number starting at the end */
- CurrentChar = asc(mid(LPrintableString,I,1)) - 48;
- /* multiply by the weighting factor which is 3,1,3,1... */
- /* and add the sum together */
- weightedTotal = weightedTotal + (CurrentChar * Factor);
- /* change factor for next calculation */
- Factor = 4 - Factor;
- }
- /* Find the CheckDigitValue by finding the number + weightedTotal that = a multiple of 10 */
- /* divide by 10, get the remainder and subtract from 10 */
- I = (int)(weightedTotal % 10);
- if(I != 0)
- CheckDigit=(10 - I);
- else
- CheckDigit = 0;
- /* Now we must encode the leading digit into the left half of the EAN-13 symbol */
- /* by using variable parity between character sets A and B */
- LeadingDigit = (((asc(mid(LPrintableString, 1, 1))))-48);
-
- if(LeadingDigit == 0)
- sprintf(Encoding, "AAAAAACCCCCC");
- else if(LeadingDigit == 1)
- sprintf(Encoding, "AABABBCCCCCC");
- else if(LeadingDigit == 2)
- sprintf(Encoding, "AABBABCCCCCC");
- else if(LeadingDigit == 3)
- sprintf(Encoding, "AABBBACCCCCC");
- else if(LeadingDigit == 4)
- sprintf(Encoding, "ABAABBCCCCCC");
- else if(LeadingDigit == 5)
- sprintf(Encoding, "ABBAABCCCCCC");
- else if(LeadingDigit == 6)
- sprintf(Encoding, "ABBBAACCCCCC");
- else if(LeadingDigit == 7)
- sprintf(Encoding, "ABABABCCCCCC");
- else if(LeadingDigit == 8)
- sprintf(Encoding, "ABABBACCCCCC");
- else if(LeadingDigit == 9)
- sprintf(Encoding, "ABBABACCCCCC");
- /* add the check digit to the end of the barcode & remove the leading digit */
- sprintf(ActualDataToEncode, "%s%i", mid(LPrintableString, 2, 11), CheckDigit);
-
- /* Now that we have the total number including the check digit, determine character to print */
- /* for proper barcoding: */
- for(I = 1;I <= (int)strlen(ActualDataToEncode);I++)
- {
- /* Get the ASCII value of each number excluding the first number because */
- /* it is encoded with variable parity */
- CurrentChar = asc(mid(ActualDataToEncode, I, 1));
- CurrentEncoding = asc(mid(Encoding, I, 1));
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- if(CurrentEncoding == 'A')
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "%c", CurrentChar);
- else if(CurrentEncoding == 'B')
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "%c", CurrentChar + 17);
- else if(CurrentEncoding=='C')
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "%c", CurrentChar + 27);
- /* add in the 1st character along with guard patterns */
- if(I == 1)
- {
- DataToPrintBuffer = 0;
- /* For the LeadingDigit print the human readable character, */
- /* the normal guard pattern and then the rest of the barcode */
- sprintf(Temp,"%i",LeadingDigit);
- if(LeadingDigit > 4)
- {
- sprintf(Temp,"%c(%s",asc(Temp) + 64, DataToPrint);
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "%s", Temp);
- }
- else if(LeadingDigit < 5)
- {
- sprintf(Temp,"%c(%s",asc(Temp) + 37, DataToPrint);
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer,"%s",Temp);
- }
- }
- else if(I==6)
- {
- /* Print the center guard pattern after the 6th character */
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "*");
- }
- else if(I==12)
- {
- /* For the last character (12) print the normal guard pattern */
- /* after the barcode */
- DataToPrintBuffer += sprintf(DataToPrint + DataToPrintBuffer, "(");
- }
- }
- /* Process 5 digit add on if it exists */
- if(strlen(EAN5AddOn) == 5)
- {
- /* Get check digit for add on */
- Factor = 3;
- weightedTotal=0;
- for(I = (int)strlen(EAN5AddOn);I >= 1;I--)
- {
- /* Get the value of each number starting at the end */
- CurrentChar = asc(mid(EAN5AddOn, I, 1)) - 48;
- /* multiply by the weighting factor which is 3,9,3,9. */
- /* and add the sum together */
- if(Factor == 3)
- weightedTotal = weightedTotal + (CurrentChar * 3);
- else if(Factor == 1)
- weightedTotal = weightedTotal + CurrentChar * 9;
- /* change factor for next calculation */
- Factor = 4 - Factor;
- }
- /* Find the CheckDigit by extracting the right-most number from weightedTotal */
- sprintf(Temp,"%i",weightedTotal);
- CheckDigit = asc(mid(Temp,(int)strlen(Temp), 1)) - 48;
- /* Now we must encode the add-on CheckDigit into the number sets */
- /* by using variable parity between character sets A and B */
- if(CheckDigit == 0)
- sprintf(Encoding,"BBAAA");
- else if(CheckDigit == 1)
- sprintf(Encoding,"BABAA");
- else if(CheckDigit == 2)
- sprintf(Encoding,"BAABA");
- else if(CheckDigit == 3)
- sprintf(Encoding,"BAAAB");
- else if(CheckDigit == 4)
- sprintf(Encoding,"ABBAA");
- else if(CheckDigit == 5)
- sprintf(Encoding,"AABBA");
- else if(CheckDigit == 6)
- sprintf(Encoding,"AAABB");
- else if(CheckDigit == 7)
- sprintf(Encoding,"ABABA");
- else if(CheckDigit == 8)
- sprintf(Encoding,"ABAAB");
- else if(CheckDigit == 9)
- sprintf(Encoding,"AABAB");
- /* Now that we have the total number including the check digit, determine character to print */
- /* for proper barcoding: */
- DataToPrintBuffer = 0;
- for(I = 1;I <= (int)strlen(EAN5AddOn);I++)
- {
- /* Get the value of each number. It is encoded with variable parity */
- CurrentChar = asc(mid(EAN5AddOn,I,1)) - 48;
- CurrentEncoding = asc(mid(Encoding, I, 1));
- if(I == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c%c", 32, 43);
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- if(CurrentEncoding == 'A')
- {
- if(CurrentChar == 0)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 34);
- else if(CurrentChar == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 35);
- else if(CurrentChar == 2)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 36);
- else if(CurrentChar == 3)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 37);
- else if(CurrentChar == 4)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 38);
- else if(CurrentChar == 5)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 44);
- else if(CurrentChar == 6)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 46);
- else if(CurrentChar == 7)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 47);
- else if(CurrentChar == 8)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 58);
- else if(CurrentChar == 9)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 59);
- }
- if(CurrentEncoding == 'B')
- {
- if(CurrentChar == 0)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 122);
- else if(CurrentChar == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 61);
- else if(CurrentChar == 2)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 63);
- else if(CurrentChar == 3)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 64);
- else if(CurrentChar == 4)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 91);
- else if(CurrentChar == 5)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 92);
- else if(CurrentChar == 6)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 93);
- else if(CurrentChar == 7)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 95);
- else if(CurrentChar == 8)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 123);
- else if(CurrentChar == 9)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 125);
- }
- /* add in the space & add-on guard pattern */
- if(I==1)
- {
- /* Now print add-on delineators between each add-on character */
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 33);
-
-
- }
- else if(I == 2)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 33);
-
- else if(I == 3)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 33);
-
- else if(I == 4)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 33);
-
- else if(I == 5)
- {
- }
- }
- }
- /* Process 2 digit add on if it exists */
- if(strlen(EAN2AddOn)==2)
- {
- int Tempi = atoi(mid(EAN2AddOn, 1, 2));
-
- /* Get encoding for add on */
- for(I = 0;I <= 99;I = I + 4)
- {
- if(Tempi == I)
- sprintf(Encoding, "AA");
- if(Tempi == I + 1)
- sprintf(Encoding, "AB");
- if(Tempi == I + 2)
- sprintf(Encoding, "BA");
- if(Tempi == I + 3)
- sprintf(Encoding, "BB");
- }
- /* Now that we have the total number including the encoding */
- /* determine what to print */
- DataToPrintBuffer = 0;
- for(I = 1;I <= (int)strlen(EAN2AddOn);I++)
- {
- /* Get the value of each number. It is encoded with variable parity */
- if(I == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, " %c", 43);
- CurrentChar = asc(mid(EAN2AddOn, I, 1)) - 48;
- CurrentEncoding = asc(mid(Encoding, I, 1));
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- if(CurrentEncoding == 'A')
- {
- if(CurrentChar == 0)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 34);
- else if(CurrentChar == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 35);
- else if(CurrentChar == 2)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 36);
- else if(CurrentChar == 3)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 37);
- else if(CurrentChar == 4)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 38);
- else if(CurrentChar == 5)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 44);
- else if(CurrentChar == 6)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 46);
- else if(CurrentChar == 7)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 47);
- else if(CurrentChar == 8)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 58);
- else if(CurrentChar == 9)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 59);
- }
- if(CurrentEncoding == 'B')
- {
- if(CurrentChar == 0)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 122);
- else if(CurrentChar == 1)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 61);
- else if(CurrentChar == 2)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 63);
- else if(CurrentChar == 3)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 64);
- else if(CurrentChar == 4)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 91);
- else if(CurrentChar == 5)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 92);
- else if(CurrentChar == 6)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 93);
- else if(CurrentChar == 7)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 95);
- else if(CurrentChar == 8)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 123);
- else if(CurrentChar == 9)
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 125);
- }
-
- /* add in the space & add-on guard pattern */
- if(I==1)
- {
- DataToPrintBuffer += sprintf(EANAddOnToPrint + DataToPrintBuffer, "%c", 33);
- }
- }
- }
-
-
- LPrintableString[512];
- if(strlen(EAN2AddOn) == 2 || strlen(EAN5AddOn) == 5)
- sprintf(LPrintableString, "%s%s", DataToPrint, EANAddOnToPrint);
- else
- sprintf(LPrintableString, "%s", DataToPrint);
- iSize = (long)strlen(LPrintableString);
- strncpy(output, LPrintableString, strlen(LPrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_UPCa (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToPrint[512];
- char DataToEncode2[512];
- char OnlyCorrectData[512];
- char EAN2AddOn[512];
- char EAN5AddOn[512];
- char EANAddOnToPrint[512];
- char Encoding[512];
- char Temp[512];
- static char PrintableString[512];
- char CurrentChar;
- char CurrentEncoding;
- int Factor;
- int weightedTotal;
- int CheckDigit;
- int Tempi;
- int I;
-
- DataToPrint[0]=(char)0;
- DataToEncode2[0]=(char)0;
- OnlyCorrectData[0]=(char)0;
- EAN2AddOn[0]=(char)0;
- EAN5AddOn[0]=(char)0;
- EANAddOnToPrint[0]=(char)0;
- Encoding[0]=(char)0;
- Temp[0]=(char)0;
- PrintableString[0]=(char)0;
- sprintf(DataToEncode2,"%s",DataToEncode);
- /* Check to make sure data is numeric and remove dashes, etc. */
- for(I=1;I <= (int)strlen(DataToEncode2);I++)
- {
- /* Add all numbers to OnlyCorrectData string */
- if(isdigit(asc(mid(DataToEncode2,I,1))))
- {
- sprintf(OnlyCorrectData,"%s%s",&OnlyCorrectData,mid(DataToEncode2,I,1));
- }
- }
- /* Remove check digits if they added one */
- if(strlen(OnlyCorrectData)==12)
- {
- sprintf(OnlyCorrectData,"%s",mid(OnlyCorrectData,1,11));
- }
- if(strlen(OnlyCorrectData)==14)
- {
- sprintf(OnlyCorrectData,"%s%s",mid(OnlyCorrectData,1,11),mid(OnlyCorrectData,13,2));
- }
- if(strlen(OnlyCorrectData)==17)
- {
- sprintf(OnlyCorrectData,"%s%s",mid(OnlyCorrectData,1,11),mid(OnlyCorrectData,13,5));
- }
- if(strlen(OnlyCorrectData)==16)
- {
- sprintf(EAN5AddOn,"%s",mid(OnlyCorrectData,12,5));
- }
- if(strlen(OnlyCorrectData)==13)
- {
- sprintf(EAN2AddOn,"%s",mid(OnlyCorrectData,12,2));
- }
- if(strlen(OnlyCorrectData) != 11 && strlen(OnlyCorrectData) != 12 && strlen(OnlyCorrectData) != 14 &&
- strlen(OnlyCorrectData) != 17 && strlen(OnlyCorrectData) != 16 && strlen(OnlyCorrectData) != 13)
- {
- sprintf(OnlyCorrectData,"%s","00000000000");
- }
- /* split 12 digit number from add-on */
- sprintf(DataToEncode2,"%s",mid(OnlyCorrectData,1,11));
- /* <<<< Calculate Check Digit >>>> */
- Factor=3;
- weightedTotal=0;
- for(I = (int)strlen(DataToEncode2);I >= 1;I = I + -1)
- {
- /* Get the value of each number starting at the end */
- CurrentChar=(asc(mid(DataToEncode2,I,1)))-48;
- /* multiply by the weighting factor which is 3,1,3,1... */
- /* and add the sum together */
- weightedTotal=weightedTotal+CurrentChar*Factor;
- /* change factor for next calculation */
- Factor=4-Factor;
- }
- /* Find the CheckDigit by finding the number + weightedTotal that = a multiple of 10 */
- /* divide by 10, get the remainder and subtract from 10 */
- I = (int)(weightedTotal % 10);
- if(I!=0)
- {
- CheckDigit=(10-I);
- }
- else
- {
- CheckDigit=0;
- }
- sprintf(DataToEncode2,"%s%i",&DataToEncode2,CheckDigit);
- /* Now that have the total number including the check digit, determine character to print */
- /* for proper barcoding */
- for(I=1;I <= (int)strlen(DataToEncode2);I++)
- {
- /* Get the ASCII value of each number */
- CurrentChar=asc(mid(DataToEncode2,I,1));
- /* Print different barcodes according to the location of the CurrentChar */
- for(;;)
- {
- if(I==1)
- {
- /* For the first character print the human readable character, the normal */
- /* guard pattern and then the barcode without the human readable character */
- if((CurrentChar-48)>4)
- {
- sprintf(DataToPrint,"%c(%c",CurrentChar+64,CurrentChar+49);
- }
- if((CurrentChar-48)<5)
- {
- sprintf(DataToPrint,"%c(%c",CurrentChar+37,CurrentChar+49);
- }
- break;
- }
- if(I==2)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar);
- break;
- }
- if(I==3)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar);
- break;
- }
- if(I==4)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar);
- break;
- }
- if(I==5)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar);
- break;
- }
- if(I==6)
- {
- /* Print the center guard pattern after the 6th character */
- sprintf(DataToPrint,"%s%c*",&DataToPrint,CurrentChar);
- break;
- }
- if(I==7)
- {
- /* Add 27 to the ASII value of characters 6-12 to print from character set+ C */
- /* this is required when printing to the right of the center guard pattern */
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar+27);
- break;
- }
- if(I==8)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar+27);
- break;
- }
- if(I==9)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar+27);
- break;
- }
- if(I==10)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar+27);
- break;
- }
- if(I==11)
- {
- sprintf(DataToPrint,"%s%c",&DataToPrint,CurrentChar+27);
- break;
- }
- if(I==12)
- {
- /* For the last character print the barcode without the human readable character, */
- /* the normal guard pattern and then the human readable character. */
- if((CurrentChar-48)>4)
- {
- sprintf(DataToPrint,"%s%c(%c",&DataToPrint,CurrentChar+59,CurrentChar+64);
- }
- if((CurrentChar-48)<5)
- {
- sprintf(DataToPrint,"%s%c(%c",&DataToPrint,CurrentChar+59,CurrentChar+37);
- }
- }
- break;
- }
- }
- /* Process 5 digit add on if it exists */
- if(strlen(EAN5AddOn)==5)
- {
- /* Get check digit for add on */
- Factor=3;
- weightedTotal=0;
- for(I = (int)strlen(EAN5AddOn);I >= 1;I--)
- {
- /* Get the value of each number starting at the end */
- CurrentChar=asc(mid(EAN5AddOn,I,1))-48;
- /* multiply by the weighting factor which is 3,9,3,9. */
- /* and add the sum together */
- if(Factor==3)
- {
- weightedTotal=weightedTotal+(CurrentChar*3);
- }
- if(Factor==1)
- {
- weightedTotal=weightedTotal+CurrentChar*9;
- }
- /* change factor for next calculation */
- Factor=4-Factor;
- }
- /* Find the CheckDigit by extracting the right-most number from weightedTotal */
- sprintf(Temp,"%i",weightedTotal);
- CheckDigit = asc(mid(Temp, (int)strlen(Temp), 1)) - 48;
- /* Now we must encode the add-on CheckDigit into the number sets */
- /* by using variable parity between character sets A and B */
- for(;;)
- {
- if(CheckDigit==0)
- {
- sprintf(Encoding,"BBAAA");
- break;
- }
- if(CheckDigit==1)
- {
- sprintf(Encoding,"BABAA");
- break;
- }
- if(CheckDigit==2)
- {
- sprintf(Encoding,"BAABA");
- break;
- }
- if(CheckDigit==3)
- {
- sprintf(Encoding,"BAAAB");
- break;
- }
- if(CheckDigit==4)
- {
- sprintf(Encoding,"ABBAA");
- break;
- }
- if(CheckDigit==5)
- {
- sprintf(Encoding,"AABBA");
- break;
- }
- if(CheckDigit==6)
- {
- sprintf(Encoding,"AAABB");
- break;
- }
- if(CheckDigit==7)
- {
- sprintf(Encoding,"ABABA");
- break;
- }
- if(CheckDigit==8)
- {
- sprintf(Encoding,"ABAAB");
- break;
- }
- if(CheckDigit==9)
- {
- sprintf(Encoding,"AABAB");
- }
- break;
- }
- /* Now that we have the total number including the check digit, determine character to print */
- /* for proper barcoding: */
- for(I=1;I <= (int)strlen(EAN5AddOn);I++)
- {
- /* Get the value of each number */
- /* it is encoded with variable parity */
- CurrentChar=asc(mid(EAN5AddOn,I,1))-48;
- CurrentEncoding=asc(mid(Encoding,I,1));
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- for(;;)
- {
- if(CurrentEncoding=='A')
- {
- if(CurrentChar==0)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,34);
- }
- if(CurrentChar==1)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,35);
- }
- if(CurrentChar==2)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,36);
- }
- if(CurrentChar==3)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,37);
- }
- if(CurrentChar==4)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,38);
- }
- if(CurrentChar==5)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,44);
- }
- if(CurrentChar==6)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,46);
- }
- if(CurrentChar==7)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,47);
- }
- if(CurrentChar==8)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,58);
- }
- if(CurrentChar==9)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,59);
- }
- break;
- }
- if(CurrentEncoding=='B')
- {
- if(CurrentChar==0)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,122);
- }
- if(CurrentChar==1)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,61);
- }
- if(CurrentChar==2)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,63);
- }
- if(CurrentChar==3)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,64);
- }
- if(CurrentChar==4)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,91);
- }
- if(CurrentChar==5)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,92);
- }
- if(CurrentChar==6)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,93);
- }
- if(CurrentChar==7)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,95);
- }
- if(CurrentChar==8)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,123);
- }
- if(CurrentChar==9)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,125);
- }
- }
-
- break;
- }
- /* add in the space & add-on guard pattern */
- for(;;)
- {
- if(I==1)
- {
- sprintf(Temp,"%c%s%c",43,&EANAddOnToPrint,33);
- sprintf(EANAddOnToPrint,"%s",&Temp);
- /* Now print add-on delineators between each add-on character */
- break;
- }
- if(I==2)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,33);
- break;
- }
- if(I==3)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,33);
- break;
- }
- if(I==4)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,33);
- break;
- }
- if(I==5)
- {
- }
- break;
- }
- }
- }
- /* Process 2 digit add on if it exists */
- if(strlen(EAN2AddOn)==2)
- {
- Tempi=(((asc(mid(EAN2AddOn,1,1))))-48)*10;
- Tempi=(Tempi + (asc(mid(EAN2AddOn,2,1))))-48;
- /* Get encoding for add on */
- for(I=0;I<=99;I=I+4)
- {
- if(Tempi==I)
- {
- sprintf(Encoding,"AA");
- }
- if(Tempi==I+1)
- {
- sprintf(Encoding,"AB");
- }
- if(Tempi==I+2)
- {
- sprintf(Encoding,"BA");
- }
- if(Tempi==I+3)
- {
- sprintf(Encoding,"BB");
- }
- }
- /* Now that we have the total number including the encoding */
- /* determine what to print */
- for(I=1;I <= (int)strlen(EAN2AddOn);I++)
- {
- /* Get the value of each number */
- /* it is encoded with variable parity */
- CurrentChar=asc(mid(EAN2AddOn,I,1))-48;
- CurrentEncoding=asc(mid(Encoding,I,1));
- /* Print different barcodes according to the location of the CurrentChar and CurrentEncoding */
- for(;;)
- {
- if(CurrentEncoding=='A')
- {
- if(CurrentChar==0)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,34);
- }
- if(CurrentChar==1)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,35);
- }
- if(CurrentChar==2)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,36);
- }
- if(CurrentChar==3)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,37);
- }
- if(CurrentChar==4)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,38);
- }
- if(CurrentChar==5)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,44);
- }
- if(CurrentChar==6)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,46);
- }
- if(CurrentChar==7)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,47);
- }
- if(CurrentChar==8)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,58);
- }
- if(CurrentChar==9)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,59);
- }
- break;
- }
- if(CurrentEncoding=='B')
- {
- if(CurrentChar==0)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,122);
- }
- if(CurrentChar==1)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,61);
- }
- if(CurrentChar==2)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,63);
- }
- if(CurrentChar==3)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,64);
- }
- if(CurrentChar==4)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,91);
- }
- if(CurrentChar==5)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,92);
- }
- if(CurrentChar==6)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,93);
- }
- if(CurrentChar==7)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,95);
- }
- if(CurrentChar==8)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,123);
- }
- if(CurrentChar==9)
- {
- sprintf(EANAddOnToPrint,"%s%c",&EANAddOnToPrint,125);
- }
- }
- break;
- }
- /* add in the space & add-on guard pattern */
- for(;;)
- {
- if(I==1)
- {
- sprintf(Temp,"%c%s%c",43,&EANAddOnToPrint,33);
- sprintf(EANAddOnToPrint,"%s",&Temp);
- /* Now print add-on delineators between each add-on character */
- break;
- }
- if(I==2)
- {
- }
- break;
- }
- }
- }
- /* Get Printable String */
- sprintf(PrintableString,"%s%s", &DataToPrint, &EANAddOnToPrint);
-
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_MSI (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- char DataToPrint[512];
- //DataToPrint = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
- int sprintBuffer = 0;
- int I;
-
- for(I = 1;I <= (int)strlen(DataToEncode);I++)
- {
-
- if(isdigit(asc(mid(DataToEncode, I, 1))))
- {
- sprintBuffer += sprintf(OnlyCorrectData + sprintBuffer, "%s", mid(DataToEncode, I, 1));
- }
- }
-
- sprintf(DataToPrint,"(%s%s)", OnlyCorrectData, CalcMSICheckDigit(OnlyCorrectData));
- iSize = (long)strlen(DataToPrint);
- strncpy(output, DataToPrint, strlen(DataToPrint));
- return 0;
- }
- char *CalcMSICheckDigit(char DataToEncode[])
- {
- int StringLength = (int)strlen(DataToEncode);
- char OddNumbers[30];
- char sOddNumberProduct[8];
- int OddDigit = TRUE;
- // int OddDigit = 1;
- int EvenNumberSum = 0;
- int BufferCounterOdd = 0;
- int BufferCounterEven = 0;
- int OddNumberProduct = 0;
- int OddNumberSum = 0;
- int CD = 0;
- int Idx = 0;
- static char sCD[1];
- for(Idx = StringLength;Idx >= 0;Idx--)
- {
- if(OddDigit == TRUE)
- {
- BufferCounterOdd += sprintf(OddNumbers + BufferCounterOdd, "%s", mid(DataToEncode, Idx, 1));
- //OddDigit = FALSE;
- OddDigit = 0;
- }
- else
- {
- EvenNumberSum += atoi(mid(DataToEncode, Idx, 1));
- //OddDigit = TRUE;
- OddDigit = 1;
- }
- }
-
-
- OddNumberProduct = atoi(OddNumbers) * 2;
-
- sprintf(sOddNumberProduct, "%d", OddNumberProduct);
- StringLength = (int)strlen(sOddNumberProduct);
- OddNumberSum = 0;
- for(Idx = 1;Idx <= StringLength;Idx++)
- {
- OddNumberSum += atoi(mid(sOddNumberProduct, Idx, 1));
- }
-
-
-
- OddNumberSum = OddNumberSum + EvenNumberSum;
-
-
-
- OddNumberSum = OddNumberSum % 10;
- if(OddNumberSum != 0)
- CD = 10 - OddNumberSum;
- else
- CD = 0;
- sprintf(sCD, "%i", CD);
- return sCD;
- }
- long IDAutomation_Code128HumanReadable (char *DataToEncode, int ApplyTilde, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
- char ReadableText[512];
- //ReadableText = new char[512];
- char StringToCheckFiltered[512];
- //StringToCheckFiltered = new char[512];
- char *RevFilteredString;
- int BufferCounter = 0;
- int BufferCounter2 = 0;
- int i = 0;
- int q = 0;
- int GoodData = 0;
- int FNCDone;
-
- for(i = 0;i < (int)strlen(DataToEncode);i++)
- {
- FNCDone = FALSE;
- if((int)asc(mid(DataToEncode, i + 1, 1)) != 126 || ApplyTilde == FALSE || strlen(DataToEncode) < 4)
- {
-
- if(asc(mid(DataToEncode, i + 1, 1)) == 212 && i <= (int)strlen(DataToEncode) - 3) {
-
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 2), ") ");
- i += 2;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 213 && i <= (int)strlen(DataToEncode) - 4)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 3), ") ");
- i += 3;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 214 && i <= (int)strlen(DataToEncode) - 5)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 4), ") ");
- i += 4;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 215 && i <= (int)strlen(DataToEncode) - 6)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 5), ") ");
- i += 5;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 216 && i <= (int)strlen(DataToEncode) - 7)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 6), ") ");
- i += 6;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 217 && i <= (int)strlen(DataToEncode) - 8)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 7), ") ");
- i += 7;
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) == 202 && i <= (int)strlen(DataToEncode) - 4 &&
- isdigit((int) DataToEncode[i + 1]) && isdigit((int) DataToEncode[i + 2]))
- {
-
-
- if(atoi(mid(DataToEncode, i + 2, 2)) == 80 || atoi(mid(DataToEncode, i + 2, 2)) == 81 ||
- (atoi(mid(DataToEncode, i + 2, 2)) <= 34 && atoi(mid(DataToEncode, i + 2, 2)) >= 31))
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 4), ") ");
- i += 4;
- FNCDone = TRUE;
- }
-
- if(FNCDone == FALSE)
- {
- if((atoi(mid(DataToEncode, i + 2, 2)) <= 49 && atoi(mid(DataToEncode, i + 2, 2)) >= 40) ||
- (atoi(mid(DataToEncode, i + 2, 2)) <= 25 && atoi(mid(DataToEncode, i + 2, 2)) >= 23))
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 3), ") ");
- i += 3;
- FNCDone = TRUE;
- }
- }
-
- if(FNCDone == FALSE)
- {
- if((atoi(mid(DataToEncode, i + 2, 2)) <= 30 && atoi(mid(DataToEncode, i + 2, 2)) >= 0) ||
- (atoi(mid(DataToEncode, i + 2, 2)) <= 99 && atoi(mid(DataToEncode, i + 2, 2)) >= 90))
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 2, 2), ") ");
- i += 2;
- FNCDone = TRUE;
- }
- }
-
- if(FNCDone == FALSE)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s%s%s"," (", mid(DataToEncode, i + 4, 4), ") ");
- i += 4;
- FNCDone = TRUE;
- }
- }
- else if(asc(mid(DataToEncode, i + 1, 1)) < 32)
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s", " ");
- else if(asc(mid(DataToEncode, i + 1, 1)) >= 32 && asc(mid(DataToEncode, i + 1, 1)) <= 126)
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s", mid(DataToEncode, i + 1, 1));
- }
- else
- {
-
-
- int char0 = (int) asc(mid(DataToEncode, i + 2, 1));
- int char1 = (int) asc(mid(DataToEncode, i + 3, 1));
- int char2 = (int) asc(mid(DataToEncode, i + 4, 1));
- if (i <= (int)strlen(DataToEncode) - 3 && isdigit(char0) && isdigit(char1)
- && isdigit(char2) )
- {
-
-
- char *tempNum = mid(DataToEncode,i + 2, 3);
- int convertedValue = atoi(mid(DataToEncode, i + 2, 3));
- if((convertedValue > 0 && convertedValue < 32))
- {
-
- BufferCounter += sprintf(ReadableText + BufferCounter, "%s", " ");
- i = i + 3;
- }
- else if(convertedValue == 197)
- i = i + 3;
- else if(convertedValue != 197)
- BufferCounter += sprintf(ReadableText + BufferCounter, "%c", DataToEncode[i]);
- }
-
- else if(((int)strlen(DataToEncode) > 5 && i > 1 && i <= (int)strlen(DataToEncode) - 3) && (int) DataToEncode[i + 1] == 109)
- {
-
- if(isdigit(DataToEncode[i + 2]) && isdigit(DataToEncode[i + 3]))
- {
- int NumCharsToConvert = atoi(mid(DataToEncode, i + 3, 2));
-
- if(i - (NumCharsToConvert - 1) >= 0)
- {
-
- char *StringToCheck = mid(DataToEncode, i - NumCharsToConvert + 1, NumCharsToConvert);
-
- int NumCharsFiltered = 0;
-
- GoodData = 0;
- BufferCounter2 = 0;
-
- for(q = (int)strlen(StringToCheck);q > 0 ;q--)
- {
- GoodData = FALSE;
- if((int)StringToCheck[q - 1] > 0 && (int)StringToCheck[q - 1] <= 126 && isdigit((int)StringToCheck[q - 1]))
- GoodData = TRUE;;
-
- if(GoodData)
- {
- if(NumCharsFiltered < NumCharsToConvert )
- {
- BufferCounter2 += sprintf(StringToCheckFiltered + BufferCounter2, "%s", mid(StringToCheck, q, 1));
- NumCharsFiltered++;
- }
- else
- break;
- }
- }
-
-
- if(StringToCheckFiltered == "")
- GoodData = FALSE;
- else
- {
- GoodData = TRUE;
- RevFilteredString = strrev(StringToCheckFiltered);
- }
- if(GoodData != FALSE)
- {
- BufferCounter += sprintf(ReadableText + BufferCounter, "%c", FindMod10Digit(RevFilteredString));
- i += 3;
- }
- else
- BufferCounter += sprintf(ReadableText + BufferCounter, "%c", DataToEncode[i]);
- }
- else
- BufferCounter += sprintf(ReadableText + BufferCounter, "%c", DataToEncode[i]);
- }
- else
- BufferCounter += sprintf(ReadableText + BufferCounter, "%c", DataToEncode[i]);
- }
- }
- }
-
- iSize = (long)strlen(ReadableText);
- strncpy(output, ReadableText, strlen(ReadableText));
-
- return 0;
- }
- long IDAutomation_UCC128 (char *DataToEncode, char *output, long iSize)
- {
- char StringToPass[512];
- //StringToPass = new char[512];
- int char0 = (int) asc(mid(DataToEncode, 1, 1));
- // check for FNC1 character, if one is there; do nothing
- if(char0 == 202 || (char0 > 211 && char0 < 218))
- sprintf(StringToPass, "%s", DataToEncode);
-
- else//insert FNC1 in the begining of the string
- sprintf(StringToPass, "%c%s", (char)202, DataToEncode);
- int iTilde = 1;
- IDAutomation_Code128(StringToPass, iTilde, output, iSize);
-
- return 0;
- }
- /*****************************************************************/
- /* ANSI C Functions for IDAutomation Barcode Fonts */
- /* ?Copyright 2002- 2007, IDAutomation.com, Inc. */
- /* All rights reserved. */
- /* Redistribution and use of this code in source and/or binary */
- /* forms, with or without modification, are permitted provided */
- /* that: (1) all copies of the source code retain the above */
- /* unmodified copyright notice and this entire unmodified */
- /* section of text, (2) You or Your organization owns a valid */
- /* Developer License to this product from IDAutomation.com */
- /* and, (3) when any portion of this code is bundled in any */
- /* form with an application, a valid notice must be provided */
- /* within the user documentation, start-up screen or in the */
- /* help-about section of the application that specifies */
- /* IDAutomation.com as the provider of the Software bundled */
- /* with the application. */
- /*****************************************************************/
- long IDAutomation_Code128 (char *DataToEncode, int ApplyTilde, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
- char PrintableString[512];
- //PrintableString = new char[512];
- char OnlyCorrectData[512];
- //OnlyCorrectData = new char[512];
-
- char StringToCheckFiltered[512];
- //StringToCheckFiltered = new char[512];
-
- char tildeStringToCheck[512];
- //tildeStringToCheck = new char[512];
-
-
-
-
- char CurrentEncoding;
- char StartChar;
- char StopChar;
- int DataToEncodeLength = 0;
- int CurrentValue = 0;
- int i = 0;
- int GoodData = 0;
- int q = 0;
- char *RevFilteredString;
- int BufferCounter = 0;
- int L_BufferCounter = 0;
- int WeightedTotal = 0;
- int StringLength = 0;
- int CurrentCharNumber = 0;
- int CheckDigitValue = 0;
-
- DataToEncodeLength = (int)strlen(DataToEncode);
- PrintableString[0]=(char)0;
- StopChar = (char)206;
-
- if(((int)asc(mid(DataToEncode, 1, 1))) < 32)
- {
- StartChar = (char) 203;
- CurrentEncoding = 'A';
- }
-
- if(((int) asc(mid(DataToEncode, 1, 1)) > 31 && (int) asc(mid(DataToEncode, 1, 1)) < 127) || ((int) asc(mid(DataToEncode, 1, 1)) == 197))
- {
- StartChar = (char) 204;
- CurrentEncoding = 'B';
- }
-
- if(DataToEncodeLength > 3 && isdigit(DataToEncode[0]) && isdigit(DataToEncode[1]) &&
- isdigit(DataToEncode[2]) && isdigit(DataToEncode[3]))
- {
- StartChar = (char) 205;
- CurrentEncoding = 'C';
- }
- if ((int) asc(mid(DataToEncode, 1, 1)) == 202 || ((int) asc(mid(DataToEncode, 1, 1)) >= 212 && (int) asc(mid(DataToEncode, 1, 1)) <= 217))
- {
- StartChar = (char) 205;
- CurrentEncoding = 'C';
- }
-
- for(i = 0; i <= DataToEncodeLength - 1; i++)
- {
- if((DataToEncodeLength > 5 && i > 1 && i <= DataToEncodeLength - 3) && (int) DataToEncode[i] == 126
- && (int) DataToEncode[i + 1] == 109 && ApplyTilde)
- {
-
- if(isdigit(DataToEncode[i + 2]) && isdigit(DataToEncode[i + 3]))
- {
- int NumCharsToConvert = atoi(mid(DataToEncode, i + 3, 2));
-
- if(i - (NumCharsToConvert - 1) >= 0)
- {
-
- char *StringToCheck = mid(DataToEncode, i - NumCharsToConvert + 1, NumCharsToConvert);
- char StringToCheckFiltered[40];
- int NumCharsFiltered = 0;
-
- GoodData = 0;
- BufferCounter = 0;
-
- for(q = (int)strlen(StringToCheck);q > 0 ;q--)
- {
- GoodData = isdigit((int)StringToCheck[q - 1]);
- if(GoodData)
- {
- if(NumCharsFiltered < NumCharsToConvert )
- {
- BufferCounter += sprintf(StringToCheckFiltered + BufferCounter, "%s", mid(StringToCheck, q, 1));
- NumCharsFiltered++;
- }
- else
- break;
- }
- }
-
-
- if(StringToCheckFiltered == "")
- GoodData = FALSE;
- else
- {
- GoodData = TRUE;
- RevFilteredString = strrev(StringToCheckFiltered);
- }
- if(GoodData != FALSE)
- {
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", FindMod10Digit(RevFilteredString));
- i += 3;
- }
- else
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- }
- else
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- }
- else
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- }
-
- else if ((DataToEncodeLength >= 4 && i <= DataToEncodeLength - 3) && (int) DataToEncode[i] == 126
- && isdigit((int) DataToEncode[i + 1]) && isdigit((int) DataToEncode[i + 2])
- && isdigit((int) DataToEncode[i + 3]) && ApplyTilde)
- {
-
- int convertedValue = atoi(mid(DataToEncode, i + 2, 3));
- if((convertedValue > 0 && convertedValue < 32) || convertedValue == 197 || convertedValue == 202 ||
- (convertedValue > 211 && convertedValue < 218))
- {
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", (char) (convertedValue));
- i = i + 3;
- }
- else
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- }
- else if((DataToEncodeLength >= 2 && i <= DataToEncodeLength - 2) && (int) DataToEncode[i] == 126
- && (int) DataToEncode[i + 1] == 126 && ApplyTilde)
- {
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- i = i + 1;
- }
- else
- L_BufferCounter += sprintf(OnlyCorrectData + L_BufferCounter,"%c", DataToEncode[i]);
- }
- L_BufferCounter = 0;
-
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", StartChar);
- DataToEncodeLength = (int)strlen(OnlyCorrectData);
-
- for(i = 0; i <= DataToEncodeLength - 1; i++)
- {
-
- if( i < DataToEncodeLength - 1 && ((int) asc(mid(OnlyCorrectData, i + 1, 1)) == 202 || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 212 || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 213
- || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 214 || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 215
- || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 216 || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 217 || (int) asc(mid(OnlyCorrectData, i + 1, 1)) == 218))
- {
-
-
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)202);
-
- }
-
- else if
-
-
- ( (DataToEncodeLength > 3 && i <= (DataToEncodeLength - 2)) &&
- ((isdigit((int) OnlyCorrectData[i]) && isdigit((int) OnlyCorrectData[i + 1]) &&
- isdigit((int) OnlyCorrectData[i + 2]) && isdigit((int) OnlyCorrectData[i + 3]) ) ||
- (i <= DataToEncodeLength - 1 && isdigit((int) OnlyCorrectData[i]) &&
- isdigit((int) OnlyCorrectData[i + 1]) && CurrentEncoding == 'C' )))
-
- {
-
- if (CurrentEncoding != 'C')
- {
- int j = i;
- int Factor = 3;
- while (j <= DataToEncodeLength-1 && isdigit((int)(OnlyCorrectData[j])))
- {
- Factor = (4 - Factor);
- j++;
- }
-
-
- if (Factor == 1)
- {
-
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter ,"%c", DataToEncode[i]);
- i++;
- }
- Factor = 0;
- }
-
- if(CurrentEncoding != 'C')
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)199);
- CurrentEncoding = 'C';
- }
- /* Get the value of each number pair */
- CurrentValue = atoi(mid(OnlyCorrectData, i + 1, 2));
- /* Get the DataToPrint */
- if(CurrentValue < 95 && CurrentValue > 0)
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)(CurrentValue + 32));
- }
- if(CurrentValue > 94)
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)(CurrentValue + 100));
- }
- if(CurrentValue == 0)
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)194);
- }
-
-
- i++;
- }
-
- else if((i <= DataToEncodeLength - 1) && (((int) asc(mid(OnlyCorrectData, i + 1, 1)) < 32) || ((CurrentEncoding == 'A') && ((int) asc(mid(OnlyCorrectData, i + 1, 1)) < 96))))
- {
- if (CurrentEncoding != 'A')
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)201);
- CurrentEncoding = 'A';
- }
- if ((int) OnlyCorrectData[i] < 32)
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)((int) OnlyCorrectData[i] + 96));
- }
- else if ((int) OnlyCorrectData[i] > 31)
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)OnlyCorrectData[i]);
- }
- else if ((int) OnlyCorrectData[i] == 32)
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)194);
- }
-
- else if((int) asc(mid(OnlyCorrectData, i + 1, 1)) == 197)
- {
- if(CurrentEncoding == 'C')
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)200);
- CurrentEncoding = 'B';
- }
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", OnlyCorrectData[i]);
- }
-
- else if ((i <= DataToEncodeLength - 1) && ((int) asc(mid(OnlyCorrectData, i + 1, 1)) > 31 && (int) asc(mid(OnlyCorrectData, i + 1, 1)) < 127))
- {
-
- if (CurrentEncoding != 'B')
- {
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)200);
- CurrentEncoding = 'B';
- }
-
- if ((int) OnlyCorrectData[i] == 32)
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)194);
- else
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", OnlyCorrectData[i]);
- }
- }
-
- WeightedTotal = (asc(&StartChar) - 100);
- StringLength = (int)strlen(PrintableString);
- CurrentCharNumber = 0;
- CurrentValue = 0;
- CheckDigitValue = 0;
- for(q = 2;q <= StringLength;q++)
- {
- CurrentCharNumber = asc(mid(PrintableString, q, 1));
- if(CurrentCharNumber < 135)
- CurrentValue = (CurrentCharNumber - 32);
- else if(CurrentCharNumber > 134 && CurrentCharNumber != 194)
- CurrentValue = (CurrentCharNumber - 100);
- else if(CurrentCharNumber == 194)
- CurrentValue = 0;
- CurrentValue = CurrentValue * (q - 1);
- WeightedTotal = WeightedTotal + CurrentValue;
- }
-
- CheckDigitValue = (WeightedTotal % 103);
- if(CheckDigitValue < 95 && CheckDigitValue > 0)
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)(CheckDigitValue + 32));
- else if(CheckDigitValue > 94)
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)(CheckDigitValue + 100));
-
-
- else if(CheckDigitValue == 0)
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", (char)(194));
-
- L_BufferCounter += sprintf(PrintableString + L_BufferCounter,"%c", StopChar);
- iSize = (long)strlen(PrintableString);
- strncpy(output, PrintableString, strlen(PrintableString));
- return 0;
- }
-
- char FindMod10Digit(char *input)
- {
- int remainder;
- int M10Factor = 0;
- int M10WeightedTotal = 0;
- int M10StringLength = 0;
- int M10I = 0;
- M10Factor = 3;
- M10WeightedTotal = 0;
- M10StringLength = (int)strlen(input);
- for(M10I = M10StringLength;M10I > 0;M10I--)
- {
-
- M10WeightedTotal = M10WeightedTotal + (atoi(mid(input, M10I, 1)) * M10Factor);
- M10Factor = 4 - M10Factor;
- }
- remainder = M10WeightedTotal % 10;
- if (remainder == 0)
- return (char)48;
- else
- return (char) ((10 - remainder) + 48);
- }
- void UPCe7to11(char DataToExpand[])
- {
-
-
- if (strlen(DataToExpand) == 6)
- {
- char buf[255];
- int n = 1 + (int)strlen(DataToExpand);
- int i =0;
- for (i=n-1;i>=0;i--)
- {
- buf[n] = DataToExpand[i];
- n--;
- }
- buf[0] = '0';
-
- strcpy(DataToExpand,buf);
- }
-
- char D1 = DataToExpand[0];
- char D2 = DataToExpand[1];
- char D3 = DataToExpand[2];
- char D4 = DataToExpand[3];
- char D5 = DataToExpand[4];
- char D6 = DataToExpand[5];
- char D7 = DataToExpand[6];
-
- switch (D7)
- {
- case '0':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = '0'; DataToExpand[4] = '0'; DataToExpand[5] = '0';
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = D4;
- DataToExpand[9] = D5; DataToExpand[10] = D6;
- break;
- case '1':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D7; DataToExpand[4] = '0'; DataToExpand[5] = '0';
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = D4;
- DataToExpand[9] = D5; DataToExpand[10] = D6;
- break;
- case '2':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D7; DataToExpand[4] = '0'; DataToExpand[5] = '0';
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = D4;
- DataToExpand[9] = D5; DataToExpand[10] = D6;
- break;
- case '3':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = '0'; DataToExpand[5] = '0';
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = D5; DataToExpand[10] = D6;
- break;
- case '4':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = '0';
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D6;
- break;
- case '5':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = D6;
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D7;
- break;
- case '6':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = D6;
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D7;
- break;
- case '7':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = D6;
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D7;
- break;
- case '8':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = D6;
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D7;
- break;
- case '9':
- DataToExpand[0] = D1; DataToExpand[1] = D2; DataToExpand[2] = D3;
- DataToExpand[3] = D4; DataToExpand[4] = D5; DataToExpand[5] = D6;
- DataToExpand[6] = '0'; DataToExpand[7] = '0'; DataToExpand[8] = '0';
- DataToExpand[9] = '0'; DataToExpand[10] = D7;
- break;
- }
- DataToExpand[11] =(int) NULL;
- }
- /*********************************************************************/
- /* Visual Basic / VBA Functions for Bar Code Fonts 5.01*/
- /* Copyright, IDAutomation.com, Inc. 2000-2005. All rights reserved.*/
- /**/
- /* Visit http://www.idautomation.com/fonts/tools/vba/ for more*/
- /* information about the functions in this file.*/
- /**/
- /* You may incorporate our Source Code in your application*/
- /* only if you own a valid license from IDAutomation.com, Inc.*/
- /* for the associated font and this text and the copyright notices*/
- /* are not removed from the source code.(/
- /**/
- /* Distributing our source code or fonts outside your*/
- /* organization requires a Developer License. */
- /*********************************************************************/
- long IDAutomation_UPCe (char *DataToEncode, char *output, long iSize)
- {
- if(DataToEncode == NULL)
- return 1;
- if(strlen(DataToEncode) == 0)
- return 1;
-
- int StringLength = 0;
- int I = 0;
- char LPrintableString[512];
- //LPrintableString = new char[512];
- char ActualDataToEncode[20];
- //ActualDataToEncode = new char[20];
- char DataToPrint[512];
- //DataToPrint = new char[512];
-
- char EAN2AddOn[3];
- //EAN2AddOn = new char[3];
-
- char OnlyCorrectData[20];
- //OnlyCorrectData = new char[20];
- char EAN5AddOn[6];
- //EAN5AddOn = new char[6];
- char EANAddOnToPrint[11];
- //EANAddOnToPrint = new char[11];
-
- int Factor = 3;
- int WeightedTotal = 0;
- int CheckDigit = 0;
- char *Encoding;
- int CurrentNumber;
- char midEncoding;
- char *sCheck = 0;
- int bufferCounter = 0;
-
- char *D1;
- char *D2;
- char *D3;
- char *D4;
- char *D5;
- char *D6;
- char *D7;
- char *D8;
- char *D9;
- char *D10;
- char *D11;
- char *D12;
-
- StringLength = (int)strlen(DataToEncode);
- LPrintableString[0]=(char)0;
-
- if(StringLength > 20)
- StringLength = 20;
-
- for(I = 0;I < StringLength;I++)
- {
- if(isdigit((int)DataToEncode[I]))
- {
- bufferCounter += sprintf(OnlyCorrectData + bufferCounter, "%c", DataToEncode[I]);
- }
-
- }
-
-
- if(strlen(OnlyCorrectData) == 6 || strlen(OnlyCorrectData) == 7 || strlen(OnlyCorrectData) == 8)
- {
- UPCe7to11(OnlyCorrectData);
- }
-
- if(strlen(OnlyCorrectData) < 11)
- {
- sprintf(LPrintableString,"%s","00005000000");
- return 0;
- }
- if(strlen(OnlyCorrectData) == 15)
- {
- sprintf(LPrintableString,"%s","00005000000");
- return 0;
- }
- if(strlen(OnlyCorrectData) > 18 && OnlyCorrectData[11] != (int) NULL)
- {
- sprintf(LPrintableString,"%s","00005000000");
- return 0;
- }
- if(strlen(OnlyCorrectData) == 12)
- sprintf(LPrintableString,"%s", mid(OnlyCorrectData, 1, 11));
- if(strlen(OnlyCorrectData) == 14)
- sprintf(LPrintableString,"%s%s", mid(OnlyCorrectData, 1, 11), mid(OnlyCorrectData, 13, 2));
- if(strlen(OnlyCorrectData) == 17)
- sprintf(LPrintableString,"%s%s", mid(OnlyCorrectData, 1, 11), mid(OnlyCorrectData, 13, 5));
-
- if(strlen(OnlyCorrectData) == 16)
- sprintf(EAN5AddOn,"%s", mid(OnlyCorrectData, 12, 5));
- else if(strlen(OnlyCorrectData) == 13)
- {
- sprintf(EAN2AddOn,"%s", mid(OnlyCorrectData, 12, 2));
- }
- else
- {
- sprintf(EAN2AddOn,"%s", "");
- sprintf(EAN5AddOn,"%s", "");
- sprintf(EANAddOnToPrint,"%s", "");
- }
-
- if(strlen(OnlyCorrectData) > 11)
- sprintf(OnlyCorrectData,"%s", mid(OnlyCorrectData, 1, 11));
-
-
- Factor = 3;
- WeightedTotal = 0;
-
-
- for(I = (int)strlen(OnlyCorrectData);I >= 0;I--)
- {
-
- CurrentNumber = atoi(mid(OnlyCorrectData, I, 1));
-
- WeightedTotal = WeightedTotal + (CurrentNumber * Factor);
-
- Factor = 4 - Factor;
- }
-
- I = (WeightedTotal % 10);
- if(I != 0)
- CheckDigit = (10 - I);
- else
- CheckDigit = 0;
- sprintf(OnlyCorrectData,"%s%i", OnlyCorrectData, CheckDigit);
-
- D1 = mid(OnlyCorrectData, 1, 1);
- D2 = mid(OnlyCorrectData, 2, 1);
- D3 = mid(OnlyCorrectData, 3, 1);
- D4 = mid(OnlyCorrectData, 4, 1);
- D5 = mid(OnlyCorrectData, 5, 1);
- D6 = mid(OnlyCorrectData, 6, 1);
- D7 = mid(OnlyCorrectData, 7, 1);
- D8 = mid(OnlyCorrectData, 8, 1);
- D9 = mid(OnlyCorrectData, 9, 1);
- D10 = mid(OnlyCorrectData, 10, 1);
- D11 = mid(OnlyCorrectData, 11, 1);
- D12 = mid(OnlyCorrectData, 12, 1);
-
- if((atoi(D11) == 5 || atoi(D11) == 6 || atoi(D11) == 7 || atoi(D11) == 8 || atoi(D11) == 9) &&
- (atoi(D6) != 0 && atoi(D7) == 0 && atoi(D8) == 0 && atoi(D9) == 0 && atoi(D10) == 0))
- {
- sprintf(ActualDataToEncode, "%s%s%s%s%s%s", D2, D3, D4, D5, D6, D11);
- }
-
- else if((atoi(D6) == 0 && atoi(D7) == 0 && atoi(D8) == 0 && atoi(D9) == 0 && atoi(D10) == 0) && atoi(D5) != 0)
- {
- sprintf(ActualDataToEncode, "%s%s%s%s%s%s", D2, D3, D4, D5, D11, "4");
- }
-
-
- else if((atoi(D5) == 0 && atoi(D6) == 0 && atoi(D7) == 0 && atoi(D8) == 0)
- && (atoi(D4) == 1 || atoi(D4) == 2 || atoi(D4) == 0))
- {
- sprintf(ActualDataToEncode, "%s%s%s%s%s%s", D2, D3, D9, D10, D11, D4);
- }
-
- else if((atoi(D5) == 0 && atoi(D6) == 0 && atoi(D7) == 0 && atoi(D8) == 0 && atoi(D9) == 0) &&
- (atoi(D4) == 3 || atoi(D4) == 4 || atoi(D4) == 5 || atoi(D4) == 6 || atoi(D4) == 7 || atoi(D4) == 8 || atoi(D4) == 9) )
- {
- sprintf(ActualDataToEncode, "%s%s%s%s%s%s", D2, D3, D4, D10, D11, "3");
- }
- else
- {
-
- sprintf(ActualDataToEncode, "%s", OnlyCorrectData);
- }
-
-
- if(strlen(ActualDataToEncode) == 6)
- {
-
- if(atoi(D1) == 1)
- {
- switch(atoi(D12))
- {
- case 0:
- Encoding = "AAABBB";
- break;
- case 1:
- Encoding = "AABABB";
- break;
- case 2:
- Encoding = "AABBAB";
- break;
- case 3:
- Encoding = "AABBBA";
- break;
- case 4:
- Encoding = "ABAABB";
- break;
- case 5:
- Encoding = "ABBAAB";
- break;
- case 6:
- Encoding = "ABBBAA";
- break;
- case 7:
- Encoding = "ABABAB";
- break;
- case 8:
- Encoding = "ABABBA";
- break;
- case 9:
- Encoding = "ABBABA";
- break;
- }
- }
-
- else
- {
- switch(atoi(D12))
- {
- case 0:
- Encoding = "BBBAAA";
- break;
- case 1:
- Encoding = "BBABAA";
- break;
- case 2:
- Encoding = "BBAABA";
- break;
- case 3:
- Encoding = "BBAAAB";
- break;
- case 4:
- Encoding = "BABBAA";
- break;
- case 5:
- Encoding = "BAABBA";
- break;
- case 6:
- Encoding = "BAAABB";
- break;
- case 7:
- Encoding = "BABABA";
- break;
- case 8:
- Encoding = "BABAAB";
- break;
- case 9:
- Encoding = "BAABAB";
- break;
- }
- }
- bufferCounter = 0;
- for(I = 1;I <= (int)strlen(ActualDataToEncode);I++)
- {
- if(I == 1)
- {
- if(asc(mid(OnlyCorrectData, I, 1)) == 48)
- {
- bufferCounter += sprintf(DataToPrint, "%c%s", (char)85, "(");
- }
- else
- {
- bufferCounter += sprintf(DataToPrint, "%c%s", (char)86, "(");
- }
- }
- CurrentNumber = asc(mid(ActualDataToEncode, I, 1));
-
- midEncoding = Encoding[I - 1];
- switch(midEncoding)
- {
- case 'A':
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)CurrentNumber);
- break;
- case 'B':
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 17));
- break;
- }
-
- switch(I)
- {
-
- case 1:
-
- /* if(atoi(D1) == 0)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s", (char)85, "(");
- }
- if(atoi(D1) == 1)
- {
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s", (char)86, "(");
- }*/
- break;
- case 6:
-
- if(atoi(D12) > 4)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s%c", ")", (char)(asc(D12) + 64));
- if(atoi(D12) < 5)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%s%c", ")", (char)(asc(D12) + 37));
- break;
- }
- }
- }
-
-
- bufferCounter = 0;
- if(strlen(ActualDataToEncode) != 6)
- {
- for(I = 1;I <= (int)strlen(ActualDataToEncode);I++)
- {
- CurrentNumber = asc(mid(ActualDataToEncode, I, 1));
-
- switch(I)
- {
- case 1:
-
-
- if(atoi(mid(ActualDataToEncode, I, 1)) > 4)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s%c", (char)(CurrentNumber + 64), "(", (char)(CurrentNumber + 49));
- if(atoi(mid(ActualDataToEncode, I, 1)) < 5)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s%c", (char)(CurrentNumber + 37), "(", (char)(CurrentNumber + 49));
- break;
- case 2:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", mid(ActualDataToEncode, I, 1));
- break;
- case 3:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", mid(ActualDataToEncode, I, 1));
- break;
- case 4:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", mid(ActualDataToEncode, I, 1));
- break;
- case 5:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", mid(ActualDataToEncode, I, 1));
- break;
- case 6:
-
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s", mid(ActualDataToEncode, I, 1), "*");
- break;
- case 7:
-
-
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 27));
- break;
- case 8:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 27));
- break;
- case 9:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 27));
- break;
- case 10:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 27));
- break;
- case 11:
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c", (char)(CurrentNumber + 27));
- break;
- case 12:
-
-
- if(atoi(mid(ActualDataToEncode, I, 1)) > 4)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s%c", (char)(CurrentNumber + 59), ")", (char)(CurrentNumber + 64));
- if(atoi(mid(ActualDataToEncode, I, 1)) < 5)
- bufferCounter += sprintf(DataToPrint + bufferCounter, "%c%s%c", (char)(CurrentNumber + 59), ")", (char)(CurrentNumber + 37));
- break;
- }
- }
- }
-
-
- if(strlen(EAN5AddOn) == 5)
- {
-
- Factor = 3;
- WeightedTotal = 0;
- for(I= (int)strlen(EAN5AddOn);I >= 0;I--)
- {
-
- CurrentNumber = atoi(mid(EAN5AddOn, I, 1));
-
- if(Factor = 3)
- WeightedTotal = WeightedTotal + (CurrentNumber * 3);
- if(Factor = 1 )
- WeightedTotal = WeightedTotal + (CurrentNumber * 9);
-
-
- Factor = 4 - Factor;
- }
-
-
- sprintf(sCheck,"%i", WeightedTotal);
- CheckDigit = atoi(mid(sCheck, (int)strlen(sCheck), 1));
-
-
-
- switch(CheckDigit)
- {
- case 0:
- Encoding = "BBAAA";
- break;
- case 1:
- Encoding = "BABAA";
- break;
- case 2:
- Encoding = "BAABA";
- break;
- case 3:
- Encoding = "BAAAB";
- break;
- case 4:
- Encoding = "ABBAA";
- break;
- case 5:
- Encoding = "AABBA";
- break;
- case 6:
- Encoding = "AAABB";
- break;
- case 7:
- Encoding = "ABABA";
- break;
- case 8:
- Encoding = "ABAAB";
- break;
- case 9:
- Encoding = "AABAB";
- break;
- }
- //Now that we have the total number including the check digit, determine character to print for proper barcoding:
- bufferCounter = 0;
- for(I = 1;I <= (int)strlen(EAN5AddOn);I++)
- {
- //Get the value of each number. It is encoded with variable parity
- CurrentNumber = atoi(mid(EAN5AddOn, I, 1));
- //Print different barcodes according to the location of the CurrentChar and CurrentEncoding
- midEncoding = Encoding[I - 1];
- switch(midEncoding)
- {
- case 'A':
- if(CurrentNumber == 0)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)34);
- if(CurrentNumber == 1)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)35);
- if(CurrentNumber == 2)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)36);
- if(CurrentNumber == 3)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)37);
- if(CurrentNumber == 4)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)38);
- if(CurrentNumber == 5)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)44);
- if(CurrentNumber == 6)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)46);
- if(CurrentNumber == 7)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)47);
- if(CurrentNumber == 8)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)58);
- if(CurrentNumber == 9)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)59);
- break;
- case 'B':
- if(CurrentNumber == 0)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)122);
- if(CurrentNumber == 1)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)61);
- if(CurrentNumber == 2)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)63);
- if(CurrentNumber == 3)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)64);
- if(CurrentNumber == 4)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)91);
- if(CurrentNumber == 5)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)92);
- if(CurrentNumber == 6)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)93);
- if(CurrentNumber == 7)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)95);
- if(CurrentNumber == 8)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)123);
- if(CurrentNumber == 9)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)125);
- break;
- }
-
- //add in the space & add-on guard pattern
- switch(I)
- {
- case 1:
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c%s%c", (char)43, EANAddOnToPrint, (char)33);
- break;
- //Now print add-on delineators between each add-on character
- case 2:
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)33);
- break;
- case 3:
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)33);
- break;
- case 4:
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)33);
- break;
- case 5:
- //EANAddOnToPrint = EANAddOnToPrint
- break;
- }
- } //end for loop
- } //end 5 digit supplement work
-
- //Now for the 2 digit add on
- if(strlen(EAN2AddOn) == 2)
- {
- //Get encoding for add on
- for(I = 0;I <= 99;I++)
- {
- if(atoi(EAN2AddOn) == I)
- Encoding = "AA";
- if(atoi(EAN2AddOn) == I + 1)
- Encoding = "AB";
- if(atoi(EAN2AddOn) == I + 2)
- Encoding = "BA";
- if(atoi(EAN2AddOn) == I + 3)
- Encoding = "BB";
- }//end for loop
-
- bufferCounter = 0;
- //Now that we have the total number including the encoding determine what to print
- for(I = 1;I <= (int)strlen(EAN2AddOn);I++)
- {
- CurrentNumber = atoi(mid(EAN2AddOn, I, 1));
- midEncoding = Encoding[I - 1];
- //Print different barcodes according to the location of the CurrentChar and CurrentEncoding
- switch(midEncoding)
- {
- case 'A':
- if(CurrentNumber == 0)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)34);
- if(CurrentNumber == 1)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)35);
- if(CurrentNumber == 2)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)36);
- if(CurrentNumber == 3)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)37);
- if(CurrentNumber == 4)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)38);
- if(CurrentNumber == 5)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)44);
- if(CurrentNumber == 6)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)46);
- if(CurrentNumber == 7)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)47);
- if(CurrentNumber == 8)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)58);
- if(CurrentNumber == 9)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)59);
- break;
- case 'B':
- if(CurrentNumber == 0)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)122);
- if(CurrentNumber == 1)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)61);
- if(CurrentNumber == 2)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)63);
- if(CurrentNumber == 3)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)64);
- if(CurrentNumber == 4)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)91);
- if(CurrentNumber == 5)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)92);
- if(CurrentNumber == 6)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)93);
- if(CurrentNumber == 7)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)95);
- if(CurrentNumber == 8)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)123);
- if(CurrentNumber == 9)
- bufferCounter += sprintf(EANAddOnToPrint + bufferCounter, "%c", (char)125);
- break;
- } //end switch
- //add in the space & add-on guard pattern
- switch(I)
- {
- case 1:
- bufferCounter += sprintf(EANAddOnToPrint, "%c%s%c", (char)43, EANAddOnToPrint, (char)33);
- break;
- case 2:
- //EANAddOnToPrint = EANAddOnToPrint
- break;
- }
- }//end loop thru characers
- } //end ean 2 digit supp processing
-
- //Now we have everything together
- sprintf(LPrintableString, "%s%s", DataToPrint, EANAddOnToPrint);
- // Allow the string to return to the proper size.
- iSize = (long)strlen(LPrintableString);
- strncpy(output, LPrintableString, strlen(LPrintableString));
- return 0;
- } //end upce
- **********************
- javaʵÏÖ
- **********************
- /********************************************************************
- /* Java Source Code for Linear Barcode Fonts Version 2006
- /* Copyright ?2000-2006 IDAutomation.com, Inc. All rights reserved.
- /* US Registered Copyright #Txu983-177
- /*
- /* You may incorporate this Source Code in your application
- /* only if you own a valid license from IDAutomation.com, Inc.
- /* for the associated product, provided that this copyright
- /* notice and text are not removed from the source code.
- /*
- /* Distributing this source code outside your
- /* organization requires a Developer License.
- /********************************************************************/
- class FontIDAutomation
- {
- public static void main ( String [] args )
- {
- //This is an example of how to format the barcode font for output
- System.out.println( "Output: " + Code128b("123456789") );
- }
- /** This is the complete method for Code128a
- */
- static String Code128a( String DataToEncode )
- {
- char C128_Start = (char)203;
- char C128_Stop = (char)206;
- String Printable_string = "";
- char CurrentChar;
- int CurrentValue=0;
- int weightedTotal=0;
- int CheckDigitValue=0;
- char C128_CheckDigit='w';
-
- DataToEncode = DataToEncode.trim();
- weightedTotal = ((int)C128_Start) - 100;
- for( int i = 1; i <= DataToEncode.length(); i++ )
- {
- //get the value of each character
- CurrentChar = DataToEncode.charAt(i-1);
- if( ((int)CurrentChar) < 135 )
- CurrentValue = ((int)CurrentChar) - 32;
- if( ((int)CurrentChar) > 134 )
- CurrentValue = ((int)CurrentChar) - 100;
-
- CurrentValue = CurrentValue * i;
- weightedTotal = weightedTotal + CurrentValue;
- }
- //divide the WeightedTotal by 103 and get the remainder,
- //this is the CheckDigitValue
- CheckDigitValue = weightedTotal % 103;
- if( (CheckDigitValue < 95) && (CheckDigitValue > 0) )
- C128_CheckDigit = (char)(CheckDigitValue + 32);
- if( CheckDigitValue > 94 )
- C128_CheckDigit = (char)(CheckDigitValue + 100);
- if( CheckDigitValue == 0 ){
- C128_CheckDigit = (char)194;
- }
-
- Printable_string = C128_Start + DataToEncode + C128_CheckDigit + C128_Stop + " ";
- return Printable_string;
- }
- /** This is the complete method for Code128b
- */
- static String Code128b( String DataToEncode )
- {
- char C128_Start = (char)204;
- char C128_Stop = (char)206;
- String Printable_string = "";
- String temp = "";
- char CurrentChar;
- int CurrentValue=0;
- int weightedTotal=0;
- int CheckDigitValue=0;
- char C128_CheckDigit='w';
- DataToEncode = DataToEncode.trim();
- weightedTotal = ((int)C128_Start) - 100;
- for( int i = 1; i <= DataToEncode.length(); i++ )
- {
- //get the value of each character
- CurrentChar = DataToEncode.charAt(i-1);
- if( ((int)CurrentChar) < 135 )
- CurrentValue = ((int)CurrentChar) - 32;
- if( ((int)CurrentChar) > 134 )
- CurrentValue = ((int)CurrentChar) - 100;
-
- CurrentValue = CurrentValue * i;
- weightedTotal = weightedTotal + CurrentValue;
- //added by tb, replaces the spaces with the 194 character
- if (CurrentChar == ' ')
- {
- CurrentChar = (char) 194;
- }
- temp = temp + CurrentChar;
- }
- //divide the WeightedTotal by 103 and get the remainder,
- //this is the CheckDigitValue
- CheckDigitValue = weightedTotal % 103;
- if( (CheckDigitValue < 95) && (CheckDigitValue > 0) )
- C128_CheckDigit = (char)(CheckDigitValue + 32);
- if( CheckDigitValue > 94 )
- C128_CheckDigit = (char)(CheckDigitValue + 100);
- if( CheckDigitValue == 0 ){
- C128_CheckDigit = (char)194;
- }
-
- //Printable_string = C128_Start + DataToEncode + C128_CheckDigit + C128_Stop + " ";
- Printable_string = C128_Start + temp + C128_CheckDigit + C128_Stop + " ";
- return Printable_string;
- }
- /** This is the complete method for Code128c
- */
- static String Code128c( String DataToEncode )
- {
- char C128_Start = (char)205;
- char C128_Stop = (char)206;
- String Printable_string = "";
- String DataToPrint = "";
- String OnlyCorrectData = "";
- int i=1;
- int CurrentChar=0;
- int CurrentValue=0;
- int weightedTotal=0;
- int CheckDigitValue=0;
- char C128_CheckDigit='w';
- DataToPrint = "";
- DataToEncode = DataToEncode.trim();
- for(i = 1; i <= DataToEncode.length(); i++ )
- {
- //Add only numbers to OnlyCorrectData string
- CurrentChar = (int)DataToEncode.charAt(i-1);
- if((CurrentChar < 58) && (CurrentChar > 47))
- {
- OnlyCorrectData = OnlyCorrectData + (char)DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- //Check for an even number of digits, add 0 if not even
- if( (DataToEncode.length() % 2) == 1 )
- {
- DataToEncode = "0" + DataToEncode;
- }
- //<<<< Calculate Modulo 103 Check Digit and generate DataToPrint >>>>
- //Set WeightedTotal to the Code 128 value of the start character
- weightedTotal = ((int)C128_Start) - 100;
- int WeightValue = 1;
- for( i = 1; i <= DataToEncode.length(); i += 2 )
- {
- //Get the value of each number pair (ex: 5 and 6 = 5*10+6 =56)
- //And assign the ASCII values to DataToPrint
- CurrentChar = ((((int)DataToEncode.charAt(i-1))-48)*10) + (((int)DataToEncode.charAt(i))-48);
- if((CurrentChar < 95) && (CurrentChar > 0))
- DataToPrint = DataToPrint + (char)(CurrentChar + 32);
- if( CurrentChar > 94 )
- DataToPrint = DataToPrint + (char)(CurrentChar + 100);
- if( CurrentChar == 0)
- DataToPrint = DataToPrint + (char)194;
- //multiply by the weighting character
- //add the values together to get the weighted total
- weightedTotal = weightedTotal + (CurrentChar * WeightValue);
- WeightValue = WeightValue + 1;
- }
- //divide the WeightedTotal by 103 and get the remainder,
- //this is the CheckDigitValue
- CheckDigitValue = weightedTotal % 103;
- if((CheckDigitValue < 95) && (CheckDigitValue > 0))
- C128_CheckDigit = (char)(CheckDigitValue + 32);
- if( CheckDigitValue > 94 )
- C128_CheckDigit = (char)(CheckDigitValue + 100);
- if( CheckDigitValue == 0 ){
- C128_CheckDigit = (char)194;
- }
- Printable_string = C128_Start + DataToPrint + C128_CheckDigit + C128_Stop + " ";
- return Printable_string;
- }
- /** This is the complete method for Code39
- */
- static String Code39( String DataToEncode )
- {
- String DataToPrint = "";
- String OnlyCorrectData = "";
- String Printable_string = "";
- int CurrentChar=0;
- int CurrentValue=0;
- DataToEncode = DataToEncode.trim();
- //only pass correct data
- for( int i = 1; i <= DataToEncode.length(); i++ )
- {
- //Get each character value one at a time
- CurrentChar = (int)(DataToEncode.charAt(i-1));
- //Get the value of CurrentChar according to MOD43
- //0-9
- if( (CurrentChar < 58) && (CurrentChar > 47) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //A-Z
- if( (CurrentChar < 91) && (CurrentChar > 64) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //Space
- if( CurrentChar == ( 32 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //-
- if( CurrentChar == ( 45 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //.
- if( CurrentChar == ( 46 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //$
- if( CurrentChar == ( 36 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- ///
- if( CurrentChar == ( 47 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //+
- if( CurrentChar == ( 43 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //%
- if( CurrentChar == ( 37 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- //Get Printable String
- Printable_string = "!" + DataToPrint + "!" + " ";
- //Return PrintableString
- return Printable_string;
- }
- /** This is the complete method for Code39Mod43
- */
- static String Code39Mod43( String DataToEncode )
- {
- String DataToPrint = "";
- int CheckDigit='0';
- String OnlyCorrectData = "";
- String Printable_string = "";
- int CurrentChar=0;
- int CurrentValue=0;
- int weightedTotal=0;
- int CheckDigitValue=0;
- DataToEncode = DataToEncode.trim();
- //only pass correct data
- for( int i = 1; i <= DataToEncode.length(); i++ )
- {
- //Get each character value one at a time
- CurrentChar = (int)(DataToEncode.charAt(i-1));
- //Get the value of CurrentChar according to MOD43
- //0-9
- if( (CurrentChar < 58) && (CurrentChar > 47) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //A-Z
- if( (CurrentChar < 91) && (CurrentChar > 64) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //Space
- if( CurrentChar == ( 32 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //-
- if( CurrentChar == ( 45 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //.
- if( CurrentChar == ( 46 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //$
- if( CurrentChar == ( 36 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- ///
- if( CurrentChar == ( 47 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //+
- if( CurrentChar == ( 43 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- //%
- if( CurrentChar == ( 37 ) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- weightedTotal = 0;
- for( int i = 1; i <= DataToEncode.length(); i++ )
- {
- //Get each character value one at a time
- CurrentChar = (int)(DataToEncode.charAt(i-1));
- //Get the value of CurrentChar according to MOD43
- //0-9
- if( (CurrentChar < 58) && (CurrentChar > 47) )
- {
- CurrentValue = (int)CurrentChar - 48;
- }
- //A-Z
- if( ((int)CurrentChar < 91) && ((int)CurrentChar > 64) )
- {
- CurrentValue = (int)CurrentChar - 55;
- }
- //Space
- if( CurrentChar == ( 32 ) )
- {
- CurrentValue = 38;
- }
- //-
- if( CurrentChar == ( 45 ) )
- {
- CurrentValue = 36;
- }
- //.
- if( CurrentChar == ( 46 ) )
- {
- CurrentValue = 37;
- }
- //$
- if( CurrentChar == ( 36 ) )
- {
- CurrentValue = 39;
- }
- ///
- if( CurrentChar == ( 47 ) )
- {
- CurrentValue = 40;
- }
- //+
- if( CurrentChar == ( 43 ) )
- {
- CurrentValue = 41;
- }
- //%
- if( CurrentChar == ( 37 ) )
- {
- CurrentValue = 42;
- }
- //To print the barcode symbol representing a space you will
- //to type or print "=" (the equal character) instead of a space character.
- if( CurrentChar == ( 32 ) )
- {
- CurrentChar = ( 61 );
- }
- //gather data to print
- DataToPrint = DataToPrint + (char)CurrentChar;
- //add the values together
- weightedTotal = weightedTotal + CurrentValue;
- }
- //divide the WeightedTotal by 43 and get the remainder, this is the CheckDigit
- CheckDigitValue = weightedTotal % 43;
- //Assign values to characters
- //0-9
- if( CheckDigitValue < 10 )
- {
- CheckDigit = CheckDigitValue + 48;
- }
- //A-Z
- if( (CheckDigitValue < 36) && (CheckDigitValue > 9) )
- {
- CheckDigit = CheckDigitValue + 55;
- }
- //Space
- if( CheckDigitValue == 38 )
- {
- CheckDigit = 61;
- }
- //-
- if( CheckDigitValue == 36 )
- {
- CheckDigit = 45;
- }
- //.
- if( CheckDigitValue == 37 )
- {
- CheckDigit = 46;
- }
- //$
- if( CheckDigitValue == 39 )
- {
- CheckDigit = 36;
- }
- ///
- if( CheckDigitValue == 40 )
- {
- CheckDigit = 47;
- }
- //+
- if( CheckDigitValue == 41 )
- {
- CheckDigit = 43;
- }
- //%
- if( CheckDigitValue == 42 )
- {
- CheckDigit = 37;
- }
- //Get Printable String
- Printable_string = "!" + DataToPrint + (char)CheckDigit + "!" + " ";
- //Return PrintableString
- return Printable_string;
- }
- /** This is the complete method for Postnet
- */
- static String Postnet( String DataToEncode )
- {
- int CheckDigit=0;
- int i=1;
- String OnlyCorrectData = "";
- String Printable_string = "";
- char CurrentChar;
- int CurrentValue=0;
- int weightedTotal=0;
- String DataToPrint = "";
- DataToEncode = DataToEncode.trim();
- // Check to make sure data is numeric and remove dashes, etc.
- for( i = 1; i <= DataToEncode.length(); i++ )
- {
- //Add all numbers to OnlyCorrectData string
- CurrentValue = (int)(DataToEncode.charAt(i-1));
- if( (CurrentValue < 58) && (CurrentValue > 47) )
- {
- OnlyCorrectData = OnlyCorrectData + DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- //<<<< Calculate Check Digit >>>>
- for( i = 1; i <= DataToEncode.length(); i++ )
- {
- //Get the value of each number
- CurrentChar = DataToEncode.charAt(i-1);
- //Convert CurrentChar to Integer and add the values together
- weightedTotal = weightedTotal + (((int)CurrentChar)-48);
- }
- //Find the CheckDigit by finding the number + weightedTotal that = a multiple of 10
- //divide by 10, get the remainder and subtract from 10
- i = weightedTotal % 10;
- if( i != 0 )
- {
- CheckDigit = 10 - i;
- }
- else
- {
- CheckDigit = 0;
- }
- //Get Printable String
- DataToPrint = DataToEncode;
- Printable_string = "(" + DataToPrint + CheckDigit + ")" + " ";
- //Return PrintableString
- return Printable_string;
- }
- /** This is the complete method for Interleaved2of5Mod10
- */
- static String Interleaved2of5Mod10( String DataToEncode )
- {
- String Printable_string = "";
- String OnlyCorrectData = "";
- String DataToPrint = "";
- int CurrentChar;
- int i=1;
- int CurrentValue=0;
- int weightedTotal=0;
- int CheckDigitValue=0;
- int CheckDigit=0;
- DataToEncode = DataToEncode.trim();
- for(i = 1; i <= DataToEncode.length(); i++ )
- {
- //Add only numbers to OnlyCorrectData string
- CurrentChar = (int)DataToEncode.charAt(i-1);
- if((CurrentChar < 58) && (CurrentChar > 47))
- {
- OnlyCorrectData = OnlyCorrectData + (char)DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- //<<<< Calculate Check Digit >>>>
- int Factor = 3;
- for( i = DataToEncode.length(); i >= 1; i-- )
- {
- //Get the value of each number starting at the end
- CurrentChar = (((int)DataToEncode.charAt(i-1))-48);
- //multiply by the weighting factor which is 3,1,3,1...
- //and add the sum together
- weightedTotal = weightedTotal + (CurrentChar * Factor);
- //change factor for next calculation
- Factor = 4 - Factor;
- }
- //Find the CheckDigit by finding the smallest number that = a multiple of 10
- i = weightedTotal % 10;
- if( i != 0 )
- {
- CheckDigit = 10 - i;
- }
- else
- {
- CheckDigit = 0;
- }
- //Add check digit number to DataToEncode
- DataToEncode = DataToEncode + CheckDigit;
- //Check for an even number of digits, add 0 if not even
- if( (DataToEncode.length() % 2) == 1 )
- {
- DataToEncode = "0" + DataToEncode;
- }
- for( i = 1; i <= DataToEncode.length(); i += 2 )
- {
- //Get the value of each number pair (ex: 5 and 6 = 5*10+6 =56)
- CurrentChar = ((((int)DataToEncode.charAt(i-1))-48)*10) + (((int)DataToEncode.charAt(i))-48);
- //Get the ASCII value of CurrentChar according to chart by adding to the value
- // (old process) DataToPrint = DataToPrint + (char)(CurrentChar + 130);
- if( CurrentChar < 94 )
- DataToPrint = DataToPrint + (char)(CurrentChar + 33);
- if( CurrentChar > 93 )
- DataToPrint = DataToPrint + (char)(CurrentChar + 103);
- }
- //Get PrintableString
- Printable_string = (char)(203) + DataToPrint + (char)(204) + " ";
- //Return PrintableString
- return Printable_string;
- }
- /** This is the complete method for Interleaved2of5
- */
- static String Interleaved2of5( String DataToEncode )
- {
- String Printable_string = "";
- String OnlyCorrectData = "";
- String DataToPrint = "";
- int CurrentChar;
- int i=1;
- int CurrentValue=0;
- int weightedTotal=0;
- DataToEncode = DataToEncode.trim();
- for(i = 1; i <= DataToEncode.length(); i++ )
- {
- //Add only numbers to OnlyCorrectData string
- CurrentChar = (int)DataToEncode.charAt(i-1);
- if((CurrentChar < 58) && (CurrentChar > 47))
- {
- OnlyCorrectData = OnlyCorrectData + (char)DataToEncode.charAt(i-1);
- }
- }
- DataToEncode = OnlyCorrectData;
- //Check for an even number of digits, add 0 if not even
- if( (DataToEncode.length() % 2) == 1 )
- {
- DataToEncode = "0" + DataToEncode;
- }
- for( i = 1; i <= DataToEncode.length(); i += 2 )
- {
- //Get the value of each number pair (ex: 5 and 6 = 5*10+6 =56)
- CurrentChar = ((((int)DataToEncode.charAt(i-1))-48)*10) + (((int)DataToEncode.charAt(i))-48);
- //Get the ASCII value of CurrentChar according to chart by adding to the value
- // (old process) DataToPrint = DataToPrint + (char)(CurrentChar + 130);
- if( CurrentChar < 94 )
- DataToPrint = DataToPrint + (char)(CurrentChar + 33);
- if( CurrentChar > 93 )
- DataToPrint = DataToPrint + (char)(CurrentChar + 103);
- }
- //Get PrintableString
- Printable_string = (char)(203) + DataToPrint + (char)(204) + " ";
- //Return PrintableString
- return Printable_string;
- }
- }
- ******************************************************************
- Barcode Fonts http://www.idautomation.com/fonts/tools/sourcecode/
- ******************************************************************
|