Writing Your First U2 Application
Total Page:16
File Type:pdf, Size:1020Kb
Writing your first Rocket U2 Application Brian Leach Writing Your First UniVerse or UniData Application Brian Leach About this Book The book is available in published form or as a free download in PDF format from Brian Leach (www.brianleach.co.uk). You may distribute it freely. About the Author Brian Leach is an independent U2 and MultiValue consultant based in the UK. Brian has worked with UniVerse since 1989 and has designed some of the most advanced development and reporting tools in the U2 market. Brian is a past President of the International U2 User Group, of which he was a founder board member. You can contact the author at www.brianleach.co.uk. Table of Contents About this Book ....................................................................................................................... 4 About the Author ............................................................................................................. 4 Acknowledgements .......................................................................................................... 8 Thank You ......................................................................................................................... 8 Introduction ............................................................................................................................. 9 UniVerse or UniData?..................................................................................................... 10 What we will cover ......................................................................................................... 10 Who Should Read This Guide ......................................................................................... 11 Getting Up and Running .................................................................................................... 12 Installing the Demonstration Database ......................................................................... 13 Installing Visual Studio ................................................................................................... 14 Exploring the Demonstration Database ................................................................................ 15 Starting from the Top - Account Structure .................................................................... 17 Moving between Accounts ............................................................................................ 19 Starting your Application ....................................................................................................... 20 Introducing the U2 Object model ...................................................................................... 21 Starting an Application ................................................................................................... 22 Adding the Namespace .................................................................................................. 24 Creating the Connection ................................................................................................ 26 Data and Files..................................................................................................................... 31 Listing the Files in your Account .................................................................................... 31 The Demonstration Files ................................................................................................ 32 Listing File Content ............................................................................................................ 33 Records and Keys ........................................................................................................... 34 Files and Dictionaries ......................................................................................................... 35 Listing a File Dictionary................................................................................................... 36 Listing Fields ................................................................................................................... 37 Virtual Fields ...................................................................................................................... 38 Related Fields ................................................................................................................. 40 Running Commands ........................................................................................................... 41 Creating the Book Titles Form ........................................................................................... 45 Reading and Writing Records ......................................................................................... 47 Opening a File ................................................................................................................. 48 Reading a Record ............................................................................................................ 48 Dynamic Arrays .................................................................................................................. 49 Triggering a Read Event .................................................................................................. 51 Locking Records .............................................................................................................. 52 Writing Changes ............................................................................................................. 54 Adding New Records ...................................................................................................... 55 XML Listings and Browsing ................................................................................................. 55 The UniXML Class ........................................................................................................... 56 Selecting from the Grid .................................................................................................. 58 MultiValued Data ............................................................................................................... 58 Inside the Record Structure ........................................................................................... 60 MultiValued Keys ........................................................................................................... 61 Reading Multiple Records .................................................................................................. 61 Part 2 - Server Coding ............................................................................................................ 65 Server Side Programming ............................................................................................... 65 Creating and Running Programs..................................................................................... 66 Your First Server Program .............................................................................................. 67 Compiling your Program ................................................................................................ 68 Running your Program ................................................................................................... 70 Examining the Syntax ..................................................................................................... 70 Reading Data ...................................................................................................................... 71 Using Dynamic Arrays ........................................................................................................ 73 Using Constants ................................................................................................................. 75 Creating a Subroutine ........................................................................................................ 76 Calling a Subroutine from the Server ................................................................................ 79 Calling Subroutines from the Client ...................................................................................... 81 Server-side updates ........................................................................................................... 85 Server Side Validation ........................................................................................................ 87 Calling Internal Subroutines .............................................................................................. 88 Adding Locking ................................................................................................................... 90 Variable Scope and Persistence ......................................................................................... 92 Creating a Common Block .............................................................................................. 93 Placing File Variables in Common .................................................................................. 94 Conclusion.......................................................................................................................... 96 From the Author ................................................................................................................ 97 Acknowledgements UniVerse, UniData and UniObjects are registered trademarks of Rocket U2. UNIX is a registered trademark in the United States of America and other countries, licensed exclusively through X/Open Company Ltd. Microsoft, Windows, Windows