home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / dataflex / func.pkg < prev    next >
Encoding:
Text File  |  1993-05-19  |  5.8 KB  |  188 lines

  1. // FUNC.PKG
  2. // New global DataFlex functions
  3. // Doug Goldner  2/25/91
  4.  
  5. #CHKSUB 1 1 // Verify the UI subsystem.
  6.  
  7. use ui
  8.  
  9. function get_month global string our_date$ returns integer
  10.    function_return (left(our_date$,2))
  11. end_function
  12.  
  13. function get_day global string our_date$ returns integer
  14.    function_return (mid(our_date$,2,4))
  15. end_function
  16.  
  17. function get_year global string our_date$ returns integer
  18.    function_return (mid(our_date$,4,7))
  19. end_function
  20.  
  21. function get_current_hour global returns string
  22.    local date tdate$
  23.    local string our_hour$
  24.    
  25.    sysdate tdate$ our_hour$
  26.    if our_hour$ lt 10 insert "0" in our_hour$ at 0
  27.    function_return our_hour$
  28. end_function
  29.  
  30. function get_current_minute global returns string
  31.    local date tdate$
  32.    local string our_hour$ our_minute$
  33.    
  34.    sysdate tdate$ our_hour$ our_minute$
  35.    if our_minute$ lt 10 insert "0" in our_minute$ at 0
  36.    function_return our_minute$
  37. end_function
  38.  
  39. function get_current_second global returns string
  40.    local date tdate$
  41.    local string our_hour$ our_minute$ our_second$
  42.    
  43.    sysdate tdate$ our_hour$ our_minute$ our_second$
  44.    if our_second$ lt 10 insert "0" in our_second$ at 0
  45.    function_return our_second$
  46. end_function
  47.  
  48. function get_hour global string our_time$ returns string
  49.    function_return (left(our_time$,2))
  50. end_function
  51.  
  52. function get_minute global string our_time$ returns string
  53.    function_return (mid(our_time$,2,4))
  54. end_function
  55.  
  56. function get_second global string our_time$ returns string
  57.    function_return (mid(our_time$,2,7))
  58. end_function
  59.  
  60. function get_time global string hr$ string min$ string sec$ integer am_pm_wanted$ returns string
  61.    local string am_pm$ time_string$
  62.    
  63.    move "AM" to am_pm$
  64.    
  65.    if hr$ gt 11 move "PM" to am_pm$
  66.    if hr$ lt 1 begin
  67.       move 12 to hr$
  68.       move "AM" to am_pm$
  69.    end
  70.    if am_pm_wanted$ eq 1 if hr$ gt 12 move (hr$ - 12) to hr$
  71.    if hr$ lt 10 insert "0" in hr$ at 0
  72.    if min$ lt 10 insert "0" in min$ at 0
  73.    if sec$ lt 10 insert "0" in sec$ at 0
  74.    move hr$ to time_string$
  75.    append time_string$ ":" min$ ":" sec$
  76.    if am_pm_wanted$ eq 1 append time_string$ " " am_pm$
  77.    function_return time_string$
  78. end_function
  79.  
  80. function get_time_no_sec global string hr$ string min$ integer am_pm_wanted$ returns string
  81.    local string am_pm$ time_string$
  82.    
  83.    move "AM" to am_pm$
  84.    
  85.    if hr$ gt 11 move "PM" to am_pm$
  86.    if hr$ lt 1 begin
  87.       move 12 to hr$
  88.       move "AM" to am_pm$
  89.    end
  90.    if am_pm_wanted$ eq 1 if hr$ gt 12 move (hr$ - 12) to hr$
  91.    if hr$ lt 10 insert "0" in hr$ at 0
  92.    if min$ lt 10 insert "0" in min$ at 0
  93.    move hr$ to time_string$
  94.    append time_string$ ":" min$
  95.    if am_pm_wanted$ eq 1 append time_string$ " " am_pm$
  96.    function_return time_string$
  97. end_function
  98.  
  99. function get_current_time global integer am_pm_wanted$ returns string
  100.    local date tdate$
  101.    local string hr$ min$ sec$
  102.    
  103.    sysdate tdate$ hr$ min$ sec$
  104.    function_return (get_time(hr$,min$,sec$,am_pm_wanted$))
  105. end_function
  106.  
  107.  
  108.  
  109. function get_current_time_no_sec global integer am_pm_wanted$ returns string
  110.    local date tdate$
  111.    local string hr$ min$
  112.    
  113.    sysdate tdate$ hr$ min$ 
  114.    function_return (get_time_no_sec(hr$,min$,am_pm_wanted$))
  115. end_function
  116.  
  117. function get_word_date global string our_date$ returns string
  118.    local integer month$
  119.    local string month_name$
  120.    local string total_date$
  121.    local string our_year$
  122.    move (get_month(our_date$)) to month$
  123.    if month$ eq 1 move "January" to month_name$
  124.    if month$ eq 2 move "February" to month_name$
  125.    if month$ eq 3 move "March" to month_name$
  126.    if month$ eq 4 move "April" to month_name$
  127.    if month$ eq 5 move "May" to month_name$
  128.    if month$ eq 6 move "June" to month_name$
  129.    if month$ eq 7 move "July" to month_name$
  130.    if month$ eq 8 move "August" to month_name$
  131.    if month$ eq 9 move "September" to month_name$
  132.    if month$ eq 10 move "October" to month_name$
  133.    if month$ eq 11 move "November" to month_name$
  134.    if month$ eq 12 move "December" to month_name$
  135.    move month_name$ to total_date$
  136.    append total_date$ " " (get_day(our_date$)) ", "
  137.    move (get_year(our_date$)) to our_year$
  138.    if (length(our_year$)) lt 2 insert "0" in our_year$ at 0
  139.    if (length(our_year$)) lt 4 insert "19" in our_year$ at 0
  140.    append total_date$ our_year$
  141.    function_return total_date$   
  142.  
  143. end_function
  144.  
  145. function get_title global string our_word$ returns string
  146.    local integer lvar$
  147.    local string title_word$
  148.    local integer upper_next$
  149.    local string our_letter$
  150.    
  151.    move 1 to upper_next$
  152.    move "" to title_word$
  153.    
  154.    for lvar$ from 1 to (length(our_word$))
  155.       mid our_word$ to our_letter$ 1 lvar$
  156.       if our_letter$ eq " " begin
  157.          append title_word$ " "
  158.          move 1 to upper_next$
  159.       end
  160.       else begin
  161.          if upper_next$ eq 1 append title_word$ (uppercase(our_letter$))
  162.          else append title_word$ our_letter$
  163.          move 0 to upper_next$
  164.       end
  165.    loop
  166.    function_return title_word$
  167. end_function
  168.  
  169. function get_file_exists global string filename$ returns integer
  170.    local integer exists$
  171.    direct_input channel 9 filename$
  172.    [seqeof] move 0 to exists$
  173.    [not seqeof] move 1 to exists$
  174.    close_input channel 9
  175.    function_return exists$
  176. end_function
  177.  
  178. function get_time_difference_no_sec global integer hr1$ integer min1$ integer hr2$ integer min2$ ;
  179.                                     returns string
  180.    
  181.    function_return (get_time_no_sec(abs(hr1$ - hr2$),abs(min1$ - min2$),0))   
  182. end_function
  183.  
  184. function get_time_difference global integer hr1$ integer min1$ integer sec1$ integer hr2$ integer min2$ integer sec2$ returns string
  185.  
  186.    function_return (get_time(abs(hr1$ - hr2$),abs(min1$ - min2$),abs(sec1$ - sec2$),0))   
  187. end_function
  188.