Mastering magic xpa

50 %
50 %
Information about Mastering magic xpa
Books

Published on September 26, 2012

Author: kaissfrikha

Source: slideshare.net

  Mastering Magic xpa The authoritative book on composing service-oriented solutions

The information in this manual/document is subject to change without prior notice and does not represent a commitment on the partof Magic Software Enterprises Ltd.Magic Software Enterprises Ltd. makes no representations or warranties with respect to the contents hereof and specifically disclaimsany implied warranties of merchantability or fitness for any particular purpose.The software described in this document is furnished under a license agreement. The software may be used or copied only inaccordance with the terms and conditions of the license agreement. It is against the law to copy the software on any medium exceptas specifically allowed in the license agreement.No part of this manual and/or databases may be reproduced or transmitted in any form or by any means, electronic or mechanical,including photocopying, recording or information recording and retrieval systems, for any purpose other than the purchaser’spersonal use, without the prior express written permission of Magic Software Enterprises Ltd.All references made to third-party trademarks are for informational purposes only regarding compatibility with the products of MagicSoftware Enterprises Ltd.Unless otherwise noted, all names of companies, products, street addresses, and persons contained herein are part of a completelyfictitious scenario or scenarios and are designed solely to document the use of Magic xpa.Magic® is a registered trademark of Magic Software Enterprises Ltd.Btrieve® and Pervasive.SQL® are registered trademarks of Pervasive Software, Inc.IBM®, Topview™, iSeries™, System i™, pSeries®, xSeries®, RISC System/6000®, DB2®, and WebSphere® aretrademarks or registered trademarks of IBM Corporation.This product also includes software provided by the ICU project. ICU 1.8.1 and later (c) 1995-2003 IBM Corporation and others Allrights reserved.Microsoft®, FrontPage®, Windows™, WindowsNT™, and ActiveX™ are trademarks or registered trademarks of MicrosoftCorporation.Oracle® and OC4J® are registered trademarks of the Oracle Corporation and/or its affiliates.Linux® is a registered trademark of Linus Torvalds.UNIX® is a registered trademark of UNIX System Laboratories.GLOBEtrotter® and FLEXlm® are registered trademarks of Macrovision Corporation.Solaris™ and Sun ONE™ are trademarks of Sun Microsystems, Inc.HP-UX® is a registered trademark of the Hewlett-Packard Company.Red Hat® is a registered trademark of Red Hat, Inc.WebLogic® is a registered trademark of BEA Systems.Interstage® is a registered trademark of the Fujitsu Software Corporation.JBoss™ is a trademark of JBoss Inc.Systinet™ is a trademark of Systinet Corporation.Clip art images copyright by Presentation Task Force®, a registered trademark of New Vision Technologies Inc.This product uses the FreeImage open source image library. See http://freeimage.sourceforge.net for details.This product includes software developed by the Apache Software Foundation (http://www.apache.org/).This product includes software developed by Computing Services at Carnegie Mellon University (http://www.cmu.edu/computing/).Copyright © 1989, 1991, 1992, 2001 Carnegie Mellon University. All rights reserved.This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/).This product includes software that is Copyright © 1998, 1999, 2000 of the Thai Open Source Software Center Ltd. and Clark Cooper.This product includes software that is Copyright © 2001-2002 of Networks Associates Technology, Inc All rights reserved.This product includes software that is Copyright © 2001-2002 of Cambridge Broadband Ltd. All rights reserved.This product includes software that is Copyright © 1999-2001 of The OpenLDAP Foundation, Redwood City, California, USA. AllRights Reserved.All other product names are trademarks or registered trademarks of their respective holders.Mastering Magic xpaJune 2012Copyright © 2012 by Magic Software Enterprises Ltd. All rights reserved.

Chapter 1: Navigation and Workspace How Do I Organize the Project Objects?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 To create a folder ..............................................................................................39 To delete a folder ..............................................................................................40 To move a folder ...............................................................................................40 Moving objects into a folder using the Folder column .....................................40 Moving objects into a folder using the Move command ..................................41 How Do I Separate Palettes?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 To separate combined palettes ..........................................................................42 How Do I Locate Any Line in the Studio? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 To locate a line ..................................................................................................43 How Do I Quickly Jump to a Line Using Its Number? . . . . . . . . . . . . . . . . . . . . . 44 Jumping to a line ...............................................................................................44 How Do I Check If an Object Is Being Used and What Other Objects Use It? . . 45 Using the cross-reference..................................................................................45 How Do I Bookmark My Current Location for a Quick Return? . . . . . . . . . . . . 47 To bookmark your current location ..................................................................47 How Do I Quickly Reopen a Recently Opened Project? . . . . . . . . . . . . . . . . . . . . 48 Opening a recent project ...................................................................................48 How Do I Change the Number of Recently Opened Projects? . . . . . . . . . . . . . . . 49 Setting the number of recently opened projects................................................49 How Do I Repeat an Entry in the Studio? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Using Repeat .....................................................................................................50 How Do I Move an Entry in the Studio? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Moving an entry in the Studio...........................................................................51 How Do I Replace an Entry in the Studio with Another Entry? . . . . . . . . . . . . . . 52 Replacing an entry ............................................................................................52 How Do I Move Between the Studio Palettes?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 How Do I Keep the Property Sheet Showing a Single Section at a Time? . . . . . . 54 Changing the property sheet display.................................................................54 How Do I Easily Switch From One Project to Another? . . . . . . . . . . . . . . . . . . . . 55 Switching between projects ..............................................................................55 Adding a Module ..............................................................................................55 Deleting a Module.............................................................................................56 How Do I Navigate Between the Groups of the Property Sheet? . . . . . . . . . . . . . 57 How Do I Drill Down into a Called Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3

Chapter 2: Projects and Applications How Do I Create a New Project? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Creating a new project ......................................................................................59 How Do I Set the Icon for My Application? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Setting the icon for your application.................................................................61 How Do I Set the Caption of My Application?. . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Setting the caption for your application............................................................63 How Do I Set a Default Context Menu for the Entire Application? . . . . . . . . . . . 64 Setting the context menu for your application ..................................................64 How Do I Set or Change the Pulldown Menu for the Application? . . . . . . . . . . . 65 Setting the pulldown menu for your application...............................................65 How Do I Set the Application to Use Its Own Files for Colors, Fonts, and Keyboard Mapping? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Setting color, font, and keyboard files for the application................................66 How Do I Read and Write Files from/to the Directory of the Project? . . . . . . . . 67 How Do I Read and Write Files from/to the Magic xpa Directory? . . . . . . . . . . . 68 How Do I Read and Write Files from/to the System’s Temporary Directory? . . 69 How Do I Open an Existing Project? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Using the Open Project dialog box ...................................................................70 Using Recent Projects .......................................................................................71 Directly activating the .edp ...............................................................................71 How Do I Transfer Objects From One Project to Another? . . . . . . . . . . . . . . . . . 73 Exporting Objects .............................................................................................73 Importing Objects ............................................................................................74Chapter 3: Models How Do I Define Reusable Interface Objects? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 ...........................................................................................................................77 How Do I Define Reusable Data Objects? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Creating a field model.......................................................................................79 How Do I Define a Data Source Column Based on a Model? . . . . . . . . . . . . . . . . 81 How Do I Unify and Standardize the Project’s Data Fields and Visual Controls?82 Specifying a control for a data model ...............................................................82

How Do I Prevent an Object from Being Affected by Any Change of its Model’s Properties? 84 Manually breaking inheritance..........................................................................84 Automatically breaking inheritance ..................................................................84 How Do I Set a Broken Property to Inherit its Value? . . . . . . . . . . . . . . . . . . . . . . 85 Manually breaking inheritance..........................................................................85 How Do I Change the Class of a Model? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 How Do I Automatically Drop Form Controls Using a Specific Control Model? 87 Selecting the control and model from the palette .............................................87 How Do I Export a Program or Table While Keeping Its Models? . . . . . . . . . . . 88 Exporting with models ......................................................................................88 How Do I Share a Collection of Models with Several Projects? . . . . . . . . . . . . . . 90 Sharing models as components .........................................................................90Chapter 4: The Magic xpa Engine How Do I Define Application Level Events? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Creating a global event .....................................................................................91 How Do I Work with the Magic xpa Engine as an Event-Driven Engine?. . . . . . 93 The Concept of Events ......................................................................................93 Creating a logic unit ..........................................................................................94 How Do I Utilize the Event Hierarchy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Blocking a system event ...................................................................................95 Adding functionality to a system event.............................................................96 How Do I Prevent an Internal Event (action) like Delete Line, from Occurring? 97 Blocking an internal event ................................................................................97 How Do I Set a Dynamic Name for an Input/Output File? . . . . . . . . . . . . . . . . . 100 Setting the I/O device name ............................................................................100 How Do I Set a Dynamic Name for a Data Source? . . . . . . . . . . . . . . . . . . . . . . . 102 Renaming a data source at the task level ........................................................102 How Do I Delete a File or a Data Source in a Task that Handles the Same File or Data Source? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 How Do I Prevent the Engine from Creating an Output File or Printing an Empty Page to the Printer when the Task Eventually Does not Output Anything? . . . . . . . . . . 104 Setting IO device timing .................................................................................104 How Can I Set a New Task to Automatically Create Logic Units for the Basic Task Levels (Task and Record)? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 5

Automatically creating Task and Record Logic Units....................................105 How Can I Set a New Task to Create No Default Logic Units? . . . . . . . . . . . . . . 106 Turning off automatic creation of logic units .................................................106 How Do I Retrieve the New Value of an Edit Control While Handling Its Events?107 How Do I Prevent the End User from Modifying Any Record in a Task? . . . . . 108 Setting the data source access mode ...............................................................108 Task Properties Initial Mode...........................................................................109 Task Properties Options ..................................................................................110 Field Level Edit...............................................................................................110 How Do I Set the Engine to Execute the Record Suffix Logic Unit Even if the Record Has Not Been Updated? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Forcing record suffix to execute .....................................................................112 How Do I Prevent the End User from Changing the Task Modes?. . . . . . . . . . . 113 Preventing users from changing task modes...................................................113 How Do I Run Two Tasks Concurrently? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Setting a program to run concurrently ............................................................115 How Do I Change the Default Value of the Task Type? . . . . . . . . . . . . . . . . . . . . 116Chapter 5: Tasks How Do I Define a Program Data View? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Entering a Main Source...................................................................................118 Entering a Linked Source................................................................................119 Entering a Virtual or Parameter ......................................................................120 How Do I Create a Simple Program?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Creating “Hello world!” in Magic xpa............................................................121 Creating the Data View...................................................................................121 Creating your logic..........................................................................................122 Creating your display ......................................................................................123 Running your program ....................................................................................124 How Do I Set a Program to Return a Value to the Calling Program? . . . . . . . . 126 Creating a return value ....................................................................................126 Using a return value ........................................................................................127 How Do I Open a Data Source Using a Physical Name that is Different than the One Specified on the Data Repository? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Renaming a data source at the task level ........................................................128 How Do I Dynamically Change the Display Order of Records in a Program? . 129 Using an expression for an index....................................................................129

How Do I Create a Simple Batch Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Creating a simple batch program ....................................................................131How Do I Stop a Batch Task from Running Forever? . . . . . . . . . . . . . . . . . . . . . 132How Do I Delete a Chunk of Records from a Data Table? . . . . . . . . . . . . . . . . . 133 Creating a batch delete task ............................................................................133How Do I Create Tasks that Dump Data Records into Flat Text Files and Vice Versa?135 Dumping records to a text file.........................................................................135 Reading records from a text file......................................................................135How Do I Define Global Values that Can Be Dynamically Defined and Accessible by VariousPrograms?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Defining global variables ................................................................................137How Do I Dynamically Instruct the Task to Open a Different Form than the Main DisplayEntry? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Choosing forms at runtime..............................................................................138How Do I Synchronize Parameters Between a Called Program and Calling Program?139How Do I Prevent the End User from Adding New Records? . . . . . . . . . . . . . . . 140 Preventing the user from entering create mode ..............................................140How Do I Prevent the End User from Deleting Existing Records? . . . . . . . . . . . 141 Preventing the user from entering delete mode ..............................................141How Do I Prevent the End User from Modifying Existing Records? . . . . . . . . . 142 Preventing the user from entering modify mode ............................................142How Do I Prevent the End User from Modifying the Data in Specific Fields? . 143 Making a field non-modifiable .......................................................................143How Do I Create a Selection List Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Creating a selection list ...................................................................................144 Using a selection list .......................................................................................146How Do I Properly Validate the Data Entered by the End User? . . . . . . . . . . . . 147 Using a control verification event ...................................................................147How Do I Set the Tabbing Sequence of the Controls on the Form? . . . . . . . . . . 149 Setting the tab order ........................................................................................149 Setting the tab order for several controls at once............................................150How Do I Exit a Program from a Subtask Level? . . . . . . . . . . . . . . . . . . . . . . . . 151 Allowing an Exit event to propagate...............................................................151How Do I Save My Changes in the Task Editor While Remaining in it? . . . . . . 152 Saving changes while editing a program ........................................................152How Do I Create Logic in a Task? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Entering a Header line.....................................................................................153 7

Entering an Operation .....................................................................................153How Do I Create Operations in a Task? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 The Cnd: field .................................................................................................154How Do I Copy a Task as a Subtask?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Copying a program to become a subtask ........................................................158How Do I Make a Subtask Become the Top Level Task? . . . . . . . . . . . . . . . . . . . 159 Moving a subtask to the top level ...................................................................159How Do I Select a Column of a Table Control? . . . . . . . . . . . . . . . . . . . . . . . . . . 160How Do I Drop a Control or Variable on a Table to Create a New Column to the Left of theHighlighted Column?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161How Do I Place Several Controls in the Same Column on a Table Control? . . . 162How Do I Add New Controls to a Form?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Using the Variable Palette...............................................................................164How Do I Drop a Control Multiple Times Consecutively? . . . . . . . . . . . . . . . . . 165How Do I Select a Container Control (Like Tab or Table) Without Selecting the Controls thatare Attached to it? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166How Do I Keep the Design of a Form for Future Re-use? . . . . . . . . . . . . . . . . . . 167 Saving a form as a template ............................................................................167 Using a template form.....................................................................................167How Do I Select Several Controls at the Same Time? . . . . . . . . . . . . . . . . . . . . . 168 Selecting controls using a “rubber band”........................................................168 Selecting controls using Ctrl+Click ................................................................168How Do I Show a Table Control with Alternating Colors? . . . . . . . . . . . . . . . . . 169 Using alternating colors on a table..................................................................169How Do I Hide or Show the Table Control Dividers? . . . . . . . . . . . . . . . . . . . . . 170How Do I Make Form Controls Fit the Form when it is Resized? . . . . . . . . . . . 171How Do I Display a Control on Top of Another Control? . . . . . . . . . . . . . . . . . . 173 Viewing the Z-order........................................................................................173 Manually Using Z-order..................................................................................173 Attaching the control.......................................................................................174How Do I Jump to the Main Form of the Task? . . . . . . . . . . . . . . . . . . . . . . . . . . 175How Do I View the Tab Order of All Controls? . . . . . . . . . . . . . . . . . . . . . . . . . . 176How Do I Undo the Last Modification in the Form Editor? . . . . . . . . . . . . . . . . 177How Do I Make Some Controls Have the Same Height or Width?. . . . . . . . . . . 178How Do I Set a Property on Multiple Controls at the Same Time? . . . . . . . . . . 179

