반응형

Arc( )
주어진 좌표를 이용하여 아크를 그린다. 


Global External Function:

FUNCTION boolean Arc(ulong hwnd, long r1, long r2, long r3, long r4, long a1, long a2, long a3, long a4) LIBRARY "Gdi32.dll"

Script:
Boolean rtn
ulong l_handle, l_device
long lv[8]
l_handle = handle(w_main)  // 'w_main' is the name of the sample window.
l_device = GetDC(l_handle)
lv[ ]  = {10,40,300,220,0,0,180,0}
rtn = Arc(l_device, lv[1], lv[2], lv[3], lv[4], lv[5], lv[6], lv[7], lv[8])



 

Beep( )
삑 소리가 나게 한다. 


Global External Function:
FUNCTION boolean Beep(long freq,long dur) LIBRARY "Kernel32.dll"

Script:
Boolean rtn
Long ll_freq, ll_dur

ll_freq = 500
ll_dur = 20
rtn = Beep(ll_freq, ll_dur)



 

BringWindowToTop( )
타겟 윈도우에게 가장 위쪽으로 나오도록 메시지를 보낸다. 파워빌더의 오브젝트명.bringtotop = true과 동일하다. 


Global External Function:
FUNCTION boolean BringWindowToTop(ulong w_handle) LIBRARY "User32.dll"

Script:
Boolean rtn
ulong l_handle

l_handle = handle(w_win2)
rtn = BringWindowToTop(l_handle)



 

Chord( )
주어진 좌표에 기반을 둔 현(사각형, 타원(?))을 그린다. 


Global External Function:
FUNCTION boolean Chord(ulong hwnd,long x1,long y1,long x2,long y2,long r1, long r2, long r3, long r4) LIBRARY "Gdi32.dll"

Script:
boolean rtn
ulong l_handle, l_device
long lv[8]

l_handle = handle(w_main)
l_device = GetDC(l_handle)

// This can be done in one line:   i.e.  l_device = GetDC(handle(w_main))
lv[ ] = {5,5,200,200,0,0,200,300}
rtn = Chord(l_device, lv[1], lv[2], lv[3], lv[4], lv[5], lv[6], lv[7], lv[8])



 

CloseHandle( )
이 함수는 열려있는 오브젝트의 핸들을 release한다. 


Global External Function:
FUNCTION boolean CloseHandle(ulong w_handle) LIBRARY "Kernel32.dll"

Script:
boolean rtn

ulong l_handle
l_handle = FindWindowA(0,"<window or object name>")  // Usually you would already have the handle.
rtn = CloseHandle(l_handle)



 

CloseWindow( )
타켓 윈도우를 미니마이즈시킨다.(닫지 않는다) 


Global External Function:
FUNCTION boolean CloseWindow(ulong w_handle) LIBRARY "User32.dll"

Script:
boolean rtn
ulong l_handle
l_handle = FindWindowA(0,"File manager")  // Be sure to use the exact title of the window you are targeting.

rtn = CloseWindow(l_handle)



 

CopyFileA( )
이 함수는 파일을 복사한다. 


Global External Function:
FUNCTION boolean CopyFileA(ref string cfrom, ref string cto, boolean flag) LIBRARY "Kernel32.dll"

Script:
string l_from, l_to
boolean l_flag, rtn

l_flag = false
l_from = "c:\pwrs\pb5i32\ex\code\beach.bmp"
l_to = "c:\test.bmp"
rtn = CopyFileA(l_from, l_to, l_flag)
MessageBox("CopyFile", string(rtn))
 

CreateDirectoryA( )
새로운 디렉토리 폴더를 생성한다. 


Global External Function:
FUNCTION boolean CreateDirectoryA(ref string pathname, int sa) LIBRARY "Kernel32.dll"

Script:
boolean rtn
string l_dir
l_dir = "API Demo"

rtn = CreateDirectoryA(l_dir, 0)
If rtn then
   MessageBox("New Directory Created", "API Demo directory is located under pwrs.")
else
   MessageBox("CreateDirectory", "Failed")
end if



 

DeleteFileA( )
지정된 파일을 삭제한다. 


Global External Function:
FUNCTION boolean DeleteFileA(ref string filename) LIBRARY "Kernel32.dll"

Script:
string l_file
boolean rtn

l_file = string(sle_to.text)
rtn = DeleteFileA(l_file)
MessageBox("DeleteFile", string(rtn))



 

DeleteMenu( )
이 함수는 지정된 메뉴아이템을 삭제하는데 사용된다. 


Global External Function:
FUNCTION boolean DeleteMenu(ulong mhand, uint upos, uint flag) LIBRARY "user32.dll"

Script:
ulong m_handle
boolean rtn

m_handle = GetSystemMenu(handle(w_main), false) // Need to get the handle of the system menu first.
rtn = DeleteMenu(m_handle, 1, 0)  // The second argument, the '1', refers to the position in the menu.
Messagebox("Return Code", string(m_handle))
Messagebox("Return Code", string(rtn))



 

DestroyWindow( )
이 함수는 타겟윈도우에게 Destory메시지를 보낸다. 파워빌더의 Close("윈도우명")과 동일하다. 


Global External Function:
FUNCTION boolean DestroyWindow(ulong w_handle) LIBRARY "USER32.DLL"

Script:
boolean rtn
ulong l_handle

open(w_win2) // Open a test window
l_handle = handle(w_win2)
rtn = DestroyWindow(l_handle)



 

DllRegisterServer( )
이 함수는 OCX가 자동적으로 등록되도록 해 준다. 이 함수는 constructor이벤트에서 파워빌더 에플리케인션이 이 동작되고 있는 동안에 동적으로 OCX를 등록할때 사용된다. 


Global External Function:
FUNCTION long DllRegisterServer() LIBRARY "c:\windows\ocxname.ocx"

Script:
Long ll_rtn

ll_rtn = DllRegisterServer()
//Note:   A return code of zero most likely means the OCX is already registered.



 

Ellipse( )
이 함수는 원에 기반을 둔 타원을 그린다. 


Global External Function:
FUNCTION boolean Ellipse(ulong hwnd,long x1,long y1,long x2,long y2) LIBRARY "Gdi32.dll"

Script:
Boolean rtn
ulong l_handle, l_device
long lv[4]

l_handle = handle(w_main)
l_device = GetDC(l_handle)
lv[ ] = {5,5,300,300}
rtn = Ellipse(l_device, lv[1], lv[2], lv[3], lv[4])



 

ExitWindowsEx( )
이 함수는 윈도우 O/S에게 윈도우가 종료되어야 함을 알려 윈도우 O/S가 종료되게 한다. 


Global External Function:
FUNCTION boolean ExitWindowsEx(uint dwReserved, uint uReserved) LIBRARY "User32.dll"

Script:
boolean rtn
rtn = ExitWindowsEx(0,0)  // Zero's tell it to shut down immediately.



 

FatalExit( )
이 함수는 실행중인 에플리케이션을 강제로 종료시킵니다. 디버깅의 용도로는 사용하되 다른 용도로는 사용하지 않는 것이 좋다. 


Global External Function:
SUBROUTINE FatalExit(int exitcode) LIBRARY "Kernel32.dll"

Script:
int rtn

rtn = MessageBox("This API call is suppose to produce a GPF!","Are You Sure?", Exclamation!, YesNo!,2)
If rtn = 1 Then
    MessageBox("Final Notice!","You will have to reboot after this API call!")
    FatalExit(1)
End If



 

FindWindowA( )
이 함수는 이름으로 호출된 윈도우의 핸들을 리턴합니다. 파워빌더 윈도우즈에서만 사용가능합니다. 파워빌더의 Handle( )과 유사합니다. 


Global External Function:
FUNCTION ulong FindWindowA(ulong classname,string windowname) LIBRARY "User32.dll"

Script:
ulong l_handle
l_handle = FindWindowA(0,"<window name>") // i.e. "File Manager" or "Numbers.txt - NotePad"



 

FreeLibrary( )
이 함수는 활성 메모리에서 dll을 release시킵니다. 이 함수는 LoadLibraryA( )와 결합되어 사용됩니다. 


Global External Function:
SUBROUTINE FreeLibrary(ulong libhandle) LIBRARY "Kernel32.dll"

Script:
ulong modhandle  // This would usually be an instance variable

modhandle = LoadLibraryA("<32 bit dll filename>")  // This would usually be done in another event.
FreeLibrary(modhandle)



 

GetBkColor( )
이 함수는 윈도우의 백그라운트 칼라를 reference number에 의해 return합니다. 파워빌더의 다음 스크립트와 유사합니다. ulong l_color
l_color = w_main.BackColor 


Global External Function:
FUNCTION ulong GetBkColor (ulong hwnd) LIBRARY "Gdi32.dll"

Script:
ulong l_handle, l_device, l_color

l_handle = handle(w_main)
l_device = GetDC(l_handle)
l_color = GetBkColor(l_device)



 

GetCapture( )
마우스에 의해 캡쳐된 윈도우의 핸들을 리턴합니다. 이때 윈도우는 마우스 커서가 어디에 있는가는 상관하지 않습니다. 


Global External Function:
FUNCTION ulong GetCapture( ) LIBRARY "User32.dll"

Script:
ulong l_handle

l_handle = GetCapture( )



 

GetComputerNameA( )
이 함수는 컴퓨터의 이름을 참조의 방법으로 return합니다. 충분한 버퍼를 확보해야 합니다. 


Global External Function:
FUNCTION boolean GetComputerNameA(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll"

Script:
string ls_compname
long ll_buf

ll_buf = 25
ls_compname = space(ll_buf)
GetComputerNameA(ls_compname, ll_buf)
MessageBox("Computer name is:", ls_compname)



 

GetClassNameA( )
이 함수는 어떤 오브젝트나 윈도우의 핸들을 이용하여 클래스명을 리턴합니다. 충분한 버퍼를 확보해야 합니다. 


Global External Function:
Function long GetClassNameA(ulong hwnd, ref string cname, int buf) Library "User32.dll"

Script:
string l_class
long rtn
ulong l_handle

l_handle = handle(w_main)
l_class = space(50)
rtn = GetClassNameA(l_handle,l_class,50)
Messagebox("Classname", l_class)



 

GetCurrentDirectoryA( )
이 함수는 현재 작업디렉토리를 return합니다. 디렉토리 명이 다 들어갈만한 충분한 크기의 버퍼를 확보해야 합니다. 


Global External Function:
FUNCTION ulong GetCurrentDirectoryA(ulong BufferLen, ref string currentdir) LIBRARY "Kernel32.dll"

Script:
string ls_curdir
ulong l_buf

l_buf = 100
ls_curdir = space(l_buf)
GetCurrentDirectoryA(l_buf, ls_curdir)
MessageBox("Current Directory:", ls_curdir)



 

GetCurrentThread( )
이 함수는 현재 thread의 handle을 return합니다. 


Global External Function:
FUNCTION ulong GetCurrentThread() LIBRARY "Kernel32.dll"

Script:
ulong rtn

rtn = GetCurrentThread()
MessageBox("Current Thread Handle", string(rtn))



 

GetCursor( )
이 함수는 커서의 핸들을 return합니다. 


Global External Function:
FUNCTION ulong GetCursor( ) LIBRARY "User32.dll"

Script:
ulong l_cursor
l_cursor = GetCursor( )



 

GetCursorPos( ) & SetCursorPos( )
GetCursorPos()는 structure Mousepos를 이용해서 마우스의 x, y좌표를 return합니다. SetCursorPos()는 주어진 좌표로 마우스 커서를 이동시킵니다. 


Global External Function:
FUNCTION boolean GetCursorPos(ref mousepos mousepos2) LIBRARY "User32.dll"
FUNCTION boolean SetCursorPos(int cx, int cy) LIBRARY  "User32.dll"

Structure:  (Mousepos)
long xpos, long ypos

Script:
mousepos mouseloc
GetCursorPos(mouseloc)
Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + "  Y = " + string(mouseloc.ypos))
SetCursorPos(300,350)
Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + "  Y = " + string(mouseloc.ypos))



 

GetDC( )
이 함수는 주어진 윈도우 핸들의 device context를 return합니다. device context는 어떤 그래픽함수를 호출하고자 할 경우에 필요합니다. 파워빌더에는 비숫한 함수가 없습니다. 


Global External Function:
Function ulong GetDC(ulong hwnd) library "user32.dll"

Script:
ulong l_handle, l_device

l_handle = handle(w_main)
l_device = GetDC(l_handle)
MessageBox("Handle", string(l_device))



 

GetKeyboardState( ) & SetKeyboardState( )
첫번째 함수는 키보드의 모든 키의 상태를 256개의 ASCII배열에 의해서 return합니다. 두번째 함수는 주어진 배열의 상태에 따라서 키보드 상태를 set합니다. 여기에서 0은 키보드가 눌러지지 않는 것을 의미하고 그렇지 않은 값은 키보드가 눌러진 것을 의미합니다. 


Global External Function:
FUNCTION boolean GetKeyboardState(ref integer kbarray[256])  LIBRARY "USER32.DLL"
FUNCTION boolean SetKeyboardState(ref integer kbarray[256]) LIBRARY "USER32.DLL"

Script:
//GetKeyboardState( )
boolean rtn
integer ipkey[256]

rtn = GetKeyboardState(ref ipkey)

//SetKeyboardState( )
rtn = SetKeyboardState(ref ipkey)
if rtn = false then
  Messagebox("Failed","Something went wrong when loading into array")
else
  Messagebox("Successful","Keyboard state is loaded back into buffer")
end if



 

GetKeyState( )
이 함수는 현재 키보드의 특정한 키의 상태를 ASCII값으로 참조하여 return합니다. 


Global External Function:
Function int GetKeyState(integer VirtualKeycode) Library "User32.dll"

Script:
int rtn

rtn = GetKeyState(65)  // 65 = A
if rtn = 0 then
  MessageBox("Key State","Letter 'A' not pressed!")
else
  MessageBox("Key State","Letter 'A'  is pressed!")
end if



 

GetModuleHandleA( )
이 함수는 활성 메모리의 모듈이나 dll의 핸들을 return합니다. 


Global External Function:
Function long GetModuleHandleA(string modname) Library "Kernel32.dll"

Script:
ulong rtn

rtn = GetModuleHandleA("User32.dll")
MessageBox("Return Code", string(rtn))



 

GetParent( )
이 함수는 child handle을 검색하여 parent handle을 return합니다. 파워빌더의 'GetParent()'가 이 함수와 동일합니다. 


Global External Function:
FUNCTION ulong GetParent(ulong hwnd) LIBRARY "User32.dll"

Script:
ulong l_handle, rtn

l_handle = handle(cb_getparent) // Command Button name
rtn = GetParent(l_handle)
Messagebox("GetParent", "Parent handle = " + string(rtn) + " / Child handle = " + string(l_handle))
 

GetPixel( ) & SetPixel( )
첫번째 함수는 특정한 픽셀의 색을 알려주며 두번째 함수는 특정한 좌표의 색을 변경합니다. 


Global External Function:
FUNCTION ulong GetPixel(ulong hwnd, long xpos, long ypos) LIBRARY "Gdi32.dll"
FUNCTION ulong SetPixel(ulong hwnd, long xpos, long ypos, ulong pcol) LIBRARY "Gdi32.dll"

Script:
long lx, ly
ulong rtn
ulong l_handle, l_device

lx = 100
ly = 100
l_handle = handle(w_main)
l_device = GetDC(l_handle)
rtn = GetPixel(l_device, 100, 100)
MessageBox("Position " + string(lx) + "," + string(ly),"Color = " + string(rtn))
SetPixel(l_device, lx, ly, 0)  // This call will set the pixel at lx, ly to black.



 

GetSystemMetrics( )
이 함수는 현재 화면의 해상도 픽셀단위를 이용해서 알려줍니다. 이 함수는 아주 민감하여 정확히 선언을 해야 하며 "GetSystemMetrics"라고 선언해야 하는데 "getsystemmetrics"로 선언하면 절대 안됩니다. 


Global External Function:
FUNCTION int GetSystemMetrics(int indexnum) LIBRARY "user32.dll"

Script:
int l_xx, l_yy

l_xx = GetSystemMetrics(0)
l_yy = GetSystemMetrics(1)
Messagebox("Screen Resolution", string(l_xx) + " , " + string(l_yy))



 

GetSystemMenu( )
이 함수는 에플리케인션이 복사 또는 수정을 위해 시스템이나 윈도우즈의 메뉴를 사용할 수 있게 합니다. 


Global External Function:
FUNCTION boolean GetSystemMenu(ulong mhandle, boolean flag) LIBRARY "user32.dll"

Script:
boolean flag
ulong l_handle, m_handle

l_handle = handle(w_main)
flag = false
m_handle = GetSystemMenu(l_handle, flag)
Messagebox("Return Code", string(m_handle))



 

GetSystemTime( )
이 함수는 structure SystemTime을 이용하여 시스템 타임을 return합니다. 


Global External Function:
SUBROUTINE GetSystemTime(ref systemtime systimeptr) Library "Kernel32.dll"

Structure:  (SystemTime)
uint year,  uint month,  uint dayofweek,  uint day,  uint hour,  uint minute,  uint second,  uint millisecond

Script:
systemtime s_systime
string l_day, l_date, l_time

GetSystemTime(s_systime)

l_date = string(s_systime.month) +"/"+ string(s_systime.day) &
       +"/"+ string(s_systime.year)
l_time = string(s_systime.hour) +":"+ string(s_systime.minute) &
       +":"+ string(s_systime.second) +":"+ string(s_systime.millisecond)

CHOOSE CASE s_systime.dayofweek
   CASE 1
      l_day = "Sunday"
   CASE 2
      l_day = "Monday"
   CASE 3
      l_day = "Tuesday"
   CASE 4
      l_day = "Wednesday"
   CASE 5
      l_day = "Thursday"
   CASE 6
      l_day = "Friday"
   CASE 7
      l_day = "Saturday"
END CHOOSE
Messagebox("System Time:",l_date + "   " + l_day + "   " + l_time)



 

GetThreadPriority( )
이 함수는 주어진 thread의 우선 순위를 return합니다. 


Global External Function:
FUNCTION int GetThreadPriority(ulong hthread) LIBRARY "Kernel32.dll"

Script:
ulong l_handle
integer rtn

l_handle = GetCurrentThread()
rtn = GetThreadPriority(l_handle)
MessageBox("Current Thread Priority", string(rtn))



 

GetUserNameA( )
이 함수는 현재 유저의 로그온 네임을 return합니다. (유저명을 저장할 수 있을 만큼의 충분한 버퍼를 확보해야 합니다.) 


Global External Function:
FUNCTION boolean GetUserNameA(ref string uname, ref ulong slength) LIBRARY "ADVAPI32.DLL"

Script:
string  ls_username
string  ls_var
ulong  lu_val
boolean rtn

lu_val = 255
ls_username = Space( 255 )
rtn = GetUserNameA(ls_username, lu_val)
Messagebox("GetUserNameA", "Username = " + string(ls_username))



 

GetWindowsDirectoryA( )
이 함수는 윈도우즈 디렉토리를 return하며 디렉토리를 얻기 위해 디렉토리가 저장될 만한 길이의 충분한 메모리를 확보해야 합니다. 


Global External Function:
FUNCTION ulong GetWindowsDirectoryA(ref string wdir, ulong buf) LIBRARY "kernel32.dll"

Script:
ulong l_buf
string windir

l_buf = 144
windir = space(144)
GetWindowsDirectoryA(windir, l_buf)
MessageBox("Current Directory", windir)



 

GlobalMemoryStatus( )
이 함수는 structure Memory를 이용하여 현재 메모리의 모든 정보를 리턴합니다. 


Global External Function:

SUBROUTINE GlobalMemoryStatus(ref memory mem2) LIBRARY "Kernel32.dll"

Structure:(Memory)
ulong m_length, ulong m_loaded, ulong m_totalphys, ulong m_availphys, &
ulong m_totalpagefile, ulong m_availpagefile, ulong m_totalvirtual, &
ulong m_availvirtual

Script:
memory sysmem

GlobalMemoryStatus(sysmem)
Messagebox("Memory Length", string(sysmem.m_length))
Messagebox("Memory Loaded", string(sysmem.m_loaded))
Messagebox("Total Physical Memory", string(sysmem.m_totalphys))
Messagebox("Total Available Memory", string(sysmem.m_availphys))
Messagebox("Total Page Size", string(sysmem.m_totalpagefile))
Messagebox("Available Page Size", string(sysmem.m_availpagefile))
Messagebox("Total Virtual Memory", string(sysmem.m_totalvirtual))
Messagebox("Available Virtual Memory", string(sysmem.m_availvirtual))



 

LoadLibraryA( )
이 함수는 dll을 (활성)메모리에 로드합니다. 32비트에서만 사용할 수 있습니다. 


Global External Function:
FUNCTION ulong LoadLibraryA(string modname) LIBRARY "Kernel32.dll"

Script:
ulong modhandle

modhandle = LoadLibraryA("c:\windows\mydll.dll")  // Pathing isn't necessary if dll is in dos search path.
If modhandle > 0 Then
   MessageBox("Return Code", "Load Successful -> handle = " + string(modhandle))
else
   MessageBox("Result","Unable to load module")
end if



 

MciSendStringA( )
이 함수는 AVI파일을 PLAY하며 사용법이 좀 복잡합니다. 파워빌더에는 비슷한 함수가 없습니다. 


Global External Function:
FUNCTION long MciSendStringA(string cmd, REF string rtn, long size, long wnd) LIBRARY "winmm.dll"

Script:
string s_errortext
string filename

filename = "c:\pwrs\pb5i32\ex\code\pbspin.avi"
MciSendStringa ("open "+Filename+"  type AVIVideo alias test wait",s_errortext, 0,0)
MciSendStringa ("Window test handle " + string(handle(w_main)) + " wait",s_errortext, 0, 0)
MciSendStringa ("Put test destination wait",s_errortext, 0, 0)
MciSendStringa ("Play test wait", s_errortext, 0, 0)
MciSendStringa ("Close test", s_errortext, 0, 0)



 

MessageBoxA( )
이 함수는 메시지 박스를 출력합니다. 파워빌더의 MessageBox()와 유사합니다. 


Global External Function:
FUNCTION long MessageBoxA(ulong hwnd, ref string text, ref string title, ulong style) LIBRARY "User32.dll"

Script:
long rtn
ulong handle1, style1
string text1
string title1

handle1 = handle(parent)
text1 = "This is an API Messagebox"
title1 = "API MessageBox"
style1 = 0
rtn = MessageBoxA(handle1,text1,title1,style1)



 

