[ 파워빌더.공통함수 - 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 농부지기
,

[ 파워빌더.파일 - 폴더 size 구하기  ]

 

 
String ls_f = "c:\test"Double size


OLEObject FSO, FSO2

FSO = CREATE OLEObject

SetPointer(Hourglass!)

ll_result = FSO.ConnectToNewObject("Scripting.FileSystemObject")
IF ll_result <> 0 THEN
        messagebox('error',ll_result)
        DESTROY FSO
        SetPointer(Arrow!)
        return
END IF


IF FSO.FolderExists(ls_f) THEN
      FSO2 = FSO.GetFolder(ls_f)

      size = FSO2.Size

Else
      DESTROY FSO
      return
End if

DESTROY FSO2

SetPointer(Arrow!)

Posted by 농부지기
,

[ 파워빌더.파일 - 폴더 ]

 

 

String ls_folder = "c:\edu"
Double ldo_folder_size
Long ll_result

OLEObject FSO, FSO2

 

FSO = CREATE OLEObject

 

SetPointer(Hourglass!)

 

ll_result = FSO.ConnectToNewObject("Scripting.FileSystemObject")

IF ll_result <> 0 THEN
 messagebox('error',ll_result)
 DESTROY FSO
 SetPointer(Arrow!)
 return
END IF


IF FSO.FolderExists(ls_folder) THEN
 FSO2 = FSO.GetFolder(ls_folder)
 ldo_folder_size = FSO2.Size
 MessageBox('', ldo_folder_size)
Else
 DESTROY FSO
 return
End if

 

DESTROY FSO2

SetPointer(Arrow!)

 

Posted by 농부지기
,

[ 파워빌더.파일 - 생성일자 ]

 

OLEObject FSO, FSO2INTEGER ll_result
string rtn

//파일존재 여부
IF NOT FILEEXISTS(as_filename) THEN RETURN 'none'

// File System OBJECT 생성
FSO = CREATE OLEObject
FSO2 = CREATE OLEObject

ll_result = FSO.ConnectToNewObject("Scripting.FileSystemObject")
IF ll_result <> 0 THEN
//messagebox('error',ll_result)
DESTROY FSO
DESTROY FSO2
RETURN 'none'
END IF

FSO2 = FSO.GetFile(as_filename)

//File System 구하기
//rtn = string(FSO2.DateCreated , 'yyyy/mm/dd-hh:mm') --> 생성일자
//rtn = string(FSO2.DateLastAccessed , 'yyyy/mm/dd-hh:mm') --> 접근일자
//rtn = string(FSO2.DateLastModified , 'yyyy/mm/dd-hh:mm') --> 수정일자
//rtn = string(FileLength(as_filename)) --> 파일크기

rtn = string(FSO2.DateLastModified, 'yyyy/mm/dd hh:mm:ss')

// File System OBJECT Destroy
DESTROY FSO
DESTROY FSO2

RETURN rtn

 

Posted by 농부지기
,

[ 파워빌더.파일 - 읽기 ]

 

// blob gf_FileRead(string as_file)

Blob  ib_file, b
integer i_fn
Long  l, l_loop
Long  l_fLen

l_fLen = FileLength(as_File)

IF l_fLen > 32765 THEN
 IF Mod(l_fLen, 32765) = 0 THEN
  l_loop = l_fLen / 32765
 ELSE
  l_loop = l_fLen / 32765 + 1
 END IF
ELSE
 l_loop = 1
END IF

i_fn   = FileOpen(as_File, StreamMode!, Read!)
FOR l = 1 to l_loop
 FileRead(i_fn, b)
 ib_file = ib_file + b
NEXT

FileClose(i_fn)

return ib_file

☞  

Posted by 농부지기
,

[ 파워빌더.Button - 동적 생성  ]

 

 

☞   

 

컨트롤버튼 동적생성 http://cafe.naver.com/pentaeduclub/5392 답변글 참고....

open 이밴트에 기술... (버튼일때는 this. 대신 parent로 하심 됩니다.)

This.setredraw(false)

CommandButton cb_7

cb_7 = CREATE CommandButton
// cb_7 = create using 'cb_6'
this.OpenUserObject(cb_7, 1842 + 100, 436 + 100) 

cb_7.resize( 500, 100 )
cb_7.visible = true
This.setredraw( True)

 

오브젝트 생성  http://cafe.naver.com/pentaeduclub/2876

 

데이타원도우/데이타스토어 동적생성  http://cafe.naver.com/pentaeduclub/5389  

질문과 답년글을 참고하시면 좋은 내용입니다. 답글에 링크도 같이 참고하시기 바랍니다..

 

원도우 형변환과 관련  http://cafe.naver.com/pentaeduclub/4962 ,  http://cafe.naver.com/pentaeduclub/4979

Posted by 농부지기
,