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

 

☞   

 

입력된 문자열을 구분자로 분리하는 함수입니다.

===========================================================================================================

global type f_parsetoken from function_object
end type

forward prototypes
global function integer f_parsetoken (string as_source, string as_token, ref string as_parsingitems[])
end prototypes

global function integer f_parsetoken (string as_source, string as_token, ref string as_parsingitems[]);/****************************************************************************************
Function    : f_parseToken [common]
Purpose     : 해당문자열의 token을 찾아 문자열을 나누어 array이에 저장하여 넘김
Scope       : public
Parameters  : al_source          (string/val)   - 원래의 문자열
              as_token           (string/val)   - 문자열안의 분리자
              as_parsingitems    (string/ref)   - 나뉘어진 문자열들을 저장하는 배열
Returns      :
Description  :
                  - 해당문자열의 특수문자열을 찾아 문자열을 나누어 문자배열에 저장
                  - 공백을 없애지 않음
      
Related      :
Author       :
Date         :
Modification:
 - 2009.02 : 박기순 : Init
****************************************************************************************/
integer li_start = 1, li_pos = 1, li_idx = 1, li_tokenLen

if isNull(as_source)  then
 return 0
end if

li_tokenLen = lenA(as_token)

do while(li_pos <> 0)
 li_pos = posA(as_source, as_token, li_start)
 if li_pos > 0 then
  as_parsingItems[li_idx] = midA(as_source, li_start, li_pos - li_start)
  li_start = li_pos + li_tokenLen
  li_idx ++
 end if
loop

as_parsingItems[li_idx] = midA(as_source, li_start)

return 0

end function

Posted by 농부지기
,

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

 

 

검색해보니 토큰으로 되어 있는 글에는 없어서 올립니다.

두 가지 형태가 들어가 있구요.

첫번째는

ls_parm = 'A!B!C'

일 경우 ..

ls_val1 = gf_tokenize(ls_parm, '!')

하면..

ls_val1 에는 'A' 가 들어가 있고, ls_parm 에는 'B!C' 가 남게 됩니다.

 

두번재는

ls_val1 = gf_tokenize(ls_parm, '!', 1)

하면..

ls_val1 에는 첫번째 토큰( !) 까지 값인 A 가 남고, ls_parm 은 그대로 'A!B!C' 값을 가지고 있게 됩니다.

 

/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/

global type gf_tokenize from function_object
end type

forward prototypes
global function string gf_tokenize (ref string as_source, string as_separator)
global function string gf_tokenize (string as_source, string as_separator, integer ai_position)
end prototypes

global function string gf_tokenize (ref string as_source, string as_separator);/*********************************************************************/
// Function : gf_tokenize()
//  Return Value 
//     String  Tokenize 결과물
//  Arguments
//   Pass By Reference String as_source
//   Pass By ReadOnly  String as_separator
/**********************************************************************/
integer li_pos
string  ls_retValue

if isnull( as_source ) or IsNull( as_separator ) THEN
 String ls_Null

 SetNull( ls_Null )
 Return ls_Null
END IF

li_pos = Pos( as_source, as_separator ) 
IF li_pos = 0 THEN
 ls_retValue = as_source
 as_source = ""
ELSE
 ls_retValue = Mid( as_source, 1, li_pos - 1 )
 as_source = Right( as_source, Len(as_source) - (li_pos + Len( as_separator ) -1 ) )
END IF

Return ls_retValue
end function