Changing properties on a group of controls....................................................179 How Do I Change the Width of a Table Control Column? . . . . . . . . . . . . . . . . . 180 How Do I Move a Table Control Column? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Moving a Table Control Column ....................................................................181 How Do I Move Between Tabs While Editing a Tab Control? . . . . . . . . . . . . . . 182 How Do I Make a Control Transparent? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Setting a transparent color...............................................................................183 How Do I Set a Default Push Button for the Form? . . . . . . . . . . . . . . . . . . . . . . . 185 Setting a Default Push Button.........................................................................185 How Do I Automatically Generate a Default Form Layout?. . . . . . . . . . . . . . . . 186 Using the Form Generator...............................................................................186 How Do I Show a Dynamic Form Title? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Using an expression in a form title .................................................................187 How Do I Set an Icon for a Form? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Choosing a form icon......................................................................................188 How Do I Set a Default Context Menu for All Controls of a Form?. . . . . . . . . . 189 Setting the default context menu for a form ...................................................189 How Do I Set a Context Menu for an Individual Control? . . . . . . . . . . . . . . . . . 190 Creating a field level context menu ................................................................190 How Do I Improve Performance When a Task is Being Called Repeatedly by a Batch Task? 191 Improving performance of batch subtasks ......................................................191 How Do I Customize the Appearance of the Verify Operation Screen? . . . . . . . 193Chapter 6: Extended Logic How Do I Send an Email? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Connecting to the server .................................................................................195 Sending the email............................................................................................196 How Do I Add an Attachment to an Email I Send? . . . . . . . . . . . . . . . . . . . . . . . 197 How Do I Receive an Email?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 A note on server types.....................................................................................198 How Do I Handle Email Attachments? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 How Do I Retrieve a Web Page or other URL Content? . . . . . . . . . . . . . . . . . . . 200 HTTPGet() ......................................................................................................200 9

How Do I Simulate a Keystroke? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 KbPut()............................................................................................................201How Do I Let the End User Mark Several Records in a Table and Handle the MarkedRecords Collection? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Preparing the table for multi marking .............................................................203 Handling marked records ................................................................................204 Other processing using MM functions............................................................204How Do I Manipulate the Menu Entries to Become Invisible, Disabled or Checked?205 The menu entry name......................................................................................205 Menu Paths......................................................................................................205 The Menu number ...........................................................................................205 MnuCheck() ....................................................................................................206 MnuEnabl() .....................................................................................................206 MnuShow() .....................................................................................................207 MnuAdd()........................................................................................................207 MnuRemove....................................................................................................208 MnuReset()......................................................................................................208 MnuName() .....................................................................................................208How Do I Call a DLL Function?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Using CallDLL................................................................................................210 Using Invoke UDP ..........................................................................................212How Do I Call a Program By Its Name? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 Calling a program by name .............................................................................213How Do I Call a Program Dynamically By Its Index? . . . . . . . . . . . . . . . . . . . . . 214 Using Call by Expression................................................................................214 Using CallProg() .............................................................................................214 Selecting the program .....................................................................................215How Do I Retrieve the Name of the Control the User Parked On? . . . . . . . . . . 216 LastPark()........................................................................................................216How Do I Retrieve the Name of the Control the User Clicked On? . . . . . . . . . . 217 LastClicked()...................................................................................................217How Do I Retrieve a Value from the System Environment Settings? . . . . . . . . . 218 OSEnvGet .......................................................................................................218How Do I Delete a Disk File? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 FileDelete() .....................................................................................................219How Do I Copy a Disk File? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 FileCopy() .......................................................................................................220How Do I Check If a File Exists on Disk? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

FileExist()........................................................................................................221 How Do I Retrieve the Content of a File Directory?. . . . . . . . . . . . . . . . . . . . . . . 222 FileListGet()....................................................................................................222 How Do I Rename a File on Disk? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 FileRename()...................................................................................................223 How Do I Get the Size of a File on Disk? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 FileInfo() .........................................................................................................224 How Do I Get the Creation Date of a File on Disk? . . . . . . . . . . . . . . . . . . . . . . . 225Chapter 7: Deployment How Do I Deploy My Project? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 How Do I Create a Cabinet File? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Creating a cabinet file .....................................................................................229 How Do I Create a Shortcut for My Application? . . . . . . . . . . . . . . . . . . . . . . . . 230 Creating a shortcut to the project file..............................................................230 Creating a shortcut to the Magic xpa engine...................................................231 Using your own icon .......................................................................................231 How Do I Make the Runtime Engine Automatically Load a Cabinet File? . . . . 232 Setting the Default Project in the Magic.Ini ...................................................232 Specifying the cabinet file in the Shortcut ......................................................233 How Do I Create an Application List Window or Open Another Application? 234Chapter 8: Subforms How Do I Make the Subform Control Fit the Dimensions of the Called Program Form?235 Setting Autofit.................................................................................................235 How Do I Manually Refresh the View of the Subform? . . . . . . . . . . . . . . . . . . . . 236 Manually refreshing a subform .......................................................................236 How Do I Refresh the Subform View Only on Modifying the Last Argument When Passing Several Arguments to the Subform? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 Using an expression on a subform automatic refresh .....................................238 How Do I Control the Visibility of a Subform When it is Placed on a Tab Control?240 Adding a subform to a tab...............................................................................240 How Do I Set the Subform to Be Tabbed Into from a Specific Control of the Parent Form? 241 11

Setting the Tab Order of a Subform Control...................................................241 How Do I Automatically Return Back to the Parent Form by Tabbing Out of the Last Control of the Subform Display? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Setting an event to exit a subform...................................................................242 How Do I Execute Task Prefix/Suffix Logic of a Subform only on Opening the Subform Task for the First Time by its Parent?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Coding a block that only executes when the subform executes for the first time243 How Do I Execute the Task Prefix/Suffix Logic of a Subform Whenever the User Enters the Subform?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Coding a block that only executes when the user enters the subform ............244 How Do I Execute Task Prefix/Suffix Logic of a Subform Whenever the Subform is Refreshed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 Coding a block that only executes when the subform is refreshed .................245 How Do I Know which Autofit Option to Use? . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 .........................................................................................................................246 How Do I Prevent the Subform from Being Refreshed If It Is Not Visible? . . . 248Chapter 9: Tree Control How Do I Display Data in a Tree-format? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 Implementing a Tree control...........................................................................250 How Do I Properly Define a Hierarchical Data Source that Will Fit a Tree Control Display? 251 How Do I Set Icons for the Tree Nodes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Using icons......................................................................................................253 How Do I Show/Hide the Expand/Collapse Buttons?. . . . . . . . . . . . . . . . . . . . . . 254 Turning on/off the expand/collapse button .....................................................254 How Do I Add a New Child Node at Runtime?. . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Creating a Child Node.....................................................................................255 How Do I Add a New Sibling Node at Runtime? . . . . . . . . . . . . . . . . . . . . . . . . . 256 Creating a Sibling Node ..................................................................................256 How Do I Explicitly ExpandCollapse Tree Nodes at Runtime? . . . . . . . . . . . . . 257 Raising an Expand or Collapse Node event....................................................257 How Do I Automatically Open the Tree with All Its Nodes or only Several Nodes Expanded? 258 Setting Auto expand to a specific node...........................................................259 Setting Auto expand to a tree level .................................................................260

How Do I Set the Tree Control to Display the Expand Button Only in the Relevant Nodes that Actually Have Child Nodes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Turning on preload..........................................................................................261 How Do I Show/Hide the Connecting Lines of the Tree Control?. . . . . . . . . . . . 262 Turning connecting lines on and off ...............................................................262 How Do I Show/Hide the Root Node as Part of the Tree Content? . . . . . . . . . . . 263 Turning show root on and off .........................................................................263 How Do I Skip to a Specific Tree Node? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Using TreeNodeGoto() ...................................................................................264 How Do I Respond to any ExpandCollapse Activity Performed on the Tree Control By the End User? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Capturing the collapse and expand events ......................................................265 How Do I Respond to the End User Movement from One Node to Another? . . 266 Capturing movement entering a node .............................................................266 Capturing movement upon leaving a node .....................................................266 How Do I Highlight the Entire Line of the Current Tree Node? . . . . . . . . . . . . . 267 Turning row highlight on and off....................................................................267Chapter 10: More on Logic How Do I Create a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 Function Scope................................................................................................270 Creating a Function.........................................................................................271 How Do I Set the Function’s Parameters?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Creating parameters for a function..................................................................272 How Do I Set the Return Value of a Function? . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 Setting a return value for a function................................................................274 How Do I Create a Function that Is Available for the Current Task Only?. . . . 275 Creating a local function .................................................................................275 How Do I Create a Function that Is Available for the Entire Project?. . . . . . . . 276 Creating a global function...............................................................................276 How Do I Share a Function Between Several Projects? . . . . . . . . . . . . . . . . . . . . 277 Creating a global function...............................................................................277 How Do I Iterate on a Series of Operations?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 LoopCounter().................................................................................................278 Creating a Block While operation...................................................................278 How Do I Update a Variable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 13

