50 things you may not know you can do with the 4gl
play

50 Things You May Not Know You Can Do With The 4GL Gus Bjrklund. - PowerPoint PPT Presentation

50 Things You May Not Know You Can Do With The 4GL Gus Bjrklund. Progress. PUG Challenge Americas Westford, MA June 5 to 8, 2011 50 Things 1 Agenda A smrgsbord of large and small topics Having nothing to do with each other


  1. 50 Things You May Not Know You Can Do With The 4GL Gus Björklund. Progress. PUG Challenge Americas Westford, MA June 5 to 8, 2011 50 Things 1

  2. Agenda • A smörgåsbord of large and small topics • Having nothing to do with each other • In no particular order 50 Things 2

  3. Credit • I didn't think all this up myself. – Greg Higgins, – Dmitri Levin, – Dustin Grau, – Tom Bascom, – Dan Foreman, • and others came up with some of these 50 Things 3

  4. Call a dynamic shared library function (Windows .DLL or UNIX/Linux .so) 50 Things 4

  5. Shared library call example define variable x as integer no-undo. procedure putenv external "/lib64/libc.so.6": define input parameter env as character. define return parameter x as long. end. run putenv( "XYZZY=pflugh", output x ). display os-getenv( "XYZZY" ). os-command value( 'echo "$XYZZY"' ). return. This code was gratuitously stolen from Tom Bascom. He has lots more. 50 Things 5

  6. Get Process Identifiers 50 Things 6

  7. Using input through define variable pid as character no-undo. input through "echo $PPID". import pid. input close. 50 Things 7

  8. Using UNIX/Linux C library call procedure getpid external "/usr/lib/glibc.so" cdecl: define return parameter pid as long no-undo. end procedure. /* then to use it: */ def var p as integer no-undo. p = getpid (). 50 Things 8

  9. Using Windows kernel library call procedure GetCurrentProcessId external "kernel32.dll": define return parameter pid as long. end procedure. def var p as integer no-undo. run GetCurrentProcessId (output p). 50 Things 9

  10. Using Database VST def var p as integer no-undo. find first _myconnection no-lock. p = _myconnection._myconn-pid. 50 Things 10

  11. Time Management 50 Things 11

  12. Date/Time related stuff • Data types – DATE – DATETIME – DATETIME-TZ – INT64 • Session attributes – SESSION:TIMEZONE – SESSION:DISPLAY-TIMEZONE 50 Things 12

  13. Date/Time related stuff • "constructor" functions d = date (2011, 6, 7) dt = datetime (2011, 6, 7, 11, 15, 0, 0) dtz = datetime-tz (2011, 6, 7, 11, 15, 0, -240) 50 Things 13

  14. ABL Calendar • Based on Gregorian Calendar • Epoch Date 1 January – 4713 at 00:00:00 • Units DATE datatype: days DATETIME: milliseconds DATETIME-TZ: milliseconds 50 Things 14

  15. Different Calendars • UNIX time – epoch is Jan 1, 1970 at 00:00:00 – unit is seconds • JMS time – epoch is Jan 1, 1970 at 00:00:00 – unit is milliseconds • Windows time – epoch is Jan 1, 1601 at 00:00:00 – unit is centinanoseconds (100 nanoseconds) aka "ticks" 50 Things 15

  16. Useful Time Constants Number Description 116 444 736 000 000 000 ticks from 1/1/1601 to 1/1/1970 11 644 473 600 000 milliseconds from 1/1/1601 to 1/1/1970 2 305 814 days from 1/1/- 4713 to 1/1/1601 2 440 588 days from 1/1/- 4713 to 1/1/1970 134 774 days from 1/1/1601 to 1/1/1970 210 866 889 600 seconds from 1/1/- 4713 to 1/1/1970 3 600 seconds in 1 hour 86 400 seconds in 1 day 31 536 000 seconds in 365 days 50 Things 16

  17. Time arithmetic is easy with datetime and datetime-tz data types arithmetic units is milliseconds def var startTime as datetime. def var endTime as datetime. def var i as int64. i = endTime - startTime. endTime = startTime + i. 50 Things 17

  18. Arithmetic in other units def var startTime as datetime. def var endTime as datetime. def var nSecs as int64. def var nDays as int64. nSecs = (endTime – startTime) / 1000. nDays = (endTime – startTime) / 86400000. /* but this is too hard !!! */ 50 Things 18

  19. INTERVAL: A useful function i = INTERVAL (endTime, startTime, units). startTime, endTime are expressions of type DATE, DATETIME, or DATETIME-TZ units is a character expression evaluating to one of "years", "months", "weeks", "days", "hours", "minutes", "milliseconds" 50 Things 19

  20. Changing Times From Windows to DATETIME: 0. convert from ticks to milliseconds 1. adjust for epoch difference def var wintime as int64 no-undo. def var dt as datetime no-undo. wintime = wintime / 10000. dt = add-interval (datetime (1, 1, 1601, 0, 0, 0, 0), wintime, "milliseconds"). 50 Things 20

  21. Changing Times From DATETIME-TZ to UNIX: 0) adjust for epoch difference in seconds def var dt as datetime-tz no-undo. def var unixTime as int64 no-undo. unixTime = interval (dt, DATETIME-TZ (1, 1, 1970, 0, 0, 0, 0, 0), "seconds"). 50 Things 21

  22. Time Zones DATETIME-TZ data type milliseconds from epoch stored as GMT with originating session time zone offset (in minutes) def var tzoffset as int no-undo. tzoffset = timezone (dt-tz expression). gives you the timezone offset dtz = datetime-tz (dtz, tzoffset) to change a timezone offset 50 Things 22

  23. Time Zones DATETIME-TZ: database indexing ignores timezone arithmetic ignores timezone comparison operators (>, <, >=, <=, =, <>) ignore timezone 50 Things 23

  24. Time Zones SESSION:DISPLAY-TIMEZONE integer timezone offset used for formatting initialized to ? when ? then SESSION:TIMEZONE is used instead. 50 Things 24

  25. Time Zones SESSION:TIMEZONE integer session timezone offset initialized to ? set with timezone function: SESSION:TIMEZONE = TIMEZONE. 50 Things 25

  26. Some other things 50 Things 26

  27. Import data thruough stdin, stdout On UNIX and Linux: cat cdata.txt | pro -b -p import.p | cat On Windows: type cdata.txt | pro -b -p import.p | more the program imp.p: def var c as char no-undo. import cv. put unformatted string (c). 50 Things 27

  28. How many BI clusters exist? find _AreaStatus where _AreaStatus-Areanum = 3. find _dbStatus display _AreaStatus-Hiwater * _dbStatus._DbStatus-BiBlkSize / _dbStatus-BiClSize / 1024 . Can’t tell how many are active though 50 Things 28

  29. To get formatted data into Excel Excel can load HTML Create an HTML table text file Use one HTML table record per table row One cell per field 50 Things 29

  30. Sample: ¡ <table ¡border=0 ¡cellpadding=0 ¡cellspacing=0 ¡width=1034> ¡ ¡<col ¡width=146> ¡ ¡<col ¡width=185> ¡ ¡<col ¡width=159> ¡ ¡<col ¡width=181> ¡ ¡<tr ¡height=13> ¡ ¡ ¡<td>Marv ¡Stone</td> ¡ ¡ ¡<td>Systems ¡Engineering</td> ¡ ¡ ¡<td>Progress ¡Software</td> ¡ ¡ ¡<td>marv@example.com</td> ¡ ¡</tr> ¡ </table> ¡ 50 Things 30

  31. Sample: ¡ <table ¡border=0 ¡cellpadding=0 ¡cellspacing=0 ¡width=1034> ¡ ¡<col ¡width=146> ¡ ¡<col ¡width=185> ¡ ¡<col ¡width=159> ¡ ¡<col ¡width=181> ¡ ¡<tr ¡height=13> ¡ ¡ ¡<td>Marv ¡Stone</td> ¡ ¡ ¡<td>Systems ¡Engineering</td> ¡ ¡ ¡<td>Progress ¡Software</td> ¡ ¡ ¡<td>marv@example.com</td> ¡ ¡</tr> ¡ </table> ¡ 50 Things 31

  32. How much space is used? for ¡each ¡_AreaStatus ¡where ¡ ¡ ¡ ¡ ¡( ¡not ¡_AreaStatus-­‑Areaname ¡matches ¡"*After ¡Image ¡Area*" ¡) ¡ ¡ ¡ ¡no-­‑lock: ¡ ¡display ¡ ¡ ¡ ¡_AreaStatus-­‑Areanum ¡ ¡format ¡">>>" ¡column-­‑label ¡"Num" ¡ ¡ ¡_AreaStatus-­‑Areaname ¡format ¡"x(20)" ¡column-­‑label ¡"Area ¡Name" ¡ ¡ ¡_AreaStatus-­‑Totblocks ¡column-­‑label ¡"Tot ¡blocks" ¡ ¡ ¡_AreaStatus-­‑Hiwater ¡column-­‑label ¡"High ¡water ¡mark" ¡ ¡ ¡_AreaStatus-­‑Hiwater ¡/ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡_AreaStatus-­‑Totblocks ¡* ¡100 ¡column-­‑label ¡"% ¡use" ¡ ¡ ¡_AreaStatus-­‑Extents ¡ ¡format ¡">>>" ¡column-­‑label ¡"Num ¡Extents" ¡ ¡ ¡_AreaStatus-­‑Freenum ¡column-­‑label ¡"Free ¡num" ¡ ¡ ¡_AreaStatus-­‑Rmnum ¡ ¡ ¡column-­‑label ¡"RM ¡num" ¡ ¡ ¡. ¡ end. ¡ 50 Things 32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend