[ 파워빌더.공통함수 - barCode ]

 

☞   

 

code128인경우 4자리 이상일때 적용이 가능.숫자 같은경우는 짝수일때 적용했을때는 단축효과가 있다...

영문대소문자구분 숫자표현 가능...

바코드 폰트는 링크걸린 사이트에서 받을수 있음..

바코드는 demo용 ... 고치는 방법도 있음. 이 부분은 알아서 하시길...

다른 자료 같은 경우는 유럽쪽 소스 내용 같은 경우는 문자코드열때문에 우리나라와 변환이 안맞아 사용이 힘들었는데..

서핑중 발견.. ㅋㅋㅋ  

아래 내용을 함수로 만들고 링크사이트에서 바코드 폰트를 받으셔서 사용하시면 됩니다..

다른 바코드관련 자료도 있으니 바코드관련 업무에 참고 하세요...

 

// PowerBuilder Source Code for IDAutomation.com Code 128 Barcode Fonts
// Copyright ⓒ 2002, IDAutomation.com, Inc. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////////
//
//      NOTE: The following code is only an example that was provided by a client.
//      IDAutomation.com, Inc. does not guarantee, support or troubleshoot
//      PowerBuilder source code.
//
// To use this function the developer needs to create an external function,
// Set function arguments and paste all the codes below.
//
///////////////////////////////////////////////////////////////////////////////////
//
// This function will convert input to a data string formatted for our
//      Code 128 Barcode Fonts. This is a code 128 "auto" function.
//
//      This barcode font is available at:
//      http://www.bizfonts.com/code128fonts/
// Download a demo version from:
//      http://www.advancemeants.com/code128fonts/download.htm
//
//      You may incorporate our Source Code in your application
//      only if you own a valid Multi-user or Corporate Distribution
//      license from IDAutomation.com, Inc. for the associated font and
//      the copyright notices are not removed from the source code.
//
// Arguments:
// Input(Pass By value)
//    Datatype String
//    Name  as_input
//
// Output(Pass By reference)
//    Datatype String
//    Name  as_ouptut
//
//    Copyright, IDAutomation.com, Inc. 2002. All rights reserved.
///////////////////////////////////////////////////////////////////////////////////

string ls_c128_starta
string ls_c128_startb
string ls_c128_startc
string ls_c128_start
string ls_c128_stop
Long  ll_len,i
Integer li_curr_char
String ls_curr_char
string ls_curr_encoding
Long  ll_curr_value
Long  ll_weighted_tot
string ls_datatoencode
Integer li_check_digit
String ls_c128_checkdigit
string ls_datatoprint, as_input , as_output


as_input = trim(sle_2.text)

If Isnull(as_input) OR as_input = '' Then
 Return -1
End IF

ls_c128_starta = char(203)
ls_c128_startb = char(204)
ls_c128_startc = char(205)
ls_c128_stop = char(206)

// Here we select character set A, B or C for the START character
ll_len = len(as_input)
li_curr_char = Asc(Mid(as_input, 1, 1))
If li_curr_char < 32 Then ls_c128_start = ls_c128_starta
If li_curr_char > 31 AND li_curr_char < 127 Then ls_c128_start = ls_c128_startb
If ((ll_len > 4) AND Isnumber(mid(as_input,1,4))) Then ls_c128_start = ls_c128_startc

// 202 is the FNC1, with this Start C is mandatory
If li_curr_char = 202 Then ls_c128_start = ls_c128_startc
If ls_c128_start = char(203) Then ls_curr_encoding = "A"
If ls_c128_start = char(204) Then ls_curr_encoding = "B"
If ls_c128_start = char(205) Then ls_curr_encoding = "C"

For i = 1 to ll_len
 // check for FNC1 in any set 
 If ((Mid(as_input,i,1)) = Char(202)) Then
  ls_datatoencode = ls_datatoencode + char(202)
 // check for switching to character set C 
 ElseIf ((i < ll_len - 2) AND (Isnumber(mid(as_input,i,1))) and (isnumber(mid(as_input,i + 1,1))) AND (Isnumber(Mid(as_input,i,4)))) OR ((i < ll_len) AND (Isnumber(mid(as_input,i,1))) AND (Isnumber(Mid(as_input,i + 1,1))) And (ls_curr_encoding = "C")) Then
  // switch to set C if not already in it  
  If ls_curr_encoding <> "C" Then ls_datatoencode = ls_datatoencode + char(199)
  ls_curr_encoding = "C"
  ls_curr_char = (Mid(as_input,i,2))
  ll_curr_value = Long(ls_curr_char)
  // set the CurrentValue to the number of String CurrentChar  
  If (ll_curr_value < 95 AND ll_curr_value > 0 ) Then ls_datatoencode = ls_datatoencode + char(ll_curr_value + 32)
  If ll_curr_value > 94 Then ls_datatoencode = ls_datatoencode + char(ll_curr_value + 100)
  If ll_curr_value = 0 Then ls_datatoencode = ls_datatoencode + char(194)
  i = i + 1
 // check for switching to character set A
 ElseIf (i <= ll_len) AND ((ASC(Mid(as_input,i,1)) < 31) OR ((ls_curr_encoding = "A") AND (ASC(Mid(as_input,i,1)) > 32 AND (asc(mid(as_input,i,1))) < 96))) Then
  // switch to set A if not already in it 
  If ls_curr_encoding <> "A" Then ls_datatoencode = ls_datatoencode + char(201)
  ls_curr_encoding = "A"
  // Get the ASCII value of the next character
  li_curr_char = (asc(mid(as_input,i,1)))
  If li_curr_char = 32 Then
   ls_datatoencode = ls_datatoencode + char(194)
  ElseIf li_curr_char < 32 then
   ls_datatoencode = ls_datatoencode + char(li_curr_char + 96)
  ElseIf li_curr_char > 32 Then
   ls_datatoencode = ls_datatoencode + char(li_curr_char)
  End IF
 // check for switching to character set B
 ElseIf (i <= ll_len) AND ((ASC(mid(as_input,i,1))) > 31 AND (ASC(mid(as_input,i,1))) < 127) Then  
  // switch to set B if not already in it
  If ls_curr_encoding <> "B" Then ls_datatoencode = ls_datatoencode + char(200)
  ls_curr_encoding = "B"
  // Get the ASCII value of the next character
  li_curr_char = (asc(mid(as_input,i,1)))
  If li_curr_char = 32 Then
   ls_datatoencode = ls_datatoencode + char(194)
  Else
   ls_datatoencode = ls_datatoencode + char(li_curr_char)
  End IF
 End IF  
Next

// ***** Calculate Modulo 103 Check Digit *******

// Set WeightedTotal to the value of the start character
ll_weighted_tot = (ASC(ls_c128_start) - 100)
ll_len = Len(ls_datatoencode)

For i = 1 to ll_len
 // Get the ASCII value of each character
 li_curr_char = (asc(mid(ls_datatoencode,i,1)))
 // Get the Code 128 value of CurrentChar according to chart
 If li_curr_char < 135 Then ll_curr_value = li_curr_char - 32
 If li_curr_char > 134 Then ll_curr_value = li_curr_char - 100
 If li_curr_char = 194 Then ll_curr_value = 0
 // multiply by the weighting character
 ll_curr_value = ll_curr_value * i
 // add the values together
 ll_weighted_tot = ll_weighted_tot + ll_curr_value
Next
// divide the WeightedTotal by 103 and get the remainder, this is the CheckDigitValue
li_check_digit = Mod(ll_weighted_tot,103)
// Now that we have the CheckDigitValue, find the corresponding ASCII character from the table
If li_check_digit < 95 AND li_check_digit > 0 Then ls_c128_checkdigit = char(li_check_digit + 32)
If li_check_digit > 94 Then ls_c128_checkdigit = char(li_check_digit + 100)
If li_check_digit = 0 Then ls_c128_checkdigit = char(194)
// Check for spaces or "00" and print ASCII 194 instead
// place changes in data to print
ll_len = Len(ls_datatoencode)
For i = 1 to ll_len
 ls_curr_char = mid(ls_datatoencode,i,1)
 If ls_curr_char = " " Then ls_curr_char = char(194)
 ls_datatoprint = ls_datatoprint + ls_curr_char
