ThaiPBL.com

PowerBuilder Library Thailand

อีเมล พิมพ์ PDF

การอ่าน system time เก็บเข้า structure

สวัสดีครับ  เรามีวิธีการอ่าน system time เก็บเข้า structure ได้ไม่ยากครับ เริ่มแรกก็ให้ทำการกำหนด Global External Function ก่อนครับ
SUBROUTINE GetSystemTime(ref systemtime systimeptr) Library "Kernel32.dll"

จากนั้นก็ทำการสร้าง structure โดยมีโครงสร้างดังนี้ครับ

uint year, uint month, uint dayofweek, uint day, uint hour, uint minute, uint second, uint millisecond

เก็บใว้ในชื่อว่า systemtime

จากนั้นก็ลงมือเขียนสคริปต์กันเลยนะครับ

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