Mouse_Event( )
이 함수는 마우스 포인터를 이동시키거나 마우스 버튼의 클릭이벤트를 발생시키거나 기타 유저가 마우스를 이용하여 할 수 있는 일을 합니다. 아래의 예제는 마우스를 왼쪽으로 80픽셀, 위로 50픽셀이동시킵니다. structure mousepos는 마우스의 이동전의 좌표입니다. 


Global External Function:
SUBROUTINE Mouse_Event(ulong dwflag,ulong dx,ulong dy,ulong cbutton,ulong dwextra) LIBRARY "User32.dll"

Structure:  (Mousepos)
long xpos, long ypos

Script:
int l_loop, lx, ly, lflag
mousepos mouseloc

lx = mouseloc.xpos
ly = mouseloc.ypos
lflag = 1  //1 = do nothing, 7 = L-button clicked, 25 = R-button clicked
mouse_event(lflag,-80,-50,0,0)



 

MoveToEx( ) & LineTo( )
MoveToEx()는 주어진 좌표로 커서를 이동시키며, LineTo()는 현재 좌표에서 주어진 좌표까지 라인을 그립니다. 


Global External Function:
FUNCTION boolean MoveToEx(ulong hwnd,long wx, long wy,ref prepos prepos2) LIBRARY "Gdi32.dll"
FUNCTION boolean LineTo(ulong hwnd,long wx, long wy) LIBRARY "Gdi32.dll"

Structure:  (Prepos)
long xpos, long ypos

Script:
ulong l_handle, l_device
prepos previouspos

l_handle = handle(w_main)
l_device = GetDC(l_handle)
MoveToEx(l_device,100,100,previouspos)
LineTo(l_device,200,200)



 

MoveWindow( )
이 함수는 주어진 값에 따라 윈도우의 위치 및 크기를 변경합니다. 


Global External Function:
FUNCTION boolean MoveWindow(ulong whand,int wx,int wy,int ww,int wh,boolean wflag) LIBRARY "user32.dll"

Script:
boolean rtn
ulong l_handle, l_device
l_handle = handle(w_main)
rtn = MoveWindow(l_handle,10,10,100,100,true)
MessageBox("Return Code",string(rtn))



 

Pie( )
이 함수는 주어진 좌표를 이용하여 파이챠트에 기반을 둔 반원을 그립니다. 


Global External Function:
FUNCTION boolean Pie(ulong hwnd,long x1,long y1,long x2,long y2,long x3,long y3,long x4,long y4) LIBRARY "Gdi32.dll"

Script:
Boolean rtn
ulong l_handle,l_device

long lv[8]
lv[ ] = {10,50,290,220,0,0,80,0}
l_handle = handle(w_main)
l_device  = GetDC(l_handle)
rtn = Pie(l_device,lv[1],lv[2],lv[3],lv[4],lv[5],lv[6],lv[7],lv[8])



 

Polygon( )
이 함수는 주어진 좌표를 이용하여 도형에 기반한 타원을 그립니다. 


Global External Function:
FUNCTION boolean Polygon(hdc, ref struct poly poly2, int cnt) LIBRARY "Gdi32.dll"

Structure:  (Poly)
long xpos[5], long ypos[5]  //The size of the array is proportional to the number of sides in the Polygon.

Script:
ulong l_handle, l_device
int pcnt
l_handle = handle(w_main)
l_device = GetDC(l_handle)
pcnt = 5
poly poly3
poly3.xpos[ ] = {50,100,150,200,250}
poly3.ypos[ ] = {50,100,150,200,250}
Polygon(l_device,poly3,pcnt)



 

PostMessageA( )
이 함수는 지정된 윈도우에 의해서 만들어진 thread와 관련된 메시지(minimize, close)를 message queue에 post하며 이것이 처리되기전까지는 return되지 않는다. 


Global External Function:
FUNCTION boolean PostMessageA(ulong hwndle,UINT wmsg,ulong wParam,ulong lParam) Library "User32.dll"

Script:
ulong l_handle
boolean rtn

l_handle = handle(w_main)
rtn = PostMessageA(l_handle,274,61472,0)   // 61472 = minimize, 61488 = maximize, 61728 = normal state



 

Rectangle( )
이 함수는 주어진 좌표에 의해서 사각형을 그린다. 


Global External Function:
FUNCTION boolean Rectangle(ulong hwnd,long x1,long y1,long x2,long y2) LIBRARY "Gdi32.dll"

Script:
Boolean rtn
ulong l_handle,l_device
long lv[4]

lv[ ] = { 10,10,275,215}
l_handle = handle(w_main)
l_device  = GetDC(l_handle)
rtn = Rectangle(l_device,lv[1],lv[2],lv[3],lv[4])



 

SendMessageA( )
이 함수는 지정된 윈도우에 의해서 만들어진 thread와 관련된 message를 message queue에 보내며 그 message가 처리될때까지 return되지 않는다. 


Global External Function:
FUNCTION long SendMessageA(ulong hwndle,UINT wmsg,ulong wParam,ulong lParam) Library "User32.dll"

Script:
ulong l_handle
long rtn

l_handle = handle(w_main)
rtn = SendMessageA(l_handle,274,61728,0)



 

SetCapture( )
이 함수들은 같이 사용되며, SetCapture()함수는 ReleaseCapture()가 호출될때까지 마우스에 락을 건다. 


Global External Function:
FUNCTION ulong SetCapture(ulong a) LIBRARY "User32.dll"
FUNCTION boolean ReleaseCapture( ) LIBRARY "User32.dll"

Script:
boolean rtn
ulong l_loop, u_test, u_long
u_test = handle(parent)
u_long = SetCapture(u_test)

SetPointer(SizeNWSE!)
for l_loop = 1 to 150000
next
rtn = ReleaseCapture( )



 

SetComputerNameA( )
이 함수는 컴퓨터(다른 컴퓨터에서 참조되는)의 이름을 변경한다. 


Global External Function:
FUNCTION boolean SetComputerNameA(ref string cname) LIBRARY "kernel32.dll"

Script:
boolean rtn
string l_name

l_name = "Powerbuilder"
rtn = SetComputerNameA(l_name)

if rtn then
   MessageBox("Computer name changed to 'Powerbuilder'", "You'll need to reboot for it to take effect")
else
   MessageBox("SetComputerName", "Failed")
end if



 

SetCurrentDirectoryA( )
이 함수는 O/S가 가리키고 있는 현재의 디렉토리를 변경한다. 파워빌더에는 이와 유사한 함수가 없다. 


Global External Function:
FUNCTION boolean SetCurrentDirectoryA(ref string cdir) LIBRARY "kernel32.dll"

Script:
boolean rtn
string l_dir

l_dir = "c:\My Documents"
rtn = SetCurrentDirectoryA(l_dir)
MessageBox("SetCurrentDirectory", string(rtn))



 

SetFocus( )
주어진 윈도우 또는 오브젝트로 포커스를 변경하는 기능을 수행한다. 파워빌더의 오브젝트.SetFocus( )와 유사하다. 


Global External Function:
SUBROUTINE SetFocus(long objhandle) LIBRARY "User32.dll"

Script:
SetFocus(handle(sle_1))  // This function gets the handle from PB.



 

SetThreadPriority( )
이 함수는 주어진 thread의 우선순위를 set한다. default값은 0이며, 그 어떤 높은 우선순위도 hold상태가 되어 더 많은 cpu time을 받을 수 있다. 우선 순위를 너무 높게 잡거나 마우스가 작동하지 않도록 하는 것은 좋지 않다. 


Global External Function:
FUNCTION boolean SetThreadPriority(ulong hthread, int npriority) LIBRARY "Kernel32.dll"

Script:
ulong l_handle
boolean rtn