global function string gf_tokenize (string as_source, string as_separator, integer ai_position)
/*********************************************************************/
// Function : gf_Tokenizer
//  Return Value
//     String  Tokenize 결과물
//  Arguments
//   Pass By ReadOnly  String as_source
//   Pass By ReadOnly  String as_separator
//   Pass By ReadOnly  integer ai_position(음수일 경우는 오른쪽부터 찾는다.)
/**********************************************************************/
integer count, start_pos = 1, str_length, end_pos = 0
string  ret_value, ls_source, ls_left_source
STring  ls_temp_source
integer li_pos, li_end_pos = 0
boolean end_chk = false, null_chk = false
String ls_Null
SetNull( ls_Null )
ls_source = as_source
if isnull( as_source ) or IsNull( as_separator ) THEN Return ''
IF ai_position = 0 THEN null_chk = true
IF ai_position < 0 THEN //뒤에서 찾는다.
 For count = 1 to ABS(ai_position)
   IF count > 1 THEN ls_source  = left(ls_source, end_pos - 1) 
    //as_separator 가 있는 마지막 위치를 구한다.
    //lastPos는 한글일 경우에도 1byte로 계산하므로, do loop을 이용해서 구한다.
    ls_temp_source = ls_source
    do
     li_pos = Pos( ls_temp_source, as_separator )
      If li_pos > 0 THEN
      li_end_pos += li_pos
       ls_temp_source  = mid(ls_temp_source, li_pos + Len(as_separator))
     END IF
    loop until(li_pos = 0)
   end_pos = li_end_pos
    IF end_pos = 0 and count < ai_position then
    null_chk = true
     exit
   ELSEIF end_pos = 0  THEN
   start_pos  = 1
   ELSE
   start_pos  = end_pos + Len(as_separator)  
   END IF  
 NEXT
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = mid(ls_source, start_pos)
 end IF
ELSE //앞에서 찾는다..
 for count = 1 to ai_position
   IF count > 1 THEN ls_source  = mid(ls_source, end_pos + Len(as_separator))
   end_pos = pos(ls_source, as_separator, 1)
   IF end_pos = 0 and count < ai_position THEN
  null_chk = true
  exit
   ELSEIF end_pos = 0 THEN
  ls_left_source = ls_source
   ELSE
  ls_left_source = left(ls_source, end_pos - 1)
   END IF
 next
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = ls_left_source
 end if
END IF
if isnull(ret_value) then ret_value = ''
return ret_value
end function

Posted by 농부지기
,

[ 파워빌더.공통함수 - bit연산 ]

 

 

☞   

 

비트연산이 필요해서 찾아보니 파워빌더에 있더군요...

sru파일입니다...

 

 

$PBExportHeader$n_cst_numerical.sru
forward
global type n_cst_numerical from nonvisualobject
end type
end forward

global type n_cst_numerical from nonvisualobject autoinstantiate
end type

forward prototypes
public function string of_binary (long al_decimal)
public function long of_decimal (string as_binary)
public function boolean of_getbit (long al_decimal, unsignedinteger ai_bit)
public function long of_bitwiseand (long al_value1, long al_value2)
public function long of_bitwisenot (long al_value)
public function long of_bitwiseor (long al_value1, long al_value2)
public function long of_bitwisexor (long al_value1, long al_value2)
end prototypes

public function string of_binary (long al_decimal);integer li_remainder 
string ls_binary='' 

//Check   parameters 
If   IsNull(al_decimal)   or   al_decimal<   0   Then 
string   ls_null 
SetNull(ls_null) 
Return   ls_null 
End   If 

If   al_decimal   =   0   Then 
Return   '0' 
End   If 

Do   Until   al_decimal=   0 
li_remainder   =   mod(al_decimal,   2) 
al_decimal   =   al_decimal   /2 

//Build   binary   string 
ls_binary   =   string(li_remainder)   +   ls_binary 
Loop 
Return   ls_binary
end function

public function long of_decimal (string as_binary);integer   li_cnt 
long ll_len 
char lch_char[] 
long ll_decimal=0 

//Check   parameters 
If   IsNull(as_binary)   or   Len(as_binary)<=0   then 
long   ll_null 
SetNull(ll_null) 
Return   ll_null 
End   If 

//Get   the   length 
ll_len   =   Len(as_binary) 

//Move   string   into   arrach   of   characters 
lch_char   =   as_binary 

For   li_cnt   =   1   to   ll_len 
//Make   sure   only   0's   and   1's   are   present 
If   (Not   lch_char[li_cnt]='1')   AND   (Not   lch_char[li_cnt]='0')   Then 
Return   -1 
End   If 
//Build   the   decimal   equivalent 
ll_decimal   =   ll_decimal   +   (long(lch_char[li_cnt])   *   (2   ^   (ll_len   -   li_cnt))) 
Next 