Using the Update operation.............................................................................279 How Do I Condition the Execution of an Operation Based on a Variable’s Value?281 Entering an expression for an operation .........................................................281 How Do I Retrieve the Sequential Number of a Record That is Handled by a Batch Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 Using Counter()...............................................................................................282 How Do I Condition the Logic to Be Executed Only for the First Record in an online Task? 283 Using IsFirstRecordCycle() ............................................................................283 How Do I Make the Cursor Jump to a Specific Control? . . . . . . . . . . . . . . . . . . 284 Using CtrlGoto() .............................................................................................284 How Do I Set Logic to Be Executed When the End User Enters/Leaves a Control?286 Using Control Prefix .......................................................................................286 Using Control Suffix.......................................................................................286 How Do I Condition an Operation to Be Executed Only When the End User Tabs from One Field to Another in a Certain Direction? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 How Do I Condition an Operation to be Executed Only if the End User Sequentially Tabs from One Control to another, or When the End User Skips to a Specific Control?288 Using Control Prefix .......................................................................................288 How Do I Retrieve the Newly Entered Data of an Edit Control, Rich Edit Control, and Multi Choice List Box While Remaining on the Control? . . . . . . . . . . . . . . . . . . . . . . . 289 Using EditGet() ...............................................................................................289 How Do I Identify from Which Control an Event Was Triggered? . . . . . . . . . . 290 Using HandledCtrl()........................................................................................290 How Do I Define an Event Handler to Be Executed Only When the User Is Parked on a Specific Control? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 Using the Control name property of an event .................................................291 How Do I Set Logic to Be Executed According to the Task Type in the Same Handler?292 How Do I Set Logic to Be Executed When the End User Writes Data in a Control?293 How Do I Disable an Operation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294 How Do I Dynamically Build Complex Text Messages?. . . . . . . . . . . . . . . . . . . . 295 How Do I Prevent Record Suffix from Executing After Updating a Virtual Variable?296Chapter 11: Date & Time How Do I Retrieve the Current Date? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

Date Storage ....................................................................................................297 Using Date() ....................................................................................................298How Do I Retrieve the Current Time?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Using Time() ...................................................................................................299How Do I Retrieve the Current Time Using Milliseconds Precision?. . . . . . . . . 300 Creating a timestamp using mTime()..............................................................300How Do I Increment a Date Value? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301How Do I Increment a Time Value? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302How Do I Increment the Value of Date-Time Combined Variables? . . . . . . . . . 303 Using AddDateTime().....................................................................................303 About Variable References .............................................................................304How Do I Calculate the Difference Between Two Datetime Values?. . . . . . . . . . 305 Using DifDateTime() ......................................................................................305 About Variable References .............................................................................306How Do I Calculate the Beginning of the Month of a Given Date?. . . . . . . . . . . 307 Using the BOM() function ..............................................................................307How Do I Calculate the Beginning of the Year of a Given Date? . . . . . . . . . . . . 308 Using the BOY() function...............................................................................308How Do I Calculate the End of the Month of a Given Date?. . . . . . . . . . . . . . . . 309 Using the EOM() function ..............................................................................309How Do I Calculate the End of the Year of a Given Date? . . . . . . . . . . . . . . . . . 310 Using the EOY() function ...............................................................................310How Do I Retrieve the Name of the Day of the Week of a Given Day? . . . . . . . 311 Using the CDOW() function ...........................................................................311How Do I Retrieve the Name of the Month of a Given Day?. . . . . . . . . . . . . . . . 312 Using the CMonth() function ..........................................................................312How Do I Calculate the Day/Month/Year Portion of a Given Date Value? . . . . 313How Do I Calculate the Hour/Minute/Seconds Portion of a Given Time Value?314 The Time Functions ........................................................................................314How Do I Calculate the Day of the Week of a Date, as a Number? . . . . . . . . . . 315 Using DOW() ..................................................................................................315How Do I Convert a Date Value to a String?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Date Pictures ...................................................................................................316 Using DStr()....................................................................................................317How Do I Calculate a Date Value That Is Stored In a String?. . . . . . . . . . . . . . . 318 15

Chapter 12: Handling GUI How Do I Enable the End User to Park on a Control Only by Mouse? . . . . . . . 319 Setting Tab Into...............................................................................................319 How Do I Change the Mouse Cursor Icon?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 Using the SetCrsr() function ...........................................................................321 How Do I Copy Data Within an Application by Dragging It?. . . . . . . . . . . . . . . 323 How Do I Drag Data From Magic xpa to External Applications? . . . . . . . . . . . 324 How Do I Retrieve a Full Path Name from a Dragged File? . . . . . . . . . . . . . . . . 325 How Do I Drag Data from External Applications to Magic xpa? . . . . . . . . . . . . 326 How Do I Drag Data in Table Format from Magic xpa to Excel?. . . . . . . . . . . . 328 How Do I Allow Drag and Drop Only Within Magic xpa so that External Applications Cannot Retrieve the Data? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 How Do I Display Different Text than the Stored Values in a Choice Control?. 330 How Do I Display Special Characters in a Choice Control? . . . . . . . . . . . . . . . . 332 How Do I Switch Between Choice Control Options in the Form Editor? . . . . . 333 How Do I Set Accelerators to Choice Control Options? . . . . . . . . . . . . . . . . . . . 334 How Do I Limit the Length of the Displayed Drop Down List of a Combo Box?335 How Do I Associate Controls to Different Tabs in a Tab Control? . . . . . . . . . . . 336 Showing controls on one tab...........................................................................336 Showing controls on all tabs ...........................................................................337 How Do I Associate a Task to a Specific Tab in a Tab Control? . . . . . . . . . . . . . 338 How Do I Associate Images to Different Tabs in a Tab Control? . . . . . . . . . . . . 339 How Do I Implement a Radio Button?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 Containing a radio button in one control ........................................................341 Using several controls for a radio button ........................................................342 How Do I Set the Default Option for a Choice Control? . . . . . . . . . . . . . . . . . . . 344 How Do I Dynamically Set the Option List of a Choice Control? . . . . . . . . . . . . 345 Creating a dynamic choice control..................................................................346 How Do I Implement a Choice Control Whose Data Comes From a Database Table?347 Creating a choice control tied to a database table ...........................................348 How Do I Combine Additional Options with a Data Bound Choice Control?. . 350 How Do I Implement Logic with Push Buttons?. . . . . . . . . . . . . . . . . . . . . . . . . . 351 1. Create your user event.................................................................................351 2. Put your push buttons on the form ..............................................................352

Create a logic unit to perform the desired logic when the event is raised ......353 How Do I Allow Keyboard Navigation to a Push Button?. . . . . . . . . . . . . . . . . . 354 Creating a parkable push button......................................................................354 How Do I Skip Verification Logic from Being Executed When a Push Button Is Pressed? 356 How Do I Create Image Buttons?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Creating an image button ................................................................................358 How Do I Combine Image and Text on a Button? . . . . . . . . . . . . . . . . . . . . . . . . 359 Specifying a Text on image button .................................................................359 How Do I Specify the Text on a Parkable Push Button? . . . . . . . . . . . . . . . . . . . 360 Using an Init to specify push button text ........................................................360 Using a default value to specify push button text ...........................................361 Using the picture to specify push button text..................................................361 How Do I Set Up One Push Button to Affect Either the Subform or its Parent Task?363 Using the Task in focus property ....................................................................364 How Do I Set Accelerators to Push Buttons? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 Setting an accelerator to a push button ...........................................................365 How Do I Dynamically Create Rich Formatted Text? . . . . . . . . . . . . . . . . . . . . . 366 How Do I Retrieve Data from a Multiple Selection List Box?. . . . . . . . . . . . . . . 368 Using a Multiple Selection List box ...............................................................369 How Do I Execute Some Logic After a User Clicked on a Column?. . . . . . . . . . 371 How Do I Use Word Wrapping in the Column Header? . . . . . . . . . . . . . . . . . . . 372 How Do I Define a Gradient Color Effect? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 How Do I Define a Hot Track Effect for Push Buttons? . . . . . . . . . . . . . . . . . . . 374 How Do I Set the Status Bar Text? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 How Do I Dynamically Define the Tab Order and Visibility for a Tab Control?376Chapter 13: XML How Do I Create an XML Doc from Scratch? . . . . . . . . . . . . . . . . . . . . . . . . . . . 379 Initializing an XML Document.......................................................................380 How Do I Find an XML Schema? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 The XML Schema ...........................................................................................381 How Do I Create an XML View? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 Creating an XML View...................................................................................383 17

Creating several XML Views .........................................................................384How Do I Update the NodeId and ParentId? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386How Do I Access a Certain Compound in an XML File? . . . . . . . . . . . . . . . . . . 387 Repeating elements .........................................................................................387 Selecting one compound .................................................................................387How Do I Modify an Existing XML Document?. . . . . . . . . . . . . . . . . . . . . . . . . . 389 Accessing a parent record ...............................................................................389 Accessing a child record .................................................................................390How Do I Determine the Magic xpa Data Types Corresponding to XML Data Types?392 Viewing the schema setting ............................................................................393How Do I Retrieve Data from an XML Doc in a Preferred Order? . . . . . . . . . . 394 Creating an alternate index for an XML view ................................................394How Do I Handle Multi-Occurrence Elements in an XML Doc? . . . . . . . . . . . . 395 Displaying repeatable elements ......................................................................395How Do I Allow Different Users Access to the Same XML Document? . . . . . . . 397 Setting the access mode for an XML document .............................................397How Do I Create Different XML Docs Based on the Same Schema? . . . . . . . . . 398How Do I Access an XML Document Stored in a Magic xpa Data Variable? . . 399 Using a BLOB as a data source ......................................................................399 Using a BLOB as an I/O device......................................................................400How Do I Validate an XML Document? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 Using XMLValidate() .....................................................................................401 XMLValidate() syntax ....................................................................................401How Do I Retrieve Validation Errors of an XML Document? . . . . . . . . . . . . . . 403How Do I Handle Errors Encountered During XML Access?. . . . . . . . . . . . . . . 404 Creating a global error handler .......................................................................404How Do I Determine the Encoding for an XML Document? . . . . . . . . . . . . . . . 405 Using XMLGetEncoding() .............................................................................405How Do I Handle XML Data that is Base64 Encoded? . . . . . . . . . . . . . . . . . . . . 406How Do I Pass an XML Document as a Parameter? . . . . . . . . . . . . . . . . . . . . . . 407How Do I Handle an XML Document with No Schema? . . . . . . . . . . . . . . . . . . . 408How Do I Retrieve / Update /Insert Data According to a Certain Path in an XML Document?409 Retrieving XML Data .....................................................................................409 Updating XML Data .......................................................................................409 Inserting XML Data ........................................................................................410

Deleting XML Data ........................................................................................410 How Do I Uniquely Identify a Data Element and Its Hierarchy Within an XML Document? 411 How Do I Handle Mixed-Content in an XML Document? . . . . . . . . . . . . . . . . . 413Chapter 14: COM How Do I Define the COM Object that I Want to Use? . . . . . . . . . . . . . . . . . . . . 415 Defining a COM object...................................................................................416 How Do I Enable Event Handling for a COM Object While in a Descendant Task?418 How Do I Call a COM Object Method? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419 Calling a COM Method...................................................................................419 How Do I Set or Get a Property of a COM Object? . . . . . . . . . . . . . . . . . . . . . . . 421 Using Get and Set Property with a COM Object ............................................421 How Do I Change a Reference to a Certain COM Object? . . . . . . . . . . . . . . . . . 423 Changing a COM Library Reference ..............................................................423 How Do I Set a Value of an Enumerated Type Parameter of a COM Object? . 425 How Do I Extract/Set Data From/To a Variant Type of a COM Object?. . . . . . 426 Creating a Variant with VariantCreate() .........................................................427 Extracting data from a Variant using VariantGet().........................................428 Variant Data Attributes ...................................................................................429 Variant Data Types .........................................................................................429 How Do I Determine the Type and Corresponding Magic xpa Attribute of a Variant Value Belonging to a COM Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 Extracting the attribute type using VariantAttr() ............................................431 Extracting the data type using VariantType() .................................................432 How Do I Send and Retrieve Array Values from COM Objects? . . . . . . . . . . . . 433 Passing an array to a COM object...................................................................434 Fetching a Collection ......................................................................................437 How Do I Pass/Receive a COM Object as a Parameter To/From a COM Object?439 Receiving a COM Object ................................................................................439 How Do I Re-use COM Object Definitions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440 How Do I Keep an Instance of a COM Object Available Across Programs?. . . 441 Defining a COM object in the Main Program.................................................441 How Do I Handle an Error Triggered by a COM Object? . . . . . . . . . . . . . . . . . 442 .........................................................................................................................442 19

How Do I Expose Magic xpa Logic as COM Methods? . . . . . . . . . . . . . . . . . . . . 443 Creating a COM interface ...............................................................................443 How Do I Set a Class ID When Exposing Magic xpa Logic as a COM Server? 445 How Do I Configure a COM Client Locally Accessing Magic xpa as a COM Server?446 How Do I Determine the COM Data Types When Exposing Magic xpa Logic as COM Methods?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 Viewing and Changing Method Argument Details.........................................447Chapter 15: Components How Do I Reuse Magic xpa Objects Across Projects? . . . . . . . . . . . . . . . . . . . . . 449 Creating a Magic xpa Component ..................................................................449 How Do I Determine Which Data is Used by Your Component Builder? . . . . . 455 How Do I Load a Component Into My Project? . . . . . . . . . . . . . . . . . . . . . . . . . . 456 Using a Magic xpa Component.......................................................................456 How Do I Implement Changes Done in Existing Component, Into a Host Application Using This Component? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 Changing a runtime component ......................................................................458 Changing a component in the Studio ................................

Add a comment

Related presentations

Related pages

Learning Offering | Magic - Magic | Outperform The Future

Book: “Mastering Magic xpa" Mastering Magic xpa is a comprehensive collection of questions and answers, comprising over 1,000 pages in two volumes.
Read more

Magic xpa Single User Edition: Frequently Asked Questions ...

Magic xpa Single User Edition is used to build and deploy full client, rich Internet applications (RIA), mobile applications, and software-as-a-service ...
Read more

www.magicsoftware.co.jp

www.magicsoftware.co.jp
Read more

Kursangebot | Magic

Magic xpa Kursangebot; Magic xpi Kursangebot; ... Book “Mastering uniPaaS" Mastering uniPaaS is a comprehensive collection of questions and answers,
Read more

www.MagicProgrammers.com | Find a magic programmer | Magic ...

Directory of resources for Magic : independent programmers, consultants, links.
Read more

Learning Offering | Magic

Mastering uniPaaS is a ... Our Application Platform formerly called uniPaaS was rebranded as Magic xpa ... Magic University Learning Offering.
Read more

Magic xpaスキルアップセンター - ホーム ...

Mastering Magic xpa.pdf. Getting Started for RIA Magic xpa; 本書は、Magic xpa を始めて利用される方を対象に、リッチ ...
Read more

Off the Hook: Introducing Offline Programs | The Magic ...

With the release of Magic xpa 2.4, Magic xpa RIA applications have offline capabilities in addition to online ... Off the Hook: Introducing Offline Programs.
Read more

Magic Request Broker (MRB) xpa

Magic Request Broker (MRB) Magic xpa provides a middleware agent known as the Magic Request Broker. The Magic Request Broker, also referred to as the ...
Read more

Reason #11: Magic xpa Provides Better .NET Handling than ...

20 Reasons to Migrate Magic eDeveloper, uniPaaS and Magic xpa to .NET by Upgrading Rather than Converting
Read more