l_handle = GetCurrentThread()
rtn = SetThreadPriority(l_handle, 2) // Set the priority of thread higher.
MessageBox("Current Thread Priority Changed", string(rtn))



 

Sleep( )
이 함수는 O/S가 주어진 시간(milliseconds)동안 현재의 thread를 무시하도록 한다. 이 함수가 Active상태인 동안 화면은 다시 그려지지 않는다. 


Global External Function:
SUBROUTINE Sleep(ulong milli) LIBRARY "Kernel32.dll"

Script:
ulong l_delay
l_delay = 2000
Sleep(l_delay)



 

SndPlaySoundA( ) & WaveOutGetNumDevs( )
이 함수들은 WAV파일을 파워빌더에서 플레이 한다. 파워빌더에는 이와 유사한 함수가 없다. 


Global External Function:
FUNCTION boolean SndPlaySoundA(string wavfile, uint flag) LIBRARY "WINMM.DLL"
FUNCTION uint WaveOutGetNumDevs() LIBRARY "WINMM.DLL"

Script:
int    lui_NumDevs, l_mode
string ls_file

l_mode  = 0
ls_file = string(c:\windows\media\chimes.wav)
lui_NumDevs = WaveOutGetNumDevs()
IF lui_NumDevs > 0 THEN
   SndPlaySoundA(ls_file, l_mode)
END IF



 

SwapMouseButton( )
이 함수는 마우스의 오른쪽 버튼과 왼쪽 버튼을 서로 바꾸는 일을 하며 파워빌더에는 이와 유사한 함수는 없다. 마우스의 일반(Normal) 상태를 return하기 위해 이 함수는 다시 호출되어야 한다. 


Global External Function:
FUNCTION boolean SwapMouseButton(boolean var) LIBRARY "User32.dll"

Script:
boolean rtn, l_mouse

rtn = SwapMouseButton(l_mouse)
If l_mouse = true Then
   MessageBox("Change Made","Right button on Left Side")
Else
   MessageBox("Change Made","Right button on Right Side")
End If



WinExec( )
이 함수는 주어진 파일명(파일의 경로 포함)을 O/S 트리거에게 전달하며 O/S트리거는 주어진 파일을 실행한후 그 결과를 Return한다. 파워빌더에서는 RUN() 함수를 사용하면 된다.(i.e. Run("c:\windows\calc.exe") 


Global External Function:
FUNCTION uint WinExec(ref string filename, uint wstyle) LIBRARY "kernel32.dll"

Script:
string ls_filename
uint rtn, wstyle

ls_filename = "c:\windows\calc.exe"
style = 1
tn = WinExec(ls_filename, wstyle)
Messagebox("Return Code", string(rtn))

[출처] 파워빌더 API함수|작성자 연쓰

반응형

본 자료는

파워빌더 개발자 싸이트 PBDN( http://www.pbdn.net )에서
김태훈(guroom@hanmail.net) 님께서 올리신 자료 입니다


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

[ 파워빌더의 기초문법 ]

VC++(OOP개념)과 VB를 합쳐놓은것

   1) 코딩시 대소문자 구분이 없다 but 가독성을 높이기 위해 가능한 구분하자
     -> VB을 따왔음...가능한 단어의 첫글자는 대문자로 쓰자

   2) 주석 : 주석다는 습관!
     //             ->한 줄 주석
     /*  ......  */ ->여러줄 주석

   3) 명령문은 line단위로 이뤄진다
     한줄에 여러 개의 명령어를 입력하고 싶을 경우 ";"으로 구분한다
      ex) a=a+b ; b=b+10 ; c=c+7
     하나의 명령어를 여러 줄로 나눠 입력할 경우 " &"
        -> a=a+b+c
            a=a+ &
            b+ &
            c
   4) 변수
    ① Variable Types
      정수형 - integer(2byte) - 32768 ~ 32767
                - long형(4byte) - 20억 ~ 20억
      실수형 - real형(4byte)
                - double형(8byte)
      문자형 - char : 문자 한글자 저장 ex) char a='t'
                - string형 :문자열 저장 ex) string a="korea"
      논리형 - boolean ex) a,b=true
      시간형(data저장형식) - time a
                                       a=Gettime//PB의 내장함수
      날짜형 - date a
      시간날짜형 - DateTime a

    ② PB만이 갖고있는 변수형!!!
     - Blob형 : 아주 긴 문자열이나 image data저장
     - Any형  : 가변길이형 data
           +=========================================+
           :!!!  변수선언시 초기값을 주지 않을 경우      :
           :                                                               :
           :      default     숫자      = 0                          :
           :                    문자      = null                       :
           :                    boolean = false                     :
           +=========================================+

    ③ 변수의 규칙
      - 변수길이는 40자까지 가능
      - 모든 변수는 반드시 선언해줘야 한다:사용자가 만들어 쓸 경우
      - 대소문자 구분이 없다
      - 영문자, 숫자, -, _, #, %, $로 조합
        "-"는 반드시 창의 design/option에서 해제해줘라!!!

   5) 배열
          +=====================================+
          :   !!! tool마다의 배열                            :
          :    a(10):0번째~9  ->C                         :
          :    a(10):0번째~10 ->Visual Basic         : 
          :    a[10]:1번째~10 ->Power Builder       :
          +=====================================+
     ex) integer a[20]
         c[3]=20
         integer a[5]={1,5,3,16,4}
         integer a[10 to 20]=a[10]~a[20]

    ① 가변길이
     - 편리하지만 프로그램 속도를 떨어뜨린다
     - 1 차원배열에서만 가능

    ② 다차원배열
       integer a[행,열]
       ex) a[2,3]
       integer a[면,행,열]
       ex) a[2,3,3]

   6) PB의 내장함수
    ① 날짜함수                               ② 시간함수
      Now() "현재의 시스템의 날짜         hour()
      Year() "년도                                  minute()
      month()                                        second()
      day()
      이외에도 아주 많습니다.

   7) 용어
    ① This : 현재 사용중인 객체(object)를 의미
      ex) cb_1에 코딩할 경우: cb_1.text="종료"
                                    ->this.text="종료"


    ② Parent : 현재 사용중인 객체의 부모window
                    menu없는 창을 닫을 때 ->close(parent)
          +=============================================+
          :  참고!!                                                          :
          :       객체를 복사할 때 두가지 방법                  :
          :     -duplication :개체만 copy                           :
          :     -edit/copy후 paste :개체+코딩까지 copy      :
          :                                                                     :
          : 따라서...                                                       :
          :  close(parent)하는게 편하다                           :
          :          ->코딩을 일일이 고칠 필요가 없다         :
          +=============================================+

    ③ Parent Window : 메뉴가 있는 window를 말함
                      종료시 close(parent window)


    ④ 종료
      Halt : application 종료 but 메모리는 해제되지 않는다
      Halt Close : application의 close 이벤트를 발생시키면서 종료

   8) 제어문:프로그램의 흐름을 통제
      형식> 컨트롤이름.속성=값
    ① if문
       +=======================+
       :  if 조건식 then              :
       :     명령1                      :
       :  end if                         :
       :                                   :
       :         OR                      :
       :                                   :
       :  if 조건식 then 명령1     :
       +=======================+
       +=================================+
       :  if 조건 then                                :
       :     명령1                                     :
       :  else                                          :
       :     명령2                                     :
       :  end if                                        :
       :                                                  :
       :              OR                                :
       :                                                  :
       :  if 조건 then 명령1 else 명령2       :
       +=================================+

    ② choose case문
       +========================+
       :    choose case 변수       :
       :       case a1                   :
       :       case a2                   :
       :       case a3                   :
       :       case a4                   :
       :       case else                :
       :    end choose                :
       +========================+


   9) 연산자
      +, -, *, /, >, <, >=, <=, <>
      and, or, not

   10) 반복문
    ① for~ next문
       +=========================================================+
       :    for 변수명=초기값 to 최종값 step 증가(+)/감소(-)값         :
       :          .......                                                                      :
       :   .......                                                                             :
       :    next                                                                             :
       : -> 횟수가 정해져 있는 경우 :   계산                                   :
       :    무제한적으로 돌아갈 경우                                             :
       +=========================================================+

    ② do while
       +=======================================================+
       :    do while 조건                                                            :
       :        ....                                                                        :
       :    loop                                                                          :
       : ->조건식이 참인 동안 실행                                            :
       :   조건식이 맞지 않으면 실행을 시작하지 않을 수도 있다  :
       +=======================================================+
         
       +======================================================================+
       :   do                                                                                                   :
       :   ......                                                                                                 :
       :   loop while 조건                                                                                 :
       : ->조건식이 틀리더라도 한 번은 실행이 된다//조건식이 뒤에 있으므로    :
      +=======================================================================+

   ③ do until
        +=====================================================+
        :   do until 조건식                                                        :
        :     .......                                                                    :
        :     loop                                                                     :
        : ->조건식이 참이 될때까지 실행//조건이 거짓인 동안   :
        +=====================================================+
        +=====================+
        :   do                          :
        :     .......                    :
        :   loop until 조건         :
        +=====================+


   ④ 분기문(go to문)
        +========================+
        :     go to 문이름              :
        :        ........                     :
        :     문이름                      :
        +========================+
      ex)삼중 loop문...loop가 중첩된 경우

   ⑤ 기타문
        exit : 현재 수행중인 loop탈출
        continue :skip의 개념이 강하다
        +===========================+===========================+
        : ex1) for i=1 to 10                  :       ex2) for i=1 to 10           :
        :          .....                           :         .....                           :
        :       if i=5 then                      :       if i=5 then                    :
        :          exit                           :         continue                    :
        :       end if                           :       end if                          :
        :      sle_1.text=string(i)          :      sle_1.text=string(i)          :
        :      next                              :      next                             :
        :  print=> 1 2 3 4                    : print=>1 2 3 4 6 7 8 9 10        :
        +===========================+===========================+

   11) 추가 연산자
       a=a+1 -> a++  증가
                 --  감소
       a=a*b -> a*=b
                 +=
                 -=
                 /=

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1) 변수
   - 전역변수 :A pp.내에 전반적으로 사용이 가능
     => \declare\global variable에서...
   - 지역변수 : 해당 스크립트문장내에서만 사용가능
    (instance variable) 해당window에서만 사용할 수 있는 변수
                               window가 닫히면 자동소멸!
                               window가 열리면 생성,
     cf) 다른 win에서 참조할 경우->win이름.변수명
        if 다른win이 닫히면 참조한 창도 에러 떨어짐
        why? instance 변수는 창이 없어지면 같이 소멸한다
   - 공용변수 shared variable :해당win에서 사용가능
                              해당win이 open하면 생성,
                              해당win이 close해도 소멸되지 않는다.