Return   ll_decimal
end function

public function boolean of_getbit (long al_decimal, unsignedinteger ai_bit);Boolean   lb_null 

//Check   parameters 
If   IsNull(al_decimal)   or   IsNull(ai_bit)   then 
SetNull(lb_null) 
Return   lb_null 
End   If 

//Assumption   ai_bit   is   the   nth   bit   counting   right   to   left   with 
//the   leftmost   bit   being   bit   one. 
//al_decimal   is   a   binary   number   as   a   base   10   long. 
If   Int(Mod(al_decimal   /   (2   ^(ai_bit   -   1)),   2))   >   0   Then 
Return   True 
End   If 

Return   False
end function

public function long of_bitwiseand (long al_value1, long al_value2);Integer li_Cnt 
Long ll_Result 
Boolean lb_Value1[32],   lb_Value2[32] 

//   Check   for   nulls 
If   IsNull(al_Value1)   Or   IsNull(al_Value2)   Then 
SetNull(ll_Result) 
Return   ll_Result 
End   If 

//   Get   all   bits   for   both   values 
For   li_Cnt   =   1   To   32 
lb_Value1[li_Cnt]   =   of_getbit(al_Value1,   li_Cnt) 
lb_Value2[li_Cnt]   =   of_getbit(al_Value2,   li_Cnt) 
Next 

//   And   them   together 
For   li_Cnt   =   1   To   32 
If   lb_Value1[li_Cnt]   And   lb_Value2[li_Cnt]   Then 
ll_Result   =   ll_Result   +   (2^(li_Cnt   -   1)) 
End   If 
Next 

Return   ll_Result 
end function

public function long of_bitwisenot (long al_value);Integer li_Cnt,   li_Count 
Long ll_Result 
string ls_Value,   ls_Result 

//   Check   for   nulls 
If   IsNull(al_Value)   Then 
SetNull(ll_Result) 
Return   ll_Result 
End   If 

//   return   a   binary   string   e.g.   100101 
ls_Value   =   of_binary(al_Value) 
li_Cnt   =   Len(ls_Value) 

//   change   0   to   1   and   1   to   0 
For   li_Count   =   1   To   li_Cnt 
If   Mid(ls_Value,   li_Count,   1)   =   '0'   Then 
ls_Result   =   ls_Result   +   '1' 
Else 
ls_Result   =   ls_Result   +   '0' 
End   If 
End   For 

//   return   the   result   in   decimal   form   e.g.   57 
Return   of_decimal(ls_Result)
end function

public function long of_bitwiseor (long al_value1, long al_value2);Integer li_Cnt 
Long ll_Result 
Boolean lb_Value1[32],   lb_Value2[32] 

//   Check   for   nulls 
If   IsNull(al_Value1)   Or   IsNull(al_Value2)   Then 
SetNull(ll_Result) 
Return   ll_Result 
End   If 

//   Get   all   bits   for   both   values 
For   li_Cnt   =   1   To   32 
lb_Value1[li_Cnt]   =   of_getbit(al_Value1,   li_Cnt) 
lb_Value2[li_Cnt]   =   of_getbit(al_Value2,   li_Cnt) 
Next 

//   Or   them   together 
For   li_Cnt   =   1   To   32 
If   lb_Value1[li_Cnt]   Or   lb_Value2[li_Cnt]   Then 
ll_Result   =   ll_Result   +   (2^(li_Cnt   -   1)) 
End   If 
Next 

Return   ll_Result
end function

public function long of_bitwisexor (long al_value1, long al_value2);Integer li_Cnt 
Long ll_Result 
Boolean lb_Value1[32],   lb_Value2[32] 

//   Check   for   nulls 
If   IsNull(al_Value1)   Or   IsNull(al_Value2)   Then 
SetNull(ll_Result) 
Return   ll_Result 
End   If 

//   Get   all   bits   for   both   values 
For   li_Cnt   =   1   To   32 
lb_Value1[li_Cnt]   =   of_getbit(al_Value1,   li_Cnt) 
lb_Value2[li_Cnt]   =   of_getbit(al_Value2,   li_Cnt) 
Next 

