1 / 27

Tips, Tricks and Toolkits

Tips, Tricks and Toolkits. Ian Cargill Development Manager Dendrite Clinical Systems. Terminal Window Tricks. ! To run an OS Shell command Do ##class(%SQL.Shell).%Go() or Do $System.SQL.Shell() q(uit) to exit back to terminal User defined Function Keys. Error Handling.

tana
Download Presentation

Tips, Tricks and Toolkits

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tips, Tricks and Toolkits Ian Cargill Development Manager Dendrite Clinical Systems

  2. Terminal Window Tricks • ! To run an OS Shell command • Do ##class(%SQL.Shell).%Go() or • Do $System.SQL.Shell() • q(uit) to exit back to terminal • User defined Function Keys

  3. Error Handling • “Old” style - $ZTrap • I still prefer this • Try / Catch / Return • Would prefer, but not until Return available • Return - Available in Caché 2013.1

  4. Error Handling try { set res="ok" } catch { set res="fail" } Quit Res // oh dear!!!!!

  5. Error HandlingCaché 2013 - RETURN try { return ok" ;; Yippeee !!!! } catch { return "fail" }

  6. SOAP debugging Set ^ISCSOAP("LogFile")="c:\temp\log.txt" Set ^ISCSOAP("Log")="oi" Set ^ISCSOAP("Log")=""

  7. Making use of @

  8. Snippets • Caché 2012 - just the one • Caché 2013 - three, • user definable, redistributable • Ctrl-5

  9. Using Unique Indexes • Normally work with classes using the ID or IdKey field: • ##class(My.Class).%ExistsId(idval) • ##class(My.Class).%OpenId(idval) • ##class(My.Class).%DeleteId(idval) • Not well known, you can actually test / open / delete objects based on a unique index.

  10. Using Unique Indexes • E.g. if a class contains: Index IxNHSNumber On NHSNumber [unique] • You can use: • ##class(My.Class). IxNHSNumberExists(NhsNum) • ##class(My.Class). IxNHSNumberOpen(NhsNum) • ##class(My.Class). IxNHSNumberDelete(NhsNum) • indexnameCheck() ?????????

  11. Useful (Windows) Shortcuts • Start Studio and automatically connect to namespace MYTEST, using user account Fred (password is xxxx). • Shortcut with Target: C:\CacheSys\Bin\CStudio.exe /fastconnect=127.0.0.1[1972]:MYTEST: Fred:xxxx • Similar for other Caché utility tools

  12. Useful Intrinsic Functions: Listblocks • $LISTFROMSTRING • $LISTTOSTRING • $LISTSAME • $LISTVALID • $LISTDATA • $LISTNEXT

  13. Config Package • In %SYS. Not % package, so can only use it in %SYS • Large number of classes for automating tasks that you would normally do via Portal. • http://localhost:57772/csp/documatic/%25CSP.Documatic.cls

  14. ObjectScript Highlights Ian Cargill Development Manager Dendrite Clinical Systems

  15. Using Unique Indexes • Normally work with classes using the ID or IdKey field: • ##class(My.Class).%ExistsId(idval) • ##class(My.Class).%OpenId(idval) • ##class(My.Class).%DeleteId(idval) • Not well known, you can actually test / open / delete objects based on a unique index.

  16. Using Unique Indexes • E.g. if a class contains: Index IxNHSNumber On NHSNumber [unique] • You can use: • ##class(My.Class). IxNHSNumberExists(NhsNum,.id) • ##class(My.Class). IxNHSNumberOpen(NhsNum,.sc) • ##class(My.Class). IxNHSNumberDelete(NhsNum) • ##class(My.Class). IxNHSNumberCheck(NhsNum) ?? • %Library.CacheIndex documents these!

  17. Runtime Class Access $CLASSMETHOD $METHOD $PROPERTY $CLASSNAME

  18. Syntax Set oDat=$CLASSMETHOD(Class, "%New") Set oDat=$CLASSMETHOD(Class, "%OpenId", ObjId) Set CurrentVal=$PROPERTY(oDat, FldName) Set $PROPERTY(oDat, FldName)=NewValue

  19. Useful Intrinsic Functions • $INCREMENT - DIY locks +1, -1 • Set x=$I(x) Set x=$I(x,-1) • $CASE • Set x=$Case(val,1:"red",2:"blue",:"green") • $ZSTRIP • Set str=$ZStrip(str, "<>W") • Set str=$ZStrip(str, "*P", "; ", "Z")

  20. Useful Intrinsic Functions • $ZCONVERT • $ZCVT(str, "U") - to uppercase • $ZCVT(str, "L") - to lowercase • $ZCVT(str, "O","HTML ") • $ZCVT(str, "O", "JS") • $ZCVT(str, "O","URL")

  21. Useful Intrinsic Functions: Listblocks • $LISTFROMSTRING • $LISTTOSTRING • $LISTSAME • $LISTVALID • $LISTDATA • $LISTNEXT

  22. Bulk loading data • $SORTBEGIN • $SORTEND • Use these to inhibit indexing while bulk loading data. • Do all indexing in one hit.

  23. Error Handling • “Old” style - $ZTrap • I still prefer this • Try / Catch / Return • Would prefer, but not until Return available • Return - coming, but not yet !!

  24. Error Handling try { set res="ok" } catch { set res="fail" } Quit Res // oh dear!!!!!

  25. Class Storage • You can control class storage • View | Storage in Studio • Default like • ^Test.PersonD ^Test.PersonI • I prefer • ^MYDB("Test","Person","D") • ^MYDB("Test","Person","I")

  26. %SYSTEM.Encryption • This class provides class functions to perform data encryption, Base64 encoding, hashing, and generation of message authentication codes. • Some complex encryption support for experts, but a number of useful applications for the more humble programmer:

  27. %SYSTEM.Encryption • Encrypting passwords for storage • e.g. MD5Hash, SHA1Hash • Encoding binary data for 'plain text' transmission. E.g. SOAP messages. • Base64Encode • Base64Decode

More Related