2) 함수
   함수명(인수1,인수2,인수3,...)
   - 지역 :\declare\function in window
   - 전역 :아이콘


   ① 사용자함수의 종류
    - 리턴값이 있는 경우 :실행된 결과값을 보여준다 ex)계산
      형식> 함수명(인수1, 인수2, ...) 인수 :함수가 처리해야 하는 값
    - 리턴값이 없는 경우 :반복적인 처리를 많이 하는 경우


   ② 자체함수 : PB함수
     +==============================================+
     : 참고!!! tool bar의 함수 : 전역함수                      :
     :         Declare\Windows Function : 지역함수      :
     :         Declare\Windows Structure : 구조체         :
     +==============================================+

3) 배열
   같은 data형의 변수를 잡아 줄때 모든 변수를 하나의 변수로 잡아준다고 생각
   즉 하나의 보따리에 각각의 보따리를 넣는다고 생각하면...?
   랜덤하게 섞이는것을 막을 수 있다
   ex)학생성적표 관리:여러과목(문자)과 그에 따른 각각의 점수(정수)

4) 구조체
   서로 다른 data형의 변수를 하나의 커다란 변수로 잡는다
   ex)회사의 사원관리
   하나의 사원에 해당하는 것들 (사원이름 주소 성별 나이)->각각의 성질이 다르다

5) Pointer
   - 번지에 있는 값을 전달한다. -> call by value
   - 번지값을 전달해준다 -> call by reference

반응형

파워빌더 함수정리

 

 1. 배열(Array) 처리 함수 

LowerBound : 지정한 배열의 하위 경계

UpperBound : 지정한 배열의 상위 경계

 

2. Bolb관련 함수 

Blob        : 텍스트 데이터를 Blob 데이터로 변환 또는 복사

BlobEdit   : PB가 지원하는 데이터를 Blob변수로 복사

BlobMid   : Blob 데이터 문자열에서 N번째 문자를 반환

Len         : 문자열의 길이

 

3. 데이터형 검사 및 변환 함수 

Char         : blob,정수,문자열을 문자로 바꿔서 반환

Dec          : 문자열의 내용을 십진수로 바꿔서 반환

Double      : 문자열의 내용을 Double로 바꿔서 반환

Integer      : 문자열의 내용을 정수로 바꿔서 반환

Long         : 문자열의 내용을 long으로 바꿔서 반환

Real         : 문자열의 내용을 실수로 바꿔서 반환

Date         : 데이터베이스로부터 읽은 DateTime값에서 Date부분만 빼온다.

DateTime   : Date나 Time을 DateTime 값으로 변환한다.

IsDate       : 지정한 문자열이 유효한 Date값을 지녔는지 검사한다.  

IsNull        : 넘어온 인자가 NULL인지 검사한다.

IsNumber   : 지정한 문자열이 숫자값을 지녔는지 검사한다.

IsTime       : 지정한 문자열이 유효한 Time값을 지녔는지 검사한다.

String        : 지정한 형식으로 문자열을 얻는다.

Time         : 데이터베이스로부터 읽은 DateTime값에서 Time부분만 빼온다.

 

4. 날짜,요일,시간 처리 함수 

Day               : 일자를 구한다(1에서 31 사이의 정수)

DayName       : 주간의 요일명을 구한다.

DayNumber    : 주간의 요일을 숫자로 표현한다.(예를들면 일요일은1, 목요일은 5)

DaysAfter       : 지정한 날짜에 n일전,후를 구한다.

Hour             : 주어진 시간의 시 값을 구한다.

Minute          : 주어진 시간의 분 값을 구한다.

Month           : 주어진 날짜의 월 값을 구한다.(1에서 12까지)

Now             : 클라이언트의 시스템 시간을 구한다.

RelativeDate  : 주어진 날짜를 기준으로 n일 후 날짜를 구한다.

RelativeTime  : 주어진 시간을 기준으로 n초 후 시간을 구한다.

Second         : 주어진 시간의 초 값을 구한다.

Today           : 클라이언트의 현재 날짜를 구한다.

Year             : 주어진 날짜의 년 값을 구한다.(1000에서 3000년까지임)

 

5.DDE클라이언트 함수 

CloseChannel        : OpenChannel함수로 열린 DDE서버 어플리케이션의 채널을 닫는다.

ExecRemote          : 서버 어플리케이션에게 명령 실행을 요구한다.

GetDataDDE          : 연결된 서버 어플리케이션으로부터 새로운 데이터를 받아온다.

GetDataDDEOrigin  : 연결된 서버 어플리케이션으로부터 원래의 데이터를 받아온다.

GetRemote            : 서버 어플리케이션에게 데이터를 요구한다.

OpenChannel        : DDE서버 어플리케이션을 연다.