Next

// Get Printable String
as_output = ls_c128_start + ls_datatoprint + ls_c128_checkdigit + ls_c128_stop + " "
 
Return 0

 

☞  

 

예.. 폰트는 다운 로드 하심 되구요... 물론 demo라 약간 제약이 있는데..
그 부분은 좀만 생각하심 .. 여기까지. 메일주심..
아 그러구 바코드활용(1) 은 kan13(ean13) 관련 내용입니다.
http://cafe.naver.com/pentaeduclub/4850
http://cafe.naver.com/pentaeduclub/4849
일반적으로 폰트로 하는것은 code39 같은 경우는 일번적으로 많이 쓰는데 kan,upc,code128등 다른
바코드는 encoding을 하지 않으면 폰트를 이용하더라도 인식이 안됩니다.
kan(ean코드 ) 아무 다른 업체의 ean바코드 폰트를 이용해도 되지만,
다른방식의 폰트는 해당업체의 모듈(인코딩방식)과 연동되기 때문에 조금식 인코딩시 넘어오는 문자가 다릅니다. 그래서 바코드 인식이 안되는 경우가 많습니다.
인코딩 소스를 받았다면 그 해당 업체의 폰트를 받아야지만 정확한 바코드가 인식되는 경우가 많음...ㅋㅋ

☞  http://cafe.naver.com/pentaeduclub/990 참고 하시면 퐅트 없이도
패턴을 가지고 이렇게 표현도 가능 합니다. 폰트를 깔아주는 수고를 덜수도 있구요..
demo 폰트 조작할 필요도 없구요...
이거를 kan, code128에 적용함 해볼려구요..
대칭관계라 쉽지만은 안더라구요....

 

폰트를 수정하는 방법을 하면 가능 하지 않을까 생각 됩니다...
ls_c128_starta = char(203)
ls_c128_startb = char(204)
ls_c128_startc = char(205)
ls_c128_stop = char(206)
이 부분을 폰트를 다른 사용하지 않는 글자로 대체 하시는 방법을 하시면 가능 할것 같은데..
폰트수정은 폰트 수정하는 툴을 이용... 저도 생각만 해봐서.. 가능하지 않을까 사료됨.

 

프로젝트 하시다 보면 간단한 바코드 폰트로 해결 되는 경우도 있지만

CODE128A,CODE128B

이과 같이 CODE128 에 Check digit 없이 Code 128 character set 은 A로 처리 되는경우등은 일반적으로 바코드 폰트로만은

처리기가 힘듭니다.

그래서 대부분 관련 ActiveX 같은걸 구매해서 사용하죠..

 

Java Barcode Servlets 된 WEB으로 바코드 폰트를 이미지화 하여 원하는 바코드 형식으로 만들수 있는 곳인데

프로젝트 하시다 보면 해당 바코드가 어떤 형태인지 확인해 보실때 사용하시면 좋을것 같습니다.

WEB으로 구축시에는 직접 사용하시는것도 괜찮을것 같네요

 

저는 보통 생성된 바코드를 확인할때 주로 많이 사용합니다...

처음 구매한 바코드나 접하지 않은 바코드일경우 해당 바코드의 타입과 설정을 알고 대응하게는 좋으니깐요..^^

 

바코드 접해 보지 않은분은 바코드에 대해 공부하신다 생각 하고 한번 확인해 보면 좋을것 같습니다.

 

URL은 아래와 같습니다.

 

http://www.idautomation.com/java/linearservlet.html

 

 

카페 등업점수가 얼마 남지 않았네요...

자주 글을 쓰야 하는데..ㅎㅎ 노력해보겠습니다.

Posted by 농부지기
,