//   Perfor   the   XOR 
For   li_Cnt   =   1   To   32 
If   (lb_Value1[li_Cnt]   And   Not   lb_Value2[li_Cnt])   Or   & 
(Not   lb_Value1[li_Cnt]   And   lb_Value2[li_Cnt])   Then 
ll_Result   =   ll_Result   +   (2^(li_Cnt   -   1)) 
End   If 
Next 

Return   ll_Result
end function

on n_cst_numerical.create
call super::create
TriggerEvent( this, "constructor" )
end on

on n_cst_numerical.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

Posted by 농부지기
,

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

 

☞   iif , 표현식에 따라 return값을 다르게 하는 함수

 

 

세 개의 인자값이 있습니다. 첫번째 값의 결과가 참일 경우에는 두번째 인자를 return 하고, 거짓일 경우에는 세 번째 인자를 return 합니다.

 

각 버전에 따라 함수오브젝트(iif)를 만드시고, 아래 스크립트를 복사하여 바꿔주세요.

 

global type iif from function_object
end type

forward prototypes
global function string iif (readonly boolean abExpression, readonly string asTruePart, readonly string asFalsePart)
global function long iif (readonly boolean abExpression, readonly long alTruePart, readonly long alFalsePart)
global function integer iif (readonly boolean abExpression, readonly integer aiTruePart, readonly integer aiFalsePart)
global function date iif (readonly boolean abExpression, readonly date adtTruePart, readonly date adtFalsePart)
global function time iif (readonly boolean abExpression, readonly time atTruePart, readonly time atFalsePart)
global function datetime iif (readonly boolean abExpression, readonly datetime adtTruePart, readonly datetime adtFalsePart)
global function decimal iif (readonly boolean abExpression, readonly decimal adTruePart, readonly decimal adFalsePart)
global function double iif (readonly boolean abExpression, readonly double adTruePart, readonly double adFalsePart)
end prototypes

global function string iif (readonly boolean abExpression, readonly string asTruePart, readonly string asFalsePart);if abExpression then
 return asTruePart
else
 return asFalsePart
end if
end function

global function long iif (readonly boolean abExpression, readonly long alTruePart, readonly long alFalsePart);if abExpression then
 return alTruePart
else
 return alFalsePart
end if
end function

global function integer iif (readonly boolean abExpression, readonly integer aiTruePart, readonly integer aiFalsePart);if abExpression then
 return aiTruePart
else
 return aiFalsePart
end if
end function

global function date iif (readonly boolean abExpression, readonly date adtTruePart, readonly date adtFalsePart);if abExpression then
 return adtTruePart
else
 return adtFalsePart
end if
end function

global function time iif (readonly boolean abExpression, readonly time atTruePart, readonly time atFalsePart);if abExpression then
 return atTruePart
else
 return atFalsePart
end if
end function

global function datetime iif (readonly boolean abExpression, readonly datetime adtTruePart, readonly datetime adtFalsePart);if abExpression then
 return adtTruePart
else
 return adtFalsePart
end if
end function

global function decimal iif (readonly boolean abExpression, readonly decimal adTruePart, readonly decimal adFalsePart);if abExpression then
 return adTruePart
else
 return adFalsePart
end if
end function

global function double iif (readonly boolean abExpression, readonly double adTruePart, readonly double adFalsePart);if abExpression then
 return adTruePart
else
 return adFalsePart
end if
end function

☞  

 

Posted by 농부지기
,

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

 

☞   

 

생각해보니... '-', '.' 등도 생각해야하고... 혹시 이게... '00.0.'  이라던지.... '00-00'

 

이렇게 되어 있어도 하나씩 체크해서는 숫자로 판단할 것 같더라구요~

 


/*============================================================*//* Function Name : BOOLEAN f_IsNumber (as_arg)                     */
/* Argument  Name :   as_arg                                                   */
/*               Type      STRING                                                   */
/*     Return Type :   BOOLEAN                                                */
/*============================================================*/
String ls_c
long ll_len, ll_a