RespondRemote     : 서버에게 명령 또는 데이터가 클라이언트에게 받아들여졌는지를 알려준.

SetRemote             : 서버 어플리케이션에게 지정한 값을 설정하도록 한다.

StartHotLink           :서버 어플리케이션과의 연결을 시작한다.

StopHotLink           : 서버 어플리케이션과의 연결을 종료한다.

 

6. DDE서버 함수 

GetCommandDDE           : 클라이언트 어플리케이션이 보낸 명령을 구한다.

GetCommandDDEOrigin   :어떤 클라이언트 어플리케이션이 명령을 보냈는지 구한다.

GetDataDDE                  : 클라이언트 어플리케이션이 보낸 데이터를 구한다.

GetDataDDEOrigin          :어떤 클라이언트 어플리케이션이 데이터를 보냈는지 구한다.

RespondRemote            :클라이언트에게 명령 또는 데이터가 서버에게 받아들여졌는지를 알려준.

SetDataDDE                  : 클라이언트 어플리케이션에게 데이터를 보낸다.

StartServerDDE              :파워빌더를 서버로 동작하게 한다.

StopServerDDE              :파워빌더가 서버로 동작하는 것을 중지한다.

 

7. 파일처리 함수 

FileClose                  : 파일 닫기

FileDelete                 : 파일 삭제

FileExists                 : 파일 존재 유/무

FileLength                : 파일 길이

FileOpen                  : 파일 열기

FileRead                  : 파일 읽기

FileSeek                  : 파일 내 위치 이동

FileWrite                  : 파일에 쓰기

GetFileOpenName     : 파일 열기 공통 다이얼로그 열기

GetFileSaveName     : 파일 저장 공통 다이얼로그 열기

 

8. 라이브러리 함수 

LibraryCreate    : 라이브러리 생성

LibraryDelete    : 라이브러리 삭제

LibrarDirectory  : pb라이브러리 파일의 모든 오브젝트의 리스트를 구한다.

LibraryExport    : 라이브러리 파일의 모든 오브젝트를 Export한다.

Library Import    : 지정한 라이브러리 파일에서 오브젝트를 Import한다.

 

9.MAPI함수 

mailAddress                : 메일 메세지에 주소를 주거나 주소 리스트를 보여준다.

mailDELETEMessage   : 메일 메시지를 지운다.

mailGetMessages        : 메지시 id를 얻어온다.

mailHandle                  : 내부 메일 시스템 핸들을 얻어온다.

mailLogOff                   : 메세징 시스템과의 세션을 끊는다.

mailLogOn                   : 메세징 시스템과의 세션을 시작한다.

mailReadMessage        : 메일 메시지를 읽는다.

mailRecipientDetails      : 지정된 수취인의 주소 정보를 보여준다.

mailResolveRecipient    : 불분명한 수취인 명을 결정한다.

mailSaveMessage        : 사용자 수신함에 새로운 메시지를 생성하거나 기존에 있는 메시지를 대체한다.

mailSend                     : 메일 메시지를 보낸다.

 

10. 수치 처리 함수 

Abs              : 수치의 절대값을 얻는다.

Ceiling         : 지정한 수보다 크거나 같은 최소 정수를 구한다.

Cos             : 주어진 각도의 코사인 값을 구한다.

Exp              : e를 Number만큼 거듭제곱한 값을 구한다.(e=2.71828182845904)

Fact             : 계승값을 구한다. Number의 계승값은 1*2*3*...* Number이다.

Int                : 소수점 이하를 버리고 가장 가까운 정수로 변환한다.

Log              : 지정 숫자의 자연로그값을 구한다.

LogTen         : 지정한 숫자에 대해 밑이 10인 로그값을 구한다.

Max             : 두 수 중 큰 수를 구한다.

Min              : 두 수 중 작은 수를 구한다.

Mod             : 두 수를 나눈 나머지를 구한다.

Pi                 : 3.14159265358979를 구한다.

Rand            : 난수를 구한다.

Randomize    : 난수 발생기를 초기화한다.

Round          : 숫자를 지정한 자릿수로 반올림한다.

Sign             : 숫자의 부호를 결정한다. Number가 양수이면 1을 표시해주고 0이면 0, 음수이면 -1을 표시한다.

Sin               : 주어진 각도의 사인 값을 구한다.

Sqrt              : 양의 제곱근을 구한다.

Tan              : 주어진 각도의 탄젠트 값을 구한다.

Truncate       : 숫자의 소수점 이하를 버리고 정수로 변환한다.

 

 

11. 출력(Print)함수 

Print                  : 현재 글꼴로 문자열을 인쇄한다.

PrintBitmap         : 지정한 인쇄공간에 비트맵 이미지를 인쇄한다.

PrintCancel        : 인쇄를 취소한다.

PrintClose          : 현재 페이지를 프린터에 보내고 인쇄를 멈춘다.

PrintDefineFont    : 인쇄작업시 폰트를 정의한다. 파워빌더는 각각의 인쇄 작업에 대해 8가지 폰트를 제공한다.

PrintLine             : 지정한 위치에 지정한 굵기로 타원을 그린다.

PrintOpen           : 현재 페이지를 프린터에 보내고 새로운 페이지를 셋한다.

PrintOval            : 지정한 위치에 지정한 굵기로 타원을 그린다.

PrintPage           : 지정한 위치에 지정한 굵기로 둥근 모서리의 사각형을 그린다.

PrintRect            : 지정한 위치에 지정한 굵기로 사각형을 그린다.

PrintRouneRect   : 지정한 위치에 지정한 굵기로 둥근 모서리의 사각형을 그린다.

PrintSend           : 지정한 문자열을 프린터에게 보낸다.

PrintSetFont        : 현재 인쇄 작업에 대한 글꼴을 지정한다.

PrintSetSpacing  : 라인간 너비를 지정한다.

PrintSetup          : 프린터 설정 다이얼로그 박스를 부른다.

PrintText            : 지정한 위치에 지정한 문자를 인쇄한다.

PrintWidth          : 현재 글꼴에서 지정된 문자열의 너비를 구한다.

PrintX                : 커서의 X좌표를 구한다.

PtintY                : 커서의 Y좌표를 구한다.

 

 

 

12. 문자열 처리 함수 

Asc        : 문자열의 첫번째 문자의 ASCII값을 구한다.

Char       : 주어진 ASCII값에 해당하는 문자를 구한다.

Fill          : 지정한 문자를 반복시켜서 문자열을 만든다.

Left         : 문자열의 시작부터 지정한 수의 문자를 읽어온다.

LeftTrim   : 문자열의 시작에 있는 공백을 없앤다.

Len         : 문자열의 길이를 구한다.

Lower     : 주어진 문자열 내의 대문자를 소문자로 고친다.

Mid        : 주어진 문자열에서 시작 위치와 끝 위치를 지정해 문자열의 일정 부분만을 구한다.

Pos        : 다른 문자열에서 주어진 문자열의 위치를 찾는다.

Replace  : 문자열의 일부를 다른 문자열로 바꾼다.

Right       : 문자열의 끝에서 주어진 수의 문자를 얻어온다.

RightTrim  : 문자열의 끝에 있는 공백을 없앤다.

Space      : 지정한 길이로 공백 문자열을 얻는다.

Trim         : 문자열의 시작과 끝의 공백을 없앤다.

Upper      : 지정한 문자열 내의 소문자를 대문자로 고친다.

 

 

 

13. 시스템 및 환경 함수(System and Environment) 

Clipboard            : 윈도우의 클립보드의 내용을 얻는다.

GetApplication     : 현재 어플리케이션의 핸들을 구한다.

CommandParm    : 어플리케이션 실행시 지정된 파라미터가 있을 경우 그값을 구한다.

DoScript             : 애플 스크립트(AppleScript)를 실행한다.(매킨토시 버전에만 해당)

GetEnvironment   :시스템의 운영체제와 프로세서 등과 같은 정보를 얻는다.

Handle               : Window SDK함수를 부르기 위해 사용한다.

Post                   : 지정한 윈도우에 대한 메시지를 메시지 큐에 마지막에 삽입한다.

ProfileInt             : 지정한 프로파일에서 숫자값을 얻어온다.

ProgileString       :지정한 프로파일에서 문자열을 얻어온다.

Restart               : 모든 스크립트의 실행을 중지하고, 모든 윈도우를 닫으며 데이터베이스     Commit한후 연결을 끊고 다시 어플리케이션을 실행시킨다.

Run                   : 지정한 어플리케이션을 실행시킨다.

Send                 : 지정한 윈도우에 메시지를 순차적으로 보낸다.

SetProfileString   : 지정한 프로파일 값을 저장한다.

ShowHelp          : 윈도우 3.x에 있는 도움말(Help)파일을 읽어 파워빌더 어플리케이션에서 사용할 수 있다.

SignalError        : 어플리케이션 레벨에서의 시스템 에러를 발생한다.

Yield                : 반복문 안에서 다른 오브젝트나 어플리케이션의 메시지가 발생 됐는지를 체크할수 있게 한다.

 

 

 

14. 시간처리 함수 

CPU   : 현재 실행중인 PB어플리케이션 프로그램의 시작 시간부터 현재까지의 CPU시간을 구해준다.

Idle    : 사용자가 아무런 입력이 없이 지정한 시간이 흐르면 Idle이벤트 발생시킨다.

Timer  : 지정한 윈도우에 일정한 간격의 타이머를 지정하여 Timer이벤트를 발생시킨다.

 

 

 

15. 그밖의 함수 

Beep              : 정해진 시간(초단위)동안 경고음을 발생한다.

DBHandle        : DBMS의 핸들을 반환한다.

IsValid            : 지정한 윈도우가 열려있는지 검사한다.

KeyDown        : 사용자가 특정한 키를 눌렀는가 검사한다.

MessageBox   : 메시지 박스를 출력한다.

PixelsToUnits   : 픽셀(Pixel)을 PB의 Unit로 바꾼다.

RGB                : 특정 색상을 표현하는 Long형 값을 반환한다.

SetNull            : 변수의 유형에 상관없이 변수를 Null로 지정한다.

SetPointer        : 마우스 포인터를 지정한 모양으로 바꾼다.

TypeOf            : 오브젝트의 형을 결정한다. 예를들면 CheckBox, Picture, RadioButton 등이다.

UnitsToPixels   : PB의 Unit를 픽셀(Pixel)로 바꾼다.

 

 

1. UpperBound(배열명,{배열차원}) : 가끔 사용

   (1) 개념 : 배열의 가장높은 경계값을 알아낸다.

       Option으로 배열의 차원을 지정할 수 있으며 Default 차원은 1차원이다.

 

   (2) Return : integer(배열의 가장높은 경계값)

 

   (3) 예제

       가)

       integer li_number[7] , li_return

       li_return = UpperBound(li_number) // li_return 은 7이 된다.

       나)

       string ls_name[5,6] integer li_return

       li_return = UpperBound(ls_name,1) // li_return 은 5가 된다

       li_return = UpperBound(ls_name,2) // li_return 은 6이 된다

 

   (4) 메모 : 가변길이 선언 배열에서 ( ls_text[] )

   위의 함수를 사용하여 0이 Return되면 배열이 아직 현 메모리에 적재되지 않았음을 의미한다.

 

   (5) 상대함수 : LowerBound()

 

 

2. IsDate(string) : 자주 사용

   (1) 개념 : 특정한 String이 정확한 Date인지를 확인한다.

 

   (2) Return : Boolean ( Date가 맞으면 True 아니면 False이다. )

 

   (3) 예제 boolean lb_check

       lb_check = IsDate("1996/05/22") // lb_check 는 True이다

       lb_check = IsDate("1996/00/22") // lb_check 는 False 이다

 

   (4) 메모 : 특정한 String등을 Date로 변환시키기 직전에 많이 사용한다.

 

   (5) 유사함수 : Isnull() , Isnumber() , Istime() , Isvalid()

 

 

3. Date(datetime) , : 자주사용 Date(string) , Date(year,month,day)

   (1) 개념 : datetime , string , 년월일의 integer값을 Date 변수타입으로 변환한

 

   (2) Return : Date ( Valid 한 Date가 아닐때는 1900-01-01을 Return한다 )

 

   (3) 예제 datetime ldt_this date ld_new

       ld_new = Date(ldt_this)

       IF ld_new = Date("1900-01-01") THEN

          Messagebox("ERROR",'정확한 일자가 아닙니다 !!')

          return

       END IF

       ld_new = Date("1996/08/15") ld_new = Date(1999,11,23)

 

   (4) 유사함수 : DateTime()

 

 

4. Control명.ClassName() : 가끔사용 ClassName(변수명)

   (1) 개념 : 특정한 Object의 Class명을 String으로 알아낸다.

 

   (2) Return : String ( Error 발생시에는 empty string "" 이 반환된다)

 

   (3) 예제

       가)

       string ls_name

       ls_name = Parent.ClassName()

       IF ls_name = "w_insa001u" THEN

          sle_1.text = ls_name

       END IF

 

       // 어떤 Object의 Dragdrop Event 에서

       string ls_name dragobject ldr_what

       ldr_what = DraggedObject() ls_name = ldr_what.ClassName()

       IF ls_name = 'em_delete' THEN

          ldr_what.Drag(end!) Messagebox("Drag Object",'Drag된 Object 는 '& + ls_name + '입니다')

       END IF

 

       나)

       long ll_qty string ls_class

       ls_class = ClassName(ll_qty) // ls_class 는 'long' 을 받아온다

       ls_class = ClassName(this) // ls_class 는 현 Object 의 Class 명칭을 받아 온다

 

5. Object명.PostEvent(event명) : 자주사용

   (1) 개념 : Script가 쓰여진 현 Event가 끝난뒤 특정 Object의 Event를 수행하게 한다.

       위의 function은 script가 쓰여진 위치에 관계없음으로 그 이후에 어떤 scrip 가 있다면        그것을 모두 수행한후에 실행된다.

 

   (2) Return : Boolean (성공하면 true , event가 없거나 script가 없으면 false)

 

   (3) 예제

       cb_close.PostEvent(clicked!) // object에 기본적으로 있는 event일때

       cb_close.PostEvent("ue_keydown") // User가 정의한 event일때

 

6. Object명.TriggerEvent(event명) : 매우 자주사용

   (1) 개념 : 현 Event에서 어떤 특정Object의 특정Event를 즉각적 수행하고 돌아온.

       Script가 쓰여진 위치가 중요하다

 

   (2) Return : Boolean (성공하면 true , event가 없거나 script가 없으면 false)

 

   (3) 예제

       cb_check.TriggerEvent(clicked!) // object에 기본적으로 있는 event일때

       cb_check.TriggerEvent("ue_check") // User가 정의한 event일때

 

   (4) 메모 : 어떤 Event의 Script를 수행한다는 면에서는 Postevent와 Triggerevent는 동일하며    두 이벤트 중 어떤것을 써야할지의 선택기준은 현재의 Event가 수행되고 난 뒤 어떤 Event를 이어서 수행시키느냐 (Postevent) , 즉각적으로 어떤 Event를 수행하느냐 (Triggerevent) 의 차이이다.

 

로맨스님 블로그에서 퍼옴

+ Recent posts