ll_len = Len (as_str)

if ll_len = 0 then
   return FALSE
else
   for ll_a = 1 to ll_len
      ls_c = mid (as_str, ll_a, 1)
      choose case ls_c
         case '0' to '9', '-', '.'
         case else
             return FALSE
      end choose
   next
end if
 
if isnumber(as_str) then
   return TRUE
else
   return FALSE
end if
 

 

☞  

 

거냥 숫자아닌 다른 문자는 제하는 함수 만드는것이 편하지 않을까요?
대충 ....
/* string OnlyNumber(string as_String)
숫자 이외 모든 문자 지우기
*/
string ls_tmp, ls_char, ls_String = ''
ls_tmp = Trim(as_String)
Do While len(ls_tmp) > 0
ls_char = Left(ls_tmp,1)
choose case ls_char
case '0','1','2','3','4','5','6','7','8','9'
ls_String += ls_char
end choose
ls_tmp = Mid(ls_tmp,2)
Loop
return ls_String

 

 

Posted by 농부지기
,

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

 

☞   isequal 두개의 값이 같은지 다른지 비교하는 함수

 

두 개의 string 변수가 동일한지 다른지를 비교하여 그 결과를 알려줍니다.

추가로는 대소문자 구별여부와 space를 trim으로 처리해서 비교할 것인지가 있습니다.

 

생성방법은 각 버전별로 함수오브젝트(isequal)을 만드신 후, 아래 스크립트를 복사하여 바꿔주시기 바랍니다.

 

global type isequal from function_object
end type

forward prototypes
global function boolean isequal (string asLeft, string asRight, readonly boolean abIgnorecase)
global function boolean isequal (string asLeft, string asRight, readonly boolean abIgnorecase, readonly boolean abTrimSpaces)
global function boolean isequal (string asleft, string asright)
end prototypes

global function boolean isequal (string asLeft, string asRight, readonly boolean abIgnorecase);return IsEqual(asLeft, asRight, abIgnorecase, true)
end function

global function boolean isequal (string asLeft, string asRight, readonly boolean abIgnorecase, readonly boolean abTrimSpaces);if abIgnoreCase then
 asLeft = Lower(asLeft)
 asRight = Lower(asRight)
end if
if abTrimSpaces then
 asLeft = Trim(asLeft)
 asRight = Trim(asRight)
end if

return asLeft = asRight
end function

global function boolean isequal (string asleft, string asright);return IsEqual(asLeft, asRight, true)
end function

 

Posted by 농부지기
,

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

 

☞ isemptyornull ,변수내용이 null이나 값이없는지 파악하는 함수

 

 

앞서 작성한 isnull 함수가 있다면, 다음의 함수를 추가로 사용하시면.(http://cafe.naver.com/pentaeduclub/4021)

매번, if isnull(변수) or trim(변수) = '' then  ... 하시던 스크립트를

if isemptyornull(변수) then 으로 줄일 수 있습니다.

 

물론 각 타입별로 만들어져 있구요...

 

작성방법은 동일합니다. 각 버전별로 함수오브젝트(isemptyornull)를 만드시고,  아래 스크립트로 바꿔주세요.

global type isemptyornull from function_object
end type

forward prototypes
global function boolean isemptyornull (readonly string asString)
global function boolean isemptyornull (readonly string asString, boolean abTrimSpace)
global function boolean isemptyornull (readonly long alLong)
global function boolean isemptyornull (readonly integer aiInt)
global function boolean isemptyornull (readonly date adtDate)
global function boolean isemptyornull (readonly decimal adDecimal)
global function boolean isemptyornull (readonly double adDouble)
end prototypes

global function boolean isemptyornull (readonly string asString);return IsEmptyOrNull(asString, TRUE)
end function

global function boolean isemptyornull (readonly string asString, boolean abTrimSpace);
if abTrimSpace then
 return IsNull(Trim(asString), '') = ''
else
 return IsNull(asString, '') = ''
end if
end function

global function boolean isemptyornull (readonly long alLong);return IsNull(alLong, 0) = 0
end function

global function boolean isemptyornull (readonly integer aiInt);return IsNull(aiInt, 0) = 0
end function

global function boolean isemptyornull (readonly date adtDate);return IsNull(adtDate, 1900-01-01) = 1900-01-01
end function

global function boolean isemptyornull (readonly decimal adDecimal);return IsNull(adDecimal, Dec("0.00")) = Dec("0.00")
end function

global function boolean isemptyornull (readonly double adDouble);return IsNull(adDouble, Double("0.00")) = Double("0.00")
end function

 

Posted by 농부지기
,

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

 

☞   

  [출처 : http://kodigopower.com/ ]

각 타입별로 두 개의 아규먼트를 가지는데, 첫번째는 null 여부를 체크하는 대상이고, 두번째는 만일 첫번째가 null일 경우 대체할 값입니다.

각 파빌 버전별로 함수 오브젝트(isnull)를 만드신 후, edit source나 export 하셔서 아래 스크립트를 복사하여 붙여넣기 하셔서 쓰세요.

 

global type isnull from function_object
end type

forward prototypes
global function string isnull (readonly string asString, readonly string asReplace)
global function long isnull (readonly long alNumber, readonly long alReplace)
global function integer isnull (readonly integer aiNumber, readonly integer aiReplace)
global function date isnull (readonly date adtDate, readonly date adtReplace)
global function time isnull (readonly time atTime , readonly time atReplace)
global function datetime isnull (readonly datetime adtDatetime , readonly datetime adtReplace)
global function decimal isnull (readonly decimal adNumber, readonly decimal adReplace)
global function double isnull (readonly double adNumber, readonly double adReplace)
end prototypes

global function string isnull (readonly string asString, readonly string asReplace);if isnull(asString) then
 return asReplace
else
 return asString
end if
end function

global function long isnull (readonly long alNumber, readonly long alReplace);if isnull(alNumber) then
 return alReplace
else
 return alNumber
end if
end function

global function integer isnull (readonly integer aiNumber, readonly integer aiReplace);if isnull(aiNumber) then
 return aiReplace
else
 return aiNumber
end if
end function

global function date isnull (readonly date adtDate, readonly date adtReplace);if isnull(adtDate) then
 return adtReplace
else
 return adtDate
end if
end function

global function time isnull (readonly time atTime, readonly time atReplace);if isnull(atTime) then
 return atReplace
else
 return atTime
end if
end function

global function datetime isnull (readonly datetime adtDatetime, readonly datetime adtReplace);if isnull(adtDatetime) then
 return adtReplace
else
 return adtDatetime
end if
end function

global function decimal isnull (readonly decimal adNumber, readonly decimal adReplace);if isnull(adNumber) then
 return adReplace
else
 return adNumber
end if
end function

global function double isnull (readonly double adNumber, readonly double adReplace);if isnull(adNumber) then
 return adReplace
else
 return adNumber
end if
end function

Posted by 농부지기
,

[ 파워빌더.파일 - 목록가져오기2 ]

 

 

윈도우 하나 만듭니다.(w_dragfile)

 

Local External Functions 에 다음과 같이 선언합니다.

9버전 이하일 경우

/*───────────────────────────────────────
   탐색기에서 파일을 Drag & Drop
───────────────────────────────────────*/
FUNCTION int DragQueryFile(long hDrop, int iFile, REF string szFileName,int cb) LIBRARY "shell32.dll" alias for "DragQueryFile"
SUBROUTINE DragAcceptFiles(long l_hWnd,boolean fAccept) LIBRARY "shell32.dll"
SUBROUTINE DragFinish(long hDrop) LIBRARY "shell32.dll"

 

10버전 이상일 경우에는

/*───────────────────────────────────────
   탐색기에서 파일을 Drag & Drop
───────────────────────────────────────*/
FUNCTION int DragQueryFile(long hDrop, int iFile, REF string szFileName,int cb) LIBRARY "shell32.dll" alias for "DragQueryFile;Ansi"
SUBROUTINE DragAcceptFiles(long l_hWnd,boolean fAccept) LIBRARY "shell32.dll"
SUBROUTINE DragFinish(long hDrop) LIBRARY "shell32.dll"

 

open 이벤트)

DragAcceptFiles(handle(this), true)

 

ue_dropfiles 이벤트 생성)

pbm_dropfiles 를 선택합니다.

아래와 같이 스크립트를 작성하세요.

//파일 드래그 앤 드롭
//파일을 가져온다.
Ulong   hDrop
Integer   li_file, li_files, li_FNlen = 255
String   ls_filename = Space(li_FNlen)
string      ls_Files[], ls_file_nm
long   ll_cnt, ll_row

// 파일의 핸들리스트과 리스트 갯수
hDrop   = Message.WordParm
li_files  = DragQueryFile(hDrop, -1, ls_filename, li_FNlen) - 1

FOR li_file = 0 TO li_files 
 DragQueryFile(hDrop, li_file, ls_filename, li_FNlen)
 ls_Files[upperbound(ls_Files) + 1] = ls_filename 
NEXT
DragFinish(hDrop)
ll_cnt = upperbound(ls_files)
For li_file = 1 To ll_cnt
 //중복된 파일이 있는지 찾는다.
 IF dw_1.find("filepath = '"+ls_files[li_file]+"'", 1, dw_1.rowcount()) > 0 then continue
 ll_row = dw_1.InsertRow(0) 
 ls_file_nm = gf_stringtokenize(ls_files[li_file], '\', -1)
 dw_1.setItem(ll_row, 'filepath', ls_files[li_file])
 dw_1.setItem(ll_row, 'filename', ls_file_nm)
 dw_1.setItem(ll_row, 'fileext', gf_stringtokenize(ls_file_nm, '.', -1))
Next

 

이걸로 윈도우 쪽은 끝입니다.

다음은... DW 양식입니다.

release 9;
datawindow(units=0 timer_interval=0 color=1073741824 processing=1 HTMLDW=no print.printername="" print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.canusedefaultprinter=yes print.prompt=no print.buttons=no print.preview.buttons=no print.cliptext=no print.overrideprintjob=no print.collate=yes hidegrayline=no grid.lines=0 )
header(height=76 color="536870912" )
summary(height=0 color="536870912" )
footer(height=0 color="536870912" )
detail(height=80 color="536870912" )
table(column=(type=char(255) updatewhereclause=yes name=filename dbname="filename" )
 column=(type=char(3) updatewhereclause=yes name=fileext dbname="fileext" )
 column=(type=char(500) updatewhereclause=yes name=filepath dbname="filepath" )
 )
text(band=header alignment="2" text="파일명" border="0" color="33554432" x="9" y="8" height="60" width="882" html.valueishtml="0"  name=filename_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="2" text="확장자" border="0" color="33554432" x="901" y="8" height="60" width="183" html.valueishtml="0"  name=fileext_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="2" text="파일전체경로" border="0" color="33554432" x="1093" y="8" height="60" width="1458" html.valueishtml="0"  name=filepath_t visible="1"  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=1 alignment="0" tabsequence=32766 border="0" color="33554432" x="9" y="8" height="88" width="882" format="[general]" html.valueishtml="0"  name=filename visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=2 alignment="2" tabsequence=32766 border="0" color="33554432" x="901" y="8" height="88" width="183" format="[general]" html.valueishtml="0"  name=fileext visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=3 alignment="0" tabsequence=32766 border="0" color="33554432" x="1093" y="8" height="88" width="1458" format="[general]" html.valueishtml="0"  name=filepath visible="1" edit.limit=0 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes edit.imemode=0  font.face="Arial" font.height="-9" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" encodeselflinkargs="1" netscapelayers="0" )
export.xml(headgroups="1" includewhitespace="0" metadatatype=0 savemetadata=0 )
import.xml()
export.pdf(method=0 distill.custompostscript="0" xslfop.print="0" )
 

다음은 gf_stringtokenize 함수입니다.

global type gf_stringtokenize from function_object
end type

forward prototypes
global function string gf_stringtokenize (string as_source, string as_separator, integer ai_position)
end prototypes

global function string gf_stringtokenize (string as_source, string as_separator, integer ai_position);/*********************************************************************/
// Function : stringtokenize
//  Return Value
//     String  Tokenize 결과물
//  Arguments
//   Pass By ReadOnly  String as_source
//   Pass By ReadOnly  String as_separator
//   Pass By ReadOnly  integer ai_position(음수일 경우는 오른쪽부터 찾는다.)
/**********************************************************************/
integer count, start_pos = 1, str_length, end_pos = 0
string  ret_value, ls_source, ls_left_source
STring  ls_temp_source
integer li_pos, li_end_pos = 0
boolean end_chk = false, null_chk = false
String ls_Null
SetNull( ls_Null )
ls_source = as_source
if isnull( as_source ) or IsNull( as_separator ) THEN Return ''
IF ai_position = 0 THEN null_chk = true
IF ai_position < 0 THEN //뒤에서 찾는다.
 For count = 1 to ABS(ai_position)
   IF count > 1 THEN ls_source  = left(ls_source, end_pos - 1) 
    //as_separator 가 있는 마지막 위치를 구한다.
    //lastPos는 한글일 경우에도 1byte로 계산하므로, do loop을 이용해서 구한다.
    ls_temp_source = ls_source
    do
     li_pos = Pos( ls_temp_source, as_separator )
      If li_pos > 0 THEN
      li_end_pos += li_pos
       ls_temp_source  = mid(ls_temp_source, li_pos + Len(as_separator))
     END IF
    loop until(li_pos = 0)
   end_pos = li_end_pos
    IF end_pos = 0 and count < ai_position then
    null_chk = true
     exit
   ELSEIF end_pos = 0  THEN
   start_pos  = 1
   ELSE
   start_pos  = end_pos + Len(as_separator)  
   END IF  
 NEXT
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = mid(ls_source, start_pos)
 end IF
ELSE //앞에서 찾는다..
 for count = 1 to ai_position
   IF count > 1 THEN ls_source  = mid(ls_source, end_pos + Len(as_separator))
   end_pos = pos(ls_source, as_separator, 1)
   IF end_pos = 0 and count < ai_position THEN
  null_chk = true
  exit
   ELSEIF end_pos = 0 THEN
  ls_left_source = ls_source
   ELSE
  ls_left_source = left(ls_source, end_pos - 1)
   END IF
 next
 if null_chk then
    ret_value = ls_Null
 else
   ret_value = ls_left_source
 end if
END IF
if isnull(ret_value) then ret_value = ''
return ret_value
end function

 

이제 구성된 화면을 보겠습니다.

 

 

 

 

Posted by 농부지기
,

[ 파워빌더.파일 - 목록가져오기1 ]

 

  /* integer gf_GetFileList( string as_path, listbox alb_box, ref string as_Files[])
 지정된 경로에서 하위 폴더를 포함한 파일의 리스트를 가져온다.
*/
int i, j, k, i_cnt
String ls_file, ls_Files[], ls_Sub, ls_SubFiles[], ls_tmp[]
as_Files = ls_tmp
if Right(as_path,1) <> '\' then as_path += '\'
alb_box.Reset()
alb_box.DirList(as_path+"*.*", 16)
for i = 1 to alb_box.Totalitems( )
 ls_Files[UpperBound(ls_Files) + 1] = alb_box.text(i)
next
for i = 1 to UpperBound(ls_Files)
 ls_file = ls_Files[i]
 if ls_file = '[..]' then Continue
 if Left(ls_file,1) = '[' and right(ls_file,1) = ']' then
  ls_file = Left(ls_file, Len(ls_file) - 1)
  ls_file = Mid(ls_file, 2) + '\'
  ls_Sub = as_path + ls_file
  i_cnt = gf_GetFileList( ls_Sub, alb_box, ls_SubFiles )
  for j = 1 to i_cnt
   as_Files[UpperBound(as_Files) + 1] = ls_file + ls_SubFiles[j]
  next
 else
  as_Files[UpperBound(as_Files) + 1] = ls_file
 end if
next
i_cnt = UpperBound(as_Files)
return i_cnt

Posted by 농부지기
,