SlideShare a Scribd company logo
Mastering IDEAScript with Website The Definitive
Guide 1st Edition Idea download
https://ebookgate.com/product/mastering-ideascript-with-website-
the-definitive-guide-1st-edition-idea/
Get Instant Ebook Downloads – Browse at https://ebookgate.com
Get Your Digital Files Instantly: PDF, ePub, MOBI and More
Quick Digital Downloads: PDF, ePub, MOBI and Other Formats
AppleScript The Definitive Guide Definitive Guides 1st
Edition Matt Neuburg
https://ebookgate.com/product/applescript-the-definitive-guide-
definitive-guides-1st-edition-matt-neuburg/
The Leading Edge Manager s Guide to Success with
Website Strategies and Better Practices 1st Edition
Parmenter
https://ebookgate.com/product/the-leading-edge-manager-s-guide-
to-success-with-website-strategies-and-better-practices-1st-
edition-parmenter/
Closure The Definitive Guide 1st Edition Michael Bolin
https://ebookgate.com/product/closure-the-definitive-guide-1st-
edition-michael-bolin/
Hadoop the definitive guide 1st Edition Tom White
https://ebookgate.com/product/hadoop-the-definitive-guide-1st-
edition-tom-white/
Cassandra The Definitive Guide 1st Edition Eben Hewitt
https://ebookgate.com/product/cassandra-the-definitive-guide-1st-
edition-eben-hewitt/
DocBook 5 The Definitive Guide Walsh Norman
https://ebookgate.com/product/docbook-5-the-definitive-guide-
walsh-norman/
Dojo The Definitive Guide 1st Edition Matthew A.
Russell
https://ebookgate.com/product/dojo-the-definitive-guide-1st-
edition-matthew-a-russell/
SharePoint 2007 The Definitive Guide 1st Edition James
Pyles
https://ebookgate.com/product/sharepoint-2007-the-definitive-
guide-1st-edition-james-pyles/
Postfix The Definitive Guide 1st Edition Kyle D. Dent
https://ebookgate.com/product/postfix-the-definitive-guide-1st-
edition-kyle-d-dent/
Mastering IDEAScript with Website The Definitive Guide 1st Edition Idea
Chapter = Date: Feb 18, 2011 Time: 11:49 am
Chapter = Date: Feb 24, 2011 Time: 12:45 pm
Mastering IDEAScript
Chapter = Date: Feb 24, 2011 Time: 12:45 pm
Chapter = Date: Feb 24, 2011 Time: 12:45 pm
Mastering IDEAScript
The Definitive Guide
JOHN PAUL MUELLER
John Wiley & Sons, Inc.
Chapter = Date: Feb 24, 2011 Time: 12:45 pm
Copyright © 2011 by CaseWare IDEA Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as
permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior
written permission of the Publisher, or authorization through payment of the appropriate per-copy fee
to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax
(978) 646-8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should
be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ
07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in
preparing this book, they make no representations or warranties with respect to the accuracy or
completeness of the contents of this book and specifically disclaim any implied warranties of
merchantability or fitness for a particular purpose. No warranty may be created or extended by sales
representatives or written sales materials. The advice and strategies contained herein may not be
suitable for your situation. You should consult with a professional where appropriate. Neither the
publisher nor author shall be liable for any loss of profit or any other commercial damages, including
but not limited to special, incidental, consequential, or other damages.
IDEA® is a registered trademark of CaseWare International Inc.
For general information on our other products and services or for technical support, please contact our
Customer Care Department within the United States at (800) 762-2974, outside the United States at
(317) 572-3993, or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print
may not be available in electronic books. For more information about Wiley products, visit our Web
site at www.wiley.com.
Library of Congress Cataloging-in-Publication Data:
Mueller, John, 1958-
Mastering IDEAScript: the definitive guide/John Paul Mueller.
p. cm.
Includes index.
ISBN 978-1-118-00448-7 (pbk.); 978-1-118-01783-8 (ebk); 978-1-118-01784-5 (ebk);
978-1-118-01785-2 (ebk)
1. Auditing–Data processing. 2. Accounting–Data processing. 3. Scripting languages
(Computer science) 4. Data structures (Computer science) I. Title.
HF5667.12.M37 2011
657.028553–dc22
2010045246
Printed in the United States of America.
10 9 8 7 6 5 4 3 2 1
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
Contents
Preface xi
Acknowledgments xvii
CHAPTER 1 Introducing IDEAScript 1
Understanding Automation 1
Understanding How You Use Macros 3
Having Things Your Way 6
Considering Your Skills 7
Summary 8
CHAPTER 2 Creating Your First IDEAScript Application 9
Understanding the Macro Types 9
Opening the Visual Script Editor 11
Writing a Hello World Application 15
Building Your Application 19
Summary 20
CHAPTER 3 Understanding the Basics of the IDEAScript Editor 21
Working with Windows 21
Hiding and Viewing Windows 27
Working with Menus and Toolbars 29
Summary 37
CHAPTER 4 Designing Structured Applications 39
Understanding the Parts of an Application 40
Understanding the Methods Used to Create an Application 41
Using the Macro Recorder 45
Working with Subroutines and Functions 52
v
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
vi Contents
Making Your Code Easy to Read 56
Adding Your Application to a Toolbar or Menu 57
Summary 60
CHAPTER 5 Working with Data 63
Understanding Variables and Constants 63
Choosing a Data Type 67
Employing Operators 82
Formatting Data 85
Creating Custom Data Types 89
Summary 91
CHAPTER 6 Using Conditional Statements and Loops 93
Making Decisions Using the If . . . Then . . . Else Statement 93
Choosing between Options Using Select Case 95
Performing Tasks a Specific Number of Times with For . . . Next 99
Performing Tasks Using Conditions with Do Loop 102
Adding Error Trapping to Your Application 106
Redirecting Macro Flow Using GoTo 112
Summary 112
CHAPTER 7 Understanding IDEA Databases 115
Considering the Parts of a Database 115
Introducing the IDEA Database System 118
Opening a Database for Use 119
Checking the Database History 120
Obtaining Field Statistics 122
Setting Database Criteria 125
Indexing a Database 125
Sorting a Database 127
Modifying Database Comments 129
Committing the Database 131
Closing a Database 133
Summary 133
CHAPTER 8 Working with Databases 135
Adding One Database to Another Using Append Database 135
Comparing Two Databases Using CompareDB 138
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
Contents vii
Working with Keys 140
Exporting a Database Using ExportDatabase 145
Working with Fields Using Field 150
Working with Records 152
Working with Tables 157
Summary 164
CHAPTER 9 Considering the CaseWare IDEA Object Model 165
Considering the IDEA Object Model 165
Working with the Task Object Model 170
Summary 193
CHAPTER 10 Performing Mathematical Tasks 195
Performing Basic Math 195
Using Advanced Math 198
Employing Analysis 200
Summary 205
CHAPTER 11 Interacting with Arrays 207
Understanding How Arrays Work 207
Creating and Using Arrays 208
Copying Data between Arrays 212
Summary 213
CHAPTER 12 Creating Interactive Dialog Boxes 215
Creating Great Dialog Boxes 216
Using the Basic Controls 218
Obtaining the Visual Appearance You Want 232
Interacting with Dialog Boxes Using Code 235
Adding Pictures to Your Dialog Boxes 244
Summary 247
CHAPTER 13 Locating Information in Databases 249
Performing Searches Efficiently 249
Using the Built-in Search Features 251
Creating a Custom Search 268
Summary 269
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
viii Contents
CHAPTER 14 Importing and Exporting Data 271
Considering the Import and Export Features 271
Performing Data Extractions 283
Managing PDF Data 290
Managing Text Data 294
Managing Excel Data 306
Managing Access Data 310
Summary 315
CHAPTER 15 Working with Files 317
Considering the File Format 317
Using the File IO Features 318
Using External Variables 346
Summary 348
CHAPTER 16 Working with Other Applications 349
Considering IDEAScript and Visual Basic for Applications (VBA)
Differences 349
Understanding the Word and Excel Object Models 350
Running Word from IDEA 351
Running IDEA from Excel 355
Summary 359
CHAPTER 17 Performing Data Analysis Tasks 361
Performing Stratification 361
Performing Summarization 367
Creating a Pivot Table 371
Employing Random Record Sampling Using RandomSample 374
Performing Gap Detection 376
Checking Distribution Using SystematicSample 378
Merging Databases 380
Summary 389
CHAPTER 18 Working with Charts and Graphs 391
Choosing the Correct Chart or Graph 391
Creating a Basic Graph 393
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
Contents ix
Defining Analytical Charts 399
Summary 405
CHAPTER 19 Defining Reports 407
Defining a Report 407
Outputting Data in PDF Format 412
Outputting Data in Word Format 414
Summary 418
CHAPTER 20 Considering Database Security 419
Considering Programmatic Data Security 419
Choosing the Correct Data Type 421
Validating Data 421
Protecting Dialog Boxes 427
Summary 428
CHAPTER 21 Debugging Your Application 429
Understanding the Kinds of Application Errors 429
Running and Stopping the Application 433
Using Breakpoints 434
Stepping through the Application 435
Using the Watch Window 438
Relying on Message Boxes 444
Summary 445
CHAPTER 22 Performing Project Management Tasks 447
Creating a Plan for Your Application 448
Keeping Track of Application Files 449
Working within a Group 450
Documenting Your Application 451
Summary 453
CHAPTER 23 Converting Visual Script to IDEAScript 455
Considering the Benefits of Using IDEAScript 455
Performing the Conversion 456
Making Changes and Saving the Result 458
Summary 461
Chapter = Date: Feb 24, 2011 Time: 12:47 pm
x Contents
About the Author 463
About the Website 465
Index 467
Chapter = Date: Feb 18, 2011 Time: 11:49 am
Preface
Most people want to perform tasks faster because, let’s face it, time is precious and
you’d much rather spend your time doing something other than sitting at your desk
waiting for the computer to complete a task. That’s where IDEAScript comes into play.
By using IDEAScript, you can automate tasks. You can tell the computer to accomplish
tasks and let you know when the work is finished. Mastering IDEAScript: The Definitive
Guide is your window to IDEAScript. It helps you understand how IDEAScript works
and how you can use it to do amazing things with IDEA, all without having to sit at your
desk to observe the computer doing it. If that sounds interesting, read on!
About This Book
Mastering IDEAScript: The Definitive Guide is designed to help the complete novice
develop the skills required to write simple applications using IDEAScript. The overall
goal of this book is to make it possible for you to automate all of those tasks that you
used to perform manually. Of course, you still have to start the task and interpret the
results—even the best automation can’t do that for you.
Automation is one of those terms that’s used a lot, but is never quite explained by
anyone. For the purposes of this book, automation means that you’ll be able to write an
application that follows a procedure you create—the same procedure you use every day
to perform tasks. It’s just that simple. Instead of you spending time filling in forms and
answering questions, you give all the required information to the computer as part of
your application and let it do the work. The result is that you become more productive
and spend less time sitting in that chair bored stiff.
The techniques in this book go further, though. Let’s say that you have an assistant
and want the assistant to help with some of the work. You can write an application that
asks the assistant very simple questions and then automates the rest of the task for the
assistant so you don’t have to help as much. The result is that your assistant also becomes
more capable and efficient. By using forms and other techniques described in this book,
you make it possible for less-skilled helpers to perform a task using the same approach
you do, making the result look the same as if you had done it.
IDEAScript provides a wealth of capabilities and Mastering IDEAScript: The Definitive
Guide tells you all about them. For example, you might want to remotely control an
external application without having to work too hard to do it. Using IDEAScript, you
xi
Chapter = Date: Feb 18, 2011 Time: 11:49 am
xii Preface
create the code required to perform the manipulation one time, and then let the computer
perform the task for you from then on.
Finally, this book tells you about a few unique tasks you can perform using
IDEAScript. Do you have an external file that doesn’t quite want to import using the nor-
mal techniques provided by IDEA? Well, you can define an application using IDEAScript
that makes it possible to import just about anything into IDEA. This book tells you how
to accomplish this kind of task.
How This Book Is Organized
This book discusses IDEAScript starting from simple topics and moving on toward more
complex topics. The initial topics also focus on tasks that you perform more often. As you
progress through the book, you start to discover tasks that are less used, but extremely
useful in many situations. In fact, this book may present you with some new ways of
accomplishing tasks that you hadn’t considered when using the GUI. Here’s a list of the
chapters in this book:
■ Chapter 1: Introducing IDEAScript: This chapter helps you understand what
automation can help you do. It presents you with the concepts behind using macros
and helps you set reasonable goals for working with IDEAScript.
■ Chapter 2: Creating Your First IDEAScript Application: This chapter begins
by helping you understand the two kinds of macros you can create with IDEA:
IDEAScript and Visual Script. It then presents you with the editors used to create each
macro type. This is also the first chapter where you write an application—something
very basic that you can use as a starting point for other applications in the book.
■ Chapter 3: Understanding the Basics of the IDEAScript Editor: This chapter
provides you with the details of using the IDEAScript Editor.
■ Chapter 4: Designing Structured Applications: This chapter helps you under-
stand the basic parts of an application. You discover how to write code quickly and
efficiently by copying it from the help file or from IDEA’s history. In addition, you
learn how to use the Macro Recorder to create complete applications without writing
any code at all. Finally, this chapter shows you how to add your application to an
IDEA toolbar or menu so that you can access it quickly.
■ Chapter 5: Working with Data: This chapter helps you understand what variables
and constants are (essentially they’re a sort of storage container) and how to use them
within your application. This chapter introduces data types, a method of categorizing
data stored in variables and constants. Finally, you discover some basic techniques
for working with variables and constants.
■ Chapter 6: Using Conditional Statements and Loops: This chapter begins build-
ing on the basic structures you learned about in Chapter 4. In this case, you learn
how to perform tasks conditionally using any criteria you want and how to perform
tasks multiple times (either a specific number of times or until the application meets
certain specifications). This chapter also helps you understand what to do about
errors that occur in your application.
Chapter = Date: Feb 18, 2011 Time: 11:49 am
Preface xiii
■ Chapter 7: Understanding IDEA Databases: This chapter introduces databases
from an IDEAScript perspective. You discover how databases are put together and
learn how to open databases for processing. After the introductory material, this
chapter provides you with the information you need to perform basic tasks, such as
indexing, sorting, and closing your database.
■ Chapter 8: Working with Databases: This chapter takes the next step after basic
database management. You discover how to perform some intermediate level tasks,
such as comparing databases and exporting them. Finally, this chapter shows you
how to work with fields, records, and tables in a database.
■ Chapter 9: Considering the CaseWare IDEA Object Model: This chapter intro-
duces you to the concept of objects, which are a representation of something in your
application. Think of objects as they appear in the real world and you have the basic
idea. Once you have the basics of objects down, this chapter introduces you to a
number of IDEAScript objects, especially those used to perform tasks.
■ Chapter 10: Performing Mathematical Tasks: This chapter helps you understand
how to perform math tasks using IDEAScript. You’ll also see details on using a couple
of the analysis-related tasks provided by IDEA.
■ Chapter 11: Interacting with Arrays: This chapter demonstrates how to use arrays,
which provide a method of storing like or associated values together for easy access.
■ Chapter 12: Creating Interactive Dialog Boxes: This chapter presents techniques
for working with complex dialog boxes. IDEAScript lets you create dialog boxes of
any complexity so that you can ask the user questions, have the user fill out forms,
or interact with the user in other ways. As part of this chapter, you learn how to use
the various graphical elements used to create dialog boxes.
■ Chapter 13: Locating Information in Databases: This chapter helps you learn
how to find information within databases. These search techniques can make it
quite easy to find any data within the database, even if you aren’t quite sure what
you’re trying to find. IDEA makes it quite easy to perform complex searches without
a lot of work on your part—IDEAScript makes things even easier by automating
some tasks associated with common searches.
■ Chapter 14: Importing and Exporting Data: This chapter shows you how you can
obtain data from other applications and send IDEA data to other applications. The
ability to import and export data is essential in today’s world of connected computers.
You want to have a number of solutions available to make data accessible for further
analysis or for sharing with other people.
■ Chapter 15: Working with Files: This chapter describes how to work with external
files of all types. You can use external files to store other information or import data
from external files that IDEA might not support directly. In addition, you can use
external files to hold configuration information or even use them to log application
errors. In short, external files are really important when creating moderately complex
IDEAScript applications.
■ Chapter 16: Working with Other Applications: This chapter describes how to
make other applications work with IDEA in a number of ways. In this chapter,
you discover specifically how to use IDEA with both Microsoft Word and Microsoft
Excel, but the techniques shown will work with other applications, too. Once you
Chapter = Date: Feb 18, 2011 Time: 11:49 am
xiv Preface
complete this chapter, you can create multi-application scenarios and automate data
manipulation tasks even further.
■ Chapter 17: Performing Data Analysis Tasks: This chapter discusses advanced
database manipulation tasks that you may not use very often, but will find essential
to accomplish certain goals. The examples in this chapter discuss advanced database
manipulation tasks such as working with pivot tables and finding gaps within data
sequences.
■ Chapter 18: Working with Charts and Graphs: This chapter describes how to
create graphical presentations of data within a database. Graphics are exciting and
usually the best way to present complex information. In addition, by using charts
and graphs, you can help others see patterns in data and present a specific message
with your data that isn’t possible using other means.
■ Chapter 19: Defining Reports: This chapter describes how to create nicely format-
ted reports using database data. In many cases, the way you present data will affect
how the viewer receives it, so this chapter is essential if you want to create output
with a certain level of fit and finish.
■ Chapter 20: Considering Database Security: This chapter discusses the difficult
topic of security in a very simple manner. When you finish this chapter, you’ll be
able to create a relatively secure application without a lot of work. Because security
is such an important topic today, you’ll want to read this chapter if you plan to share
your application with anyone else or if you routinely work on sensitive data.
■ Chapter 21: Debugging Your Application: This chapter presents methods for find-
ing errors in your application and fixing them. Most applications have errors at some
point in their lifetime. Fixing these errors makes the application more reliable, easier
to use, more efficient, and definitely a pleasure to work with as well.
■ Chapter 22: Performing Project Management Tasks: This chapter helps you
understand how to work with your application in a larger company environment. In
many cases, you’ll find that your application becomes popular after you show it to
other people. In other cases, you might find yourself working with other people to
create a database management solution in the form of an application. It’s important
to know how to work with IDEAScript in a group environment.
■ Chapter 23: Converting Visual Script to IDEAScript: This chapter demonstrates
how to convert your Visual Script macro into an IDEAScript macro. Visual Script
can be a little limiting because you don’t have good control over every feature
the application can do. Using IDEAScript is more flexible and makes it possible to
perform advanced database management.
What You Need to Use This Book
This book doesn’t assume that you have any knowledge about programming or have
any programming skills. In fact, it assumes that you don’t have either programming
knowledge or skills. However, you do need to know the basics of working with Windows
and you must at least be familiar with using IDEA. This book doesn’t tell you how to
Chapter = Date: Feb 18, 2011 Time: 11:49 am
Preface xv
perform tasks such as working with a mouse and it assumes that you know how to use
IDEA to perform at least simple tasks such as extracting a database.
You won’t need any special equipment or software to use this book. All you need is
your copy of IDEA. If you want to perform some advanced tasks, such as working with
other applications, you do need the other applications. For the purposes of this book, if
you have a copy of Microsoft Excel and Microsoft Word handy, you’ll be able to work
with the examples in Chapter 16.
Conventions Used in This Book
This book doesn’t use many conventions. It emphasizes simple text for most purposes.
You’ll see special terms in italics on first use, followed by a definition of that term.
Website URLs, all code, file/folder names, and file/folder locations appear in Courier
New font type. In procedural text, Bold is used for user interface elements and text you
need to enter. This book also provides three special kinds of text as follows:
■ Notes are additional information that doesn’t fit within the flow of text. You might
find the information useful because it augments the information found in the para-
graphs. In some cases, notes provide sources of additional information or help you
understand a concept more clearly. In almost every case, you can skip a note without
losing any essential information, but whenever possible, stop to read the notes to
get the special information they contain.
■ Tips provide you with insights on how to do something more efficiently, faster, or
with less work. Often, tips provide best practices for working with IDEAScript. Even
though tips aren’t essential reading, you’ll want to read tips whenever possible to
get the most out of this book and IDEAScript.
■ Warnings tell you about things you should avoid doing. In many cases, warnings
tell you about situations that will cause data loss or at least cause your application
to crash. You should always pay special attention to warnings. In fact, you should
note warnings that especially affect you and go back to them later when writing your
application. Never skip warnings.
In addition to these three special kinds of text, this book does use a special format
for code. You’ll see both code snippets (short sections of incomplete code) and code
listings (longer sections of complete examples) in the following format:
' This is a comment.
MsgBox This is code
Chapter = Date: Feb 18, 2011 Time: 11:49 am
Chapter = Date: Dec 22, 2010 Time: 11:45 am
Acknowledgments
Thanks to my wife, Rebecca, for working with me to get this book completed. I really
don’t know what I would have done without her help in researching and compiling
some of the information that appears in this book. She also did a fine job of proofreading
most of my rough draft.
Matt Wagner, my agent, deserves credit for helping me get the contract in the first
place and taking care of all the details that most authors don’t consider. I always appre-
ciate his assistance. It’s good to know that someone wants to help.
Finally, I would like to thank Andrew Coles, Vanessa Muckleston, Andy Sloman,
Christine Dahlgren, and the rest of the editorial and production staff for their assis-
tance in bringing this book to print. It’s always nice to work with such a great group of
professionals.
xvii
Chapter = Date: Dec 22, 2010 Time: 11:45 am
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
CHAPTER 1
Introducing IDEAScript
You’ve just completed the same analysis for the fiftieth time and wonder if there isn’t
an easier way to get the job done. Yes, using IDEA is fast and easy, but there must be
a way to make things faster still. Of course, you can try to find some way to improve your
own efficiency or try to perform the analysis a few less times, but there are limitations
to that approach and they often require additional work on your part. Why not have
someone else, or more importantly, something else, do the work for you? That’s what
scripting is all about. This book tells you everything you need to know in order to make
the computer work for you, rather than you work for it. In this chapter, you discover just
how much benefit you can obtain by spending a few hours learning to tell the computer
what to do. As you go through this chapter, you learn how to:
■ Understand how automation can make working with IDEA easier.
■ Consider the ways in which you can use automation.
■ Decide which forms of automation to pursue first.
■ Determine how your skills can help you use automation best.
Understanding Automation
The computer community will use all kinds of technical terms you don’t understand to
describe scripting. In fact, the word scripting itself sounds foreign and technical. What
this book really describes is automation, and you use automation every day. When you
go to the gas station and fill your car with gas, you’re using automation. After all, you
don’t have to pump the gas from the storage tank yourself—you let the gas pump do the
work. When you go to the store, the cashier uses a cash register and scanner to total the
amount of money you owe for food—no one uses pen and paper any longer. The cashier
is employing yet another kind of automation. You get home and click a button—the
garage door opens. The garage door is yet more automation. In fact, it won’t take long
for you to find automation everywhere in your life. Why not automate IDEA as well?
All forms of automation rely on some kind of control. When you pump gas, you press
buttons or tell the gas pump to begin pumping in some other way. Controls inside the gas
pump automatically stop the flow of gas. At the store, the act of clicking a few keys on the
1
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
2 Mastering IDEAScript
cash register and scanning the items provides control over the adding process. The garage
door opens when you click a button on its control. Likewise, scripting is a form of control
over IDEA that you exercise using special words and phrases. As you can see, scripting
isn’t anything new—you’ve already been exercising control over things all your life.
Scripting is a little more complex than pumping gas, scanning groceries, or opening
a garage door, but it also does a lot more for you. The complexity comes in the form of
a procedure you must write. Of course, you’ve already been doing that task for a long
time too. Any time you have someone stay at your house to water the plants or ask a
coworker to perform a task, you write a procedure for them—you tell them what you
want them to do and when to do it. Automating tasks in IDEA is no different. You use
control words to write a procedure that IDEA performs for you. This procedure is called
a macro and you use macros to tell IDEA how to automate tasks for you. The following
sections describe the benefits of automating tasks in IDEA in more detail.
How Does Automation Benefit You?
The main reason you’re reading this book is to gain a new skill that benefits you in some
way. After all, why bother to learn something that isn’t going to help you in some way?
The following list outlines the benefits you should consider as you read this book:
■ You can perform work faster.
■ The results you obtain will contain fewer errors.
■ Any analysis is performed more consistently.
■ Your work becomes more interesting because you can focus on unique tasks.
■ You don’t have to remember how to perform complex procedures because the
procedure is contained in the macro.
■ It’s easy to justify actions you take based on the consistency of your macros.
Tip
There are many ways in which learning to script will benefit you that this book can’t
cover. For example, if you know how to script and none of the other people in your
organization do, you’ll likely find that your job security is greater and you’ll receive
promotions more often. Many people are afraid of scripting, but you’re brave enough
to give it a try. You’ll find that scripting is actually quite easy and straightforward as
the book progresses.
How Does Automation Benefit Others?
Believe it or not, your new skill will also benefit others. When you know how to create
macros, you become an important asset to others who don’t know how to perform this
task or simply want to benefit from what you’ve learned. The following list outlines the
benefits others will receive from your macros:
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
Introducing IDEAScript 3
■ People can use your macros to obtain the same benefits you obtain.
■ Your organization can perform analysis in a consistent fashion, making the analysis
easier for everyone to understand.
■ The reports and other output you generate will make it easier to see trends.
■ It’s possible to create a workflow (a standard method of performing a task) for the
entire organization.
■ A single employee absence won’t mean that work stops.
Best Practices for Using Automation
Given the benefits of automation, you may be tempted to use automation all the time.
However, automation isn’t always the answer; you must use some discretion in employing
automation. For example, you wouldn’t want a completely automated plane—having a
pilot is important for safety reasons. The following list provides best practices you should
follow when considering automation:
■ Always choose tasks that you’ll repeat. The more often you need to repeat a task,
the better a candidate it is for scripting.
■ Always choose well-defined tasks. In order to write a procedure, you must under-
stand the task completely.
■ Always plan your macros carefully and completely so that the procedure works as
you expect it should. The planning process begins when you separate tasks that will
automate well from those that won’t.
■ Whenever possible, create macros that everyone in your organization can use, rather
than focus on macros for personal needs. When everyone benefits, the time you use
to write the macro is paid off faster.
■ Whenever possible, write down the procedure you use and then test the procedure
carefully. This act is no different from any other automation you use. For example,
you’d expect that a cashier would receive training that relies on written and tested
procedures.
■ Avoid writing macros that are too complicated for your current skill level. Discover
scripting a step at a time. As this chapter progresses, you’ll learn tricks you can use
to avoid getting in over your head.
■ Never assume that the macro you write for your machine will work on another
machine until you test it on that machine. Just as a procedure for one cash register
may not work on another, you can’t assume your macro will work on every machine.
As the book progresses, you’ll discover methods for testing your macros to ensure
they work as anticipated.
Understanding How You Use Macros
Macros, the written procedures used for scripting, can perform all kinds of tasks. In fact,
the number of tasks you can perform is literally limited only by your imagination. Some
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
4 Mastering IDEAScript
people have written games and done all kinds of other interesting things with macros.
Of course, most people use macros for more practical purposes. The following sections
describe some of the common tasks you can perform with macros.
Interacting with Databases
The task you perform most often in IDEA is interacting with a database of some sort.
From your perspective, you’re performing a data analysis. However, from the perspec-
tive of the IDEA application, you’re manipulating data found in databases. Whatever
the perspective, being able to get the data you need is important, and it’s often repeti-
tious. Macros that help you get the information you need are probably the singular most
important kind of macro that you can write.
Starting with Chapter 7, you begin working with databases and discover that no
matter the source, databases often have similar needs and requirements when writing a
macro. Chapter 8 shows you how to interact with databases, while Chapter 9 describes
the model IDEAScript uses to work with databases. When working with IDEAScript, you
can access two kinds of databases:
■ Internal IDEA databases
■ External databases such as SQL Server
This book helps you work with both kinds of databases. The external database
information starts in Chapter 14 and you see some advanced techniques in Chapter 17.
In fact, you’ll find that you can access data in all its forms, even an Excel document (see
Chapter 16) or a text file (see Chapter 15) on your hard drive. Procedures that might
seem complex when you perform them by hand suddenly become easy and fast when
you use a macro to perform them.
Customizing the IDEA Interface
You can attach (bind) your macros to the IDEA interface. By adding buttons that
access your macros, you can customize the IDEA interface to meet your specific
needs. Your macros, in essence, become part of the IDEA application and make using
IDEA easier. Chapter 4 tells you how to add your macros to the IDEA application
interface.
Performing Calculations
Analysis normally includes performing comparisons and employing equations to calcu-
late specific values. Of course, you want to be sure you perform the right comparisons
and obtain the correct calculations. Fortunately, your computer is far faster and signifi-
cantly more accurate in both comparisons and calculations, so this is one area that you
really should let the computer take care of for you. Chapter 6 tells you how to perform
comparisons, while Chapter 10 addresses math requirements.
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
Introducing IDEAScript 5
Designing New Application Features
Binding macros to the IDEA interface isn’t the only kind of customization you can do.
In addition, you can create your own interface elements as dialog boxes. You can use
dialog boxes for two purposes:
■ To output information to the user.
■ To obtain input from the user.
You can do everything from telling the user of your macro the status of a calculation
to asking the user for the name of the database they want to use for analysis. Chapter 12
shows you how to create interactive dialog boxes that let you do amazing things.
Importing and Exporting Data
Most businesses need to exchange data in some form or another. Depending on the kind
of analysis you perform, you might have to obtain data from many different businesses.
Unfortunately, businesses use different applications and different methodologies to store
information. Trying to remember all of the methods used to access this information can
prove daunting. Fortunately, macros make fast work of importing and exporting data as
needed. Chapter 14 describes the resources that IDEAScript provides for importing and
exporting data.
Data comes in many forms. Normally, you’ll work with databases, but that isn’t
always the case. Besides the database chapters in this book, you can discover how to
interact directly with files in Chapter 15 and Excel in Chapter 16.
Controlling Other Applications
One of the most useful ways to use macros is to control other applications. It’s incon-
venient and time wasting to have to interact with more than one application at a time.
If you can perform at least part of that work by using a macro, you save time and can
maintain a focus on IDEA.
Nothing limits the kinds of applications you can control. If you want to start a copy
of Excel and use it to create a chart or graph, you can do so with the information found
in Chapter 18. Chapter 19 shows how to control other applications, such as Word, to
create reports.
Warning
Never execute macros unless you know what task the macro performs and that the
macro is safe to use. Executing a macro that you don’t know about can cause damage
to your data or produce unreliable results. In addition, macros can cause significant
problems on your machine, such as installing a virus. The macros that are completely
safe are the ones you understand and obtain from a reliable source.
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
6 Mastering IDEAScript
FIGURE 1.1 The Open Dialog Box Lets You Choose a Macro File on Your Hard Drive
You’re probably thinking that controlling another application sounds too hard, but
it really isn’t. The first exercise in this book is to execute a macro that starts a copy of
Internet Explorer. This macro actually comes with your copy of IDEA. Just follow these
steps.
1. Open IDEA and select Tools  Macros  Open. This command displays the Open
dialog box shown in Figure 1.1. IDEA automatically selects the Samples folder for
you, which contains a macro named ie.iss. If you don’t see the Samples folder,
you can find it by locating My DocumentsIDEASamples in the Look in field.
2. Select ie.iss and click Open. IDEA opens the IDEAScript Editor shown in
Figure 1.2. Don’t worry about the editor for now; Chapter 2 tells you how to work
with it. The text you see in the right Editor pane is a macro and we’re going to
execute it.
3. Click Run Script. The Run Script button is the blue right-pointing arrow on the
toolbar. You can also press F5. IDEA executes the macro and opens a copy of
Internet Explorer for you. Congratulations! You just executed your first macro.
4. Close Internet Explorer. Select File  Exit in the IDEAScript Editor.
Having Things Your Way
For many people, the idea of scripting can become overwhelming. At first, you can’t
quite accept that you can actually write macros, but then, once you get used to the idea,
all kinds of macro ideas start coming to mind. It’s nice to have things your way. Once
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
Introducing IDEAScript 7
FIGURE 1.2 The IDEAScript Editor Lets You Write Macros That You Can Save to Disk
you discover the full capability of scripting, you’ll find that you can do a host of things
that you didn’t think were possible in the past.
Of course, that list of ideas can become a burden, too. Make sure you write your
ideas down because it’s all too easy to forget something you want to do. Even if you don’t
know how to write the macro today, write it down. As you work with IDEAScript, your
skills will improve and today’s impossible task will become quite possible tomorrow.
Make sure you prioritize your list. Use these criteria for prioritization:
■ Skill Level: Your skill level determines the macros you can create today.
■ Existing Knowledge: Macros that play to knowledge you already possess, say a
math macro if you’re already a math expert, should be a priority.
■ Pressing Need: Personal or organizational needs can act as a great motivator to
finish the macro. Some people try for a short time and then give up—finishing the
macro is the only way to build the knowledge you need.
■ Interest: Some projects are definitely more interesting than others. It’s more likely
that you’ll finish a macro that interests you, so be sure to tackle these macros first.
Considering Your Skills
Even though macro writing is like many other things you’ve already done and is basically
writing a procedure for IDEA to follow, it’s still a skill. As you write more macros, you’ll
Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am
8 Mastering IDEAScript
learn more about the IDEAScript language and be able to create procedures that are
more complex than those you create at first. The best way to learn scripting is to start
slowly and discover new commands one at a time until you become proficient.
Some of the skills you already possess will help as you discover IDEAScript. For
example, if you already have solid math skills, you’ll find that writing macros that perform
math tasks is significantly easier. You may even want to focus on math-related macros
when you first begin scripting. Some people already know quite a bit about databases,
so working on database-related macros is easier. Don’t force yourself to start out with
something too difficult—ease into scripting.
You should create some goals for yourself based on the scripting needs you discover
as you work with IDEA. Put these goals on your To Do list—the same as you would
anything else you want to learn. When you have a little additional time or you’re waiting
for another task to complete, take some time to learn a new IDEAScript command and
then begin employing it in your macros. It won’t be long before you’ll be writing complex
macros without any trouble at all.
No one’s asking you to memorize anything. The purpose of this book is to act as your
memory. As you work through the book, you’ll discover that IDEA provides a number
of other useful aids to make writing macros easier. Writing macros should be something
you do to improve your work experience, not ruin your mood.
Summary
This chapter has started you on the road to a new kind of experience—scripting. The
most important idea to take from this chapter is that anyone can write a macro as long as
they fully understand the task at hand. While not every task is suitable for automation,
many tasks are and you should make full use of this capability in IDEA to reduce your
workload. The macros you create help both you and everyone else in your organization,
so writing good macros is essential.
One of the most important aspects of using automation is to employ it correctly.
Of course, only you can decide when automation applies. Before you go to the next
chapter, consider a few places in which automation will help you and your organization.
Using the information in this chapter, write down the pros and cons of using automation
for the tasks you define. Present your list and reasoning to other people and see if they
agree that automation is the right choice for the tasks you list. This exercise will save
you considerable time trying to automate tasks that you really shouldn’t automate.
Now that you have a list of tasks you want to automate, Chapter 2 takes the next
step and begins to show how to create macros. Of course, your first macros will be
very simple. You want to make scripting fun and easy to perform, so these initial steps
are important. The macro in Chapter 2 is functional and you can even show it off to
your friends. However, you’ll create significantly more interesting macros as the book
progresses.
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
CHAPTER 2
Creating Your First
IDEAScript Application
An IDEAScript application is a group of one or more macros that perform a specific
task, such as a particular kind of analysis on a database. The application can contain
dialog boxes and other user interface features that make it possible to interact with the
user and create a more flexible result. You can even compile your IDEAScript application
to execute it at the command line without ever opening IDEA.
Many people experience a mental block when they attempt to perform some tasks.
For example, most people have a hard time starting to write something when faced with
a blank page. Writing an application can be the same way. Many people look at the
blank editor screen and simply don’t know what to do next. Just as book authors use a
number of tricks to avoid the blank page, you can use some tricks to avoid the blank
editor screen. This chapter helps you get started by showing you how to create simple
applications. Often, you can start with a simple application and keep adding to it until
the resulting application does everything you need.
Before you can create a macro, however, you need to know how to perform
tasks such as opening the editors and interacting with them in a meaningful way. In
fact, you will learn that IDEA actually provides two different editors and you need to
decide which editor to use for your application. IDEA also lets you create an executable
program—one that you can start from within Windows without starting IDEA. Executa-
bles are really interesting because they let you start macros without starting the editor
every time.
Understanding the Macro Types
A macro is always a method of creating a procedure using special control words. You
execute the macro by telling IDEA to perform the procedure. However, IDEA provides
two different methods for creating a macro. The first, IDEAScript, is more powerful and
flexible because it lets you work with the control words directly. The second, Visual
Script, is easier because you tell IDEA what you want to do using a graphical interface
9
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
10 Mastering IDEAScript
and then IDEA creates the control words for you. The following sections describe each
macro creation method in more detail.
Considering IDEAScript
IDEAScript provides you with the ultimate in flexibility when creating macros for IDEA.
When working with IDEAScript, you can control the entire IDEA object model, work
with dialog boxes, interact with the operating system, and even control other applica-
tions. However, with this kind of power comes a certain level of complexity. Don’t let
the complexity overwhelm you—take things slowly and you’ll find that it’s quite man-
ageable. After all, everyone who’s ever written a macro has started out knowing nothing
about performing this task. Even so, it will require a little time to learn how to use
IDEAScript.
You select IDEAScript when you want the best control over your application and
need to perform significant tasks. IDEAScript is the right tool for anyone who has time
to learn the special control words used to communicate with IDEA. Anyone reading this
book falls into that category. You’ve already shown your interest in having the additional
power over IDEA by reading this book.
Considering Visual Script
Visual Script provides a graphical method of creating a macro. You essentially describe
what you want to see and IDEA provides it for you. Visual Script is very good for creating
a macro for repeating tasks. For example, you can use it to create a macro that imports
a file, runs some tasks to analyze data, and then provides results where the auditor
takes over.
Using Visual Script is incredibly easy, but it also limits what you can do in a significant
way. For example, you can’t create a message box describing the result of executing a
task directly. You save Visual Script macros as .vscript files.
One of the more important Visual Script limitations is that you can’t run a Visual
Script macro on IDEA Server. IDEA Server allows the users to connect to a server and
run tasks on a server farm. Consequently, Visual Script isn’t a very good solution for
larger enterprises.
It’s possible to use Visual Script as a method for starting an IDEAScript application
if you want to completely avoid the blank page issue. All you do is create the basics of
your application using the Visual Script Editor and then convert the Visual Script macro
to an IDEAScript macro. Chapter 23 explains how to convert Visual Script macros to
IDEAScript macros.
You aren’t completely without resources when working with Visual Script. For exam-
ple, you can use macros (either IDEAScript or Visual Script) that you or someone else
creates using IDEAScript. Consequently, it’s possible to use Visual Script as a means of
gluing modules together—to hide complexity from view. With the right coding tech-
nique, you can obtain the simplicity of Visual Script matched with the flexibility of
IDEAScript.
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
Creating Your First IDEAScript Application 11
Note
You can’t use macros that require any sort of input information other than the infor-
mation that’s available from a database or other external source. When you insert
a macro in Visual Script, the macro is executed in its entirety. Consequently, any
macros you use within Visual Script must be self-contained modules (black boxes)
that require nothing on the part of the individual using it.
Visual Script may not be the option of choice for you, but it could be an option
for less skilled workers. You can create IDEAScript modules that others put together as
needed to perform tasks in your organization. Consequently, you shouldn’t view Visual
Script from the limited perspective of a personal tool.
Opening the Visual Script Editor
Before you can create a Visual Script macro, you must open the associated editor. Start
IDEA and then select Tools  Macros  New  Visual Script. You see the Visual Script
Editor shown in Figure 2.1.
FIGURE 2.1 The Visual Script Editor Lets You Create Visual Script Macros
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
12 Mastering IDEAScript
FIGURE 2.2 Choose a Database You Want to Use
Unfortunately, the display looks a bit blank, but that’s easily fixed. To begin a new
macro, simply open a database or select a macro you want to execute. For the purpose
of this example, let’s assume you want to find all of the customers in the Sample-
Customers database that have a credit limit equal to or greater than $10,000.00. The
following steps show you how easy it is to create the macro.
1. Select Task  Insert  File  Open Database. You’ll see the Select Database
dialog box shown in Figure 2.2. This dialog box shows all of the databases that
you can access, which are the sample databases when you first install IDEA (found
in your current working folder).
2. Select the database you want to use (Sample-Customers in this case) and click
OK. IDEA closes the dialog box and adds an entry for the database to the Visual
Script Editor. Now that you have a database open, you can do something with it.
For the purposes of the example, we’ll create an indexed extraction.
3. Select Task  Insert  Data  Extractions  Indexed Extraction. You’ll see the
Indexed Extraction dialog box shown in Figure 2.3 (which has already been filled
out in the screenshot).
4. In the Field box, select CREDIT LIM. In the Value is fields, select = and then type
10000. In the File name field, type 10K Customers. Each of these actions defines
part of the task you want performed on the Sample-Customers database. In this
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
Creating Your First IDEAScript Application 13
FIGURE 2.3 Tell IDEA What You Want to Do with the Database
case, you’re telling IDEA to extract all of the records in the Sample-Customers
database that have a value equal to or greater than 10000 in the CREDIT LIM (credit
limit) field and place them in the 10K Customers database.
5. Click OK. IDEA will display a dialog box asking whether you want to perform the
task now. Click No. We’ll run the task later. Now, at this point, you’ll probably want
to close the Sample-Customers database because you don’t need it anymore.
6. Select Task  Insert  File  Close Database. Again, IDEA will ask whether you
want to perform the task now. Click No. At this point, you should have a procedure
completed like the one shown in Figure 2.4. That’s all a macro is really—a procedure
that you define for IDEA to perform.
Note
The reason the task message appears is that you may need to program a task based
on the output of a previous task. This feature allows you to selectively run only a
single task at a time—something that you can’t do using IDEAScript.
Let’s try executing the macro. Select Run  Run and you’ll see the Sample-
Customers database open, IDEA will create the required extraction, and then you’ll
see the Sample-Customers database close. At the bottom of the Visual Script Editor
window, you’ll see “The Visual Script has completed without any errors.”
To save the macro so you can view it later, select File  Save. You’ll see the Save
Visual Script As dialog box. Type a name, such as 10K Customers, in the File name
field and click Save. Select File  Exit to close the Visual Script Editor window. To
see the results of the macro, double-click the Sample-Customers10K Customers
database entry in the File Explorer window. You’ll see the output shown in Figure 2.5.
Of course, the question now is whether the macro actually produced code. If you
convert this macro using the process described in Chapter 23, you’ll get the macro shown
in Listing 2.1.
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
14 Mastering IDEAScript
FIGURE 2.4 The Completed Macro Is Simply a Procedure
FIGURE 2.5 Seeing the Output Tells You That the Macro Worked
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
Creating Your First IDEAScript Application 15
LISTING 2.1 Output of the 10K Customers Macro
Sub Main
Call IndexedExtraction() 'Sample-Customers.imd
End Sub
' Data: Indexed Extraction
Function IndexedExtraction
Const WI_IE_NUMFLD = 1
Const WI_IE_CHARFLD = 2
Const WI_IE_TIMEFLD = 3
Set db = Client.OpenDatabase(Sample-Customers.imd)
Set task = db.IndexedExtraction
task.IncludeAllFields
task.FieldToUse = CREDIT_LIM
task.FieldValueIs2 WI_IE_GTEQUAL, 10000.00, WI_IE_NUMFLD
dbName = 10K Customers.imd
task.OutputFilename = dbName
task.PerformTask
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
End Function
It isn’t important that you understand the code shown in Listing 2.1 right now. In
fact, after you’ve discovered more about IDEAScript, you can come back to this listing
and read it with ease. What’s important is to know that creating a macro using the Visual
Script Editor produces real code that you can modify later.
Writing a Hello World Application
You’ve probably wanted to write your first IDEAScript macro from the beginning of this
chapter. Well, the wait is over. To begin this section, select Tools  Macros  New 
IDEAScript. You’ll see the IDEAScript Editor shown in Figure 2.6.
Notice that IDEA automatically starts a macro for you so that you don’t face a blank
page. The keyword Sub is short for subroutine. A macro consists of one or more subrou-
tines. You must tell IDEA where the subroutine starts and ends. Placing Sub as the first
word on a line always starts a subroutine. The End Sub keyword combination shows the
end of the subroutine. The word Main is the name of the subroutine. You must always
provide a name for the subroutines you create.
The left side of the display contains the Project window, while the right side contains
the Editor window where you type the code for your macro. Now that we’re ready for
that first macro, the following sections help you create your first macro and show it off
to your friends.
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
16 Mastering IDEAScript
FIGURE 2.6 The IDEAScript Editor Is Where You Type the Code for the Macros You Want to Create
Typing in the Editor Window
You type code words into the Editor window just as you would a word processor doc-
ument, spreadsheet, or other editor. When you create a macro, you place the text you
type between the Sub and End Sub lines in the window. This placement tells IDEA
that the words you’ve typed are part of a procedure.
Fortunately, you don’t have to go it alone when you use IDEAScript, because the
Editor window comes with several aids. The first is IntelliSense. When you type some-
thing, the Editor window helps you out by telling you about the additional information
you can provide as a tooltip. Figure 2.7 shows a typical example of IntelliSense informa-
tion. Don’t worry about the other aids for right now, you’ll find them discussed in later
sections of the book.
For this example, type MsgBox(“Hello World”). The MsgBox function (a kind of
command) tells IDEA to display a message box that contains the words Hello World.
It’s a simple example that programmers have used throughout history when learning
IDEAScript or another language. Don’t worry too much about the specifics of the code
FIGURE 2.7 IDEA Provides Help on What to Type Next When You Begin Typing a Function Name
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
Creating Your First IDEAScript Application 17
FIGURE 2.8 The First Macro Displays a Message Box With Hello World in It
for now. The code is a little hard to read as is, so add three spaces in front of MsgBox
to show that Sub Main holds one procedural step that displays a message box. Your
code should look like this:
Sub Main
MsgBox(‘‘Hello World‘‘)
End Sub
It’s time to try your first macro. Select Debug  Run or simply press F5. You see a
message box like the one shown in Figure 2.8. Isn’t it exciting to see the first macro run?
As you can see, it doesn’t take very much to boss IDEA around. Click OK to remove the
dialog box.
Saving Your Macro
The macro you created exists only in memory right now. Just like your other documents,
you must save the macro to disk to reuse it. IDEA will remind you to save the macro
if you haven’t done so already. To save your macro, select File  Save, click the Save
toolbar button, or press Ctrl+S. In all three cases, you see the Save As dialog box shown
in Figure 2.9.
Use the Save in field to change the location where you save the macro. Type the
name of the macro in the File name field. The example uses Hello World as a file
name. Click Save to save the file.
Understanding .iss Versus .ise Files
Macros can appear with two different extensions: .iss or .ise. The .iss file is a stan-
dard text file that contains the code you write, while the .ise file is compiled. Compiling
the file turns the text into tokens that IDEA can understand. (There’s a third form, an
executable file that you can learn about in the “Building Your Application” section, but
this isn’t strictly a macro file.) So, if the .iss file contains words you understand and
executes as a macro, just like the .ise file, why would you ever use the .iss file? The
following list describes situations where the .ise file excels.
■ Code Hiding: You put a lot of work into your macros. If you make the code acces-
sible to everyone, someone will almost certainly steal it and claim that they created
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
18 Mastering IDEAScript
FIGURE 2.9 Save Your Macro so You Can Use It Later
it. If you want to maintain control over the code you create, compiling it hides the
code from everyone else, while letting them use it for purposes you specify.
■ Faster Execution: Theoretically, the compiled file will provide better execution
times since it has already been converted into a form that IDEA recognizes. The
interpretation phase of working with the macro is taken care of before you actually
use the macro.
It’s easy to create a compiled file. Select File  Save As, click the Save tool-
bar button, or press Ctrl+S. When you see the Save As dialog box shown in Figure
2.9, select the Compiled files (*.ise) option in the Save as type field. Type a name
in the File name field as normal and click Save. Figure 2.10 shows the Hello
World.ise file.
As you can see, the file content looks like pure garbage, yet it executes as nor-
mal. To execute this file, select Tools  Macros  Run in IDEA. Locate the Hello
World.ise file and click Open. You see precisely the same result as when using the
Hello World.iss file.
FIGURE 2.10 It’s Impossible to Read an .ise File, Making It More Secure than an .iss File
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
Creating Your First IDEAScript Application 19
Sending Your Macro to Someone Else
At this point, you have a lovely new macro. You’re justifiably proud of your efforts
and want to share it with someone else. IDEA makes it easy to send others the macros
you create. In the IDEAScript Editor, select File  Send. IDEA will create an e-mail
message using your default e-mail program. The macro is automatically attached to the
e-mail message for you. All you need do is supply an address, subject, and message, and
send the e-mail to the recipient as normal.
Building Your Application
IDEA supports the creation of executable files from your macros. Using this technique
lets you build complete applications that run outside IDEA, unlike a macro that you
have to execute from within IDEA. (You still have to have IDEA installed in order to
run the application, but the convenience of using an executable file still makes this
a valuable option.) This technique is most useful when you create a complete, self-
contained process that you don’t want others to modify. The following sections describe
how to build an executable application.
Creating the Executable File
Before you do anything else, you need to save your macro as described in the “Saving
Your Macro” section. It’s important to save your macro before you create an executable
application from it. The following steps tell how to create the executable:
1. Select File  Build Application Name.exe. For example, if you’ve followed the
Hello World example, you’d select File  Build Hello World.exe. Interestingly
enough, you see a Save As dialog box that looks similar to the one in Figure 2.9.
However, in this case, the Save as type field contains an Executable files (*.exe)
entry in place of the normal macro entries.
2. Type a name for the executable file in the File name field.
3. Select a location for the executable file in the Save in field.
4. Click Save. You’ll see a new file created in the folder you selected with an .exe
extension.
Warning
Always save a copy of your application code in a safe place. Choose a central location
for all of your application code so that you can find it when you need it. For security
reasons, keep compiled or executable forms of your application on network drives or
the drives of other users. The important thing to remember is that you can’t recover
your application code if you lose it—the compiled and executable files are unreadable
and you can’t obtain your application code from them.
Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am
20 Mastering IDEAScript
Executing Your Application from Windows Explorer
Now that you have a shiny new executable to use, locate it in Windows Explorer. Double-
click the icon as you would any other Windows application and you’ll see the same
results as before for Hello World. However, in this case, you don’t have to have IDEA
running to use the macro—you can double-click the executable file with IDEA closed.
Just as you can add any Windows application to a shortcut or the Start menu, you
can place an IDEA executable in these locations as well. You can send the .exe file
to a friend and they’ll have your complete application. In short, creating an executable
file has every advantage that you obtain from its Windows counterpart—an .exe file
is always an executable. Just imagine—your first application and you’ve already created
something that takes programmers weeks to learn!
Note
If you want to run your uncompiled application using the Windows Scheduler, you
must do so by specifying the IDEA.EXE file and the/m command line switch. For
example, if you have an application named MyApplication, then you would add
IDEA.EXE/m=MyApplication.ISS to the Windows Scheduler Run field. How-
ever, you can get around this requirement by using the executable form of the
IDEAScript application.
Summary
This chapter has demonstrated how easy it is to create an application using IDEAScript.
You don’t need any special skills to perform the task—simply a few instructions. Using
the techniques in this chapter, anyone can create an application that will help others
work faster and smarter. Of course, you still need to discover more about IDEAScript
before you can do anything impressive. The basic ideas in this chapter tell you what
you’ll do, but not how to do it—that’s what the rest of the book is for.
It’s important that you understand this chapter completely before you proceed. Make
sure you create both the 10K Customers database and the Hello World application
as well as understand what you’re doing before you proceed. It isn’t necessary at this
point that you understand the code—simply the process that you’ll follow. Don’t worry;
you’ll discover more about IDEAScript as the book progresses.
It’s extremely important to learn about the tools you use to work with IDEAScript.
Chapter 3 helps you take this next step by describing all of the elements of the IDEAScript
Editor in detail. So far, you’ve simply followed instructions to perform a task. By the time
you finish Chapter 3, you’ll understand how the IDEAScript Editor works and will be
able to complete many tasks on your own. Knowing your tools is extremely important.
Just as you expect a carpenter to know how to use a hammer, others will expect you to
know how to use the IDEAScript Editor.
Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am
CHAPTER 3
Understanding the Basics of the
IDEAScript Editor
The IDEAScript Editor is your tool for creating IDEA macros. As with any other tool,
understanding how the IDEAScript Editor works is central to your ability to create
macros efficiently. Trying to use a hammer to drive home a screw might work, but it’s
not very efficient and definitely won’t produce a very satisfying result. Likewise, your
ability to use the IDEAScript Editor helps determine the efficiency with which you work
and partly determines the result you receive.
One of the essentials of working with the IDEAScript Editor is to understand the
windows it provides. Each of these windows gives you a different perspective of your
application. Some windows, such as the Editor window, you use all the time, while others,
such as the Watch window, only see use for specific tasks (debugging, or removing errors,
in the case of the Watch window). It’s important to know how to hide and view these
windows as needed.
Along with windows, the IDEAScript Editor includes a number of menus and toolbars
that you use to access commands. Locating the correct command quickly will help you
work faster. This chapter considers the default configuration of the menus and toolbars
first and then looks at ways you can customize the menus and toolbars as needed.
Perhaps the most important tool in your arsenal is the Language Browser. No one
can possibly remember every function that you can use to create an application. Conse-
quently, you need well organized help to locate precisely the function you need. You’ll
use the Language Browser regularly as the book progresses, so this is possibly one of
the most important tools to learn about first.
Working with Windows
Think about the windows in the IDEAScript Editor in the same way that you think about
windows in your house—they offer a view of your application. You look through the
windows to see your application in a certain way. Just as each window in your house
offers a different view, so do the windows in the IDEAScript Editor. The following sections
describe each of the IDEAScript windows that you use when creating an application.
21
Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am
22 Mastering IDEAScript
FIGURE 3.1 The Editor Window Provides a Place to Type Code for Your Application
Editor
The Editor window is where you type the commands that you want IDEA to perform.
Figure 3.1 shows the Editor window. In this case, you see the Hello World application
created in Chapter 2. However, the Editor window shows whatever code your applica-
tion uses.
As noted in Chapter 2, whenever you type a keyword in the Editor window, it
displays a tooltip with information about that keyword. For example, if you type the
name of a function, you see the input that the function requires to perform useful work.
One of the Editor window features is hidden. Right-click anywhere within the Editor
window and you see the context menu shown in Figure 3.2. You can use the options on
this context menu to perform the following tasks:
■ Cut: Removes the text you have highlighted in the Editor window and places it on
the Windows Clipboard. You can use the Paste command to place this text in another
FIGURE 3.2 The Editor Window Context Menu Contains Options for Working with Text
Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am
Understanding the Basics of the IDEAScript Editor 23
location and create multiple copies of it. IDEA only enables the Cut command when
you have text highlighted.
■ Copy: Places a copy of the text you have highlighted in the Editor window onto the
Windows Clipboard. You can use the Paste command to create multiple copies of
the text anywhere you need it within the Editor window. It’s also possible to use this
feature to copy code to another application. IDEA only enables the Copy command
when you have text highlighted.
■ Paste: Writes text that currently appears on the Windows Clipboard to the Editor
window at the insertion point (the point at which the text cursor appears). IDEA only
enables the Paste command when you have text placed on the Windows Clipboard.
Note
The Editor window is the only IDEAScript Editor window that you can’t hide. Because
you use this particular window for every task, from writing the application to testing
it, hiding the Editor window wouldn’t serve a useful purpose.
Project
The Project window contains details about the elements in your application. Every time
you create a new application element such as a function, subroutine, or dialog box, it
appears in the Project window. Figure 3.3 shows the Project window as it appears for
the Hello World application.
Whenever you double-click an element in the Project window, IDEA presents that
element to you. For example, if you double-click a subroutine or a function name, IDEA
places the insertion pointer next to the subroutine’s or function’s name in the Editor
window.
Right-clicking the project’s file name, such as Hello World.iss, presents a
context menu with a single entry, Close. Choosing this entry will close the project
for you.
FIGURE 3.3 The Project Window Contains a Complete List of All Application Elements
Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am
24 Mastering IDEAScript
FIGURE 3.4 The Properties Window Helps You Work with Dialog Boxes
Tip
It pays to right-click in the IDEAScript Editor wherever you think you might find
a context menu. The IDEAScript Editor provides a number of context menus, all of
which are designed to make your work easier. Context menus help you perform tasks
quickly by making it unnecessary to search for a command on a menu or toolbar.
To create a new dialog box, right-click the Dialogs folder and then select New
Dialog from the context menu. You see a new dialog box added to the application.
Don’t worry too much about the actual use of dialog boxes yet, you will learn about
them in Chapter 12.
Properties
The Properties window shown in Figure 3.4 helps you configure dialog boxes and the
objects they contain using properties. A property is basically part of the description of an
object, such as the color of an apple, may be red, green, or yellow. Color is the name of
the property, and red, green, or yellow are the property values. Don’t worry too much
about properties now; you’ll discover them in Chapters 9 and 12. IDEA only enables this
window when you work with dialog boxes. Even though the Properties window can
appear at other times, it doesn’t have a use outside of modifying dialog boxes.
As with many other windows, the Properties window supports a context menu. When
working with a text property, you can right-click the text value and see the context menu
shown in Figure 3.5. These options help you perform the following tasks:
Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am
Understanding the Basics of the IDEAScript Editor 25
■ Undo: Reverses any changes you make to the property value.
■ Cut, Copy, and Paste: Performs the same tasks as the Cut, Copy, and Paste com-
mands for the Editor window. Essentially, you can cut, copy, or paste values in the
Properties window.
■ Delete: Removes the highlighted property value text. However, this option doesn’t
place the text on the Clipboard—the text is simply deleted, so you need to use this
option with care.
■ Select All: Highlights the entire property value. This is an exceptionally useful option
when the property value contains a lot of text.
At the top of the Properties window, you see two buttons. Click the first button if
you want to see a list of properties for the selected option by category. For example, if
you want to see all of the properties that affect the position of a dialog box on screen.
This sort order is helpful when you need to change a number of related properties at one
time. Click the second button when you want to see the properties listed in alphabetical
order. Using alphabetical order is handy when you remember the name of a property
you want to change and need to find it quickly.
Dialog Tools
The Dialog Tools window shown in Figure 3.6 contains a palette of controls you can
use to create a dialog box. Simply drag a control onto the dialog box window and drop
it. (Chapter 12 tells you more about working with dialog boxes.) This window only
appears when you work with dialog boxes. The Dialog Tools window doesn’t provide
any context menus.
Dialog Box Editor
The Dialog Box Editor window shown in Figure 3.7 is where you create the dialog boxes
you want to present to the user. IDEA supports a number of controls such as text boxes,
buttons, and labels. To draw a dialog box, you simply drag and drop the controls you
want onto the dialog box in the Dialog Box Editor. Chapter 12 describes this process
completely. For now, all you need to know is that IDEA takes care of many of the details
of creating a dialog box for you and all you really need to know is what you want the
user to see.
FIGURE 3.5 Use This Context Menu to Manipulate Text Values in the Properties Window
Discovering Diverse Content Through
Random Scribd Documents
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for
the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you
discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
1.F.5. Some states do not allow disclaimers of certain implied
warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,
the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.
Volunteers and financial support to provide volunteers with the
assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.
The Foundation’s business office is located at 809 North 1500 West,
Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws regulating
charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.
While we cannot and do not solicit contributions from states where
we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot make
any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Section 5. General Information About
Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
This website includes information about Project Gutenberg™,
including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookgate.com

More Related Content

Similar to Mastering IDEAScript with Website The Definitive Guide 1st Edition Idea (20)

PDF
(eBook PDF) Using MIS 9th Edition by David M. Kroenke
auwofle829
 
PDF
Micro Wave Computer Institute: Empowering Tech Futures, One Student at-a-Time
Micro Wave Computer Institute
 
PDF
Idea v9 product profile
AuditWare Systems Ltd.
 
PPT
Computer concepts
Imran Waris
 
PDF
Mta ssg soft_dev_individual_without_crop
marcelodelta
 
PDF
Essentials of MIS (Management Information Systems), 15th Global Edition Kenne...
azawixotzas
 
DOCX
assign - id = exprid - A B Cexpr - id + .docx
festockton
 
PDF
(eBook PDF) Using MIS 9th Edition by David M. Kroenke
reveykleebt3
 
PDF
(eBook PDF) Hands-On Database 2nd Edition by Steve Conger
okogiegwil
 
DOCX
bgloss.indd 312 11262015 74039 PM .docx
jasoninnes20
 
PDF
Database concepts 8th Edition David M. Kroenke
kargerjohmar
 
PDF
Microsoft Adonet Professional Projects Professional Projects 1st Edition Sanj...
kigexcr0854
 
DOCX
bgloss.indd 312 11262015 74039 PM .docx
richardnorman90310
 
PDF
Methods Of It Project Management 2nd Edition Jeffrey L Brewer
contejoernn7
 
PDF
IBM Big Data Beyond the Hype
Rick VARGAS
 
DOCX
But today, theyre n o t e n o u g h . D o y o u f i n d .docx
humphrieskalyn
 
PDF
Essentials of MIS (Management Information Systems), 15th Global Edition Kenne...
wakedkoutslg
 
PDF
Professional Microsoft Smartphone Programming 1st Edition Baijian Yang
uahpirsahrin
 
PDF
Excel.vba.for.dummies
Andragon
 
DOCX
BINDEXXML 06222012 184024 Page 402FFIRSXML 06.docx
AASTHA76
 
(eBook PDF) Using MIS 9th Edition by David M. Kroenke
auwofle829
 
Micro Wave Computer Institute: Empowering Tech Futures, One Student at-a-Time
Micro Wave Computer Institute
 
Idea v9 product profile
AuditWare Systems Ltd.
 
Computer concepts
Imran Waris
 
Mta ssg soft_dev_individual_without_crop
marcelodelta
 
Essentials of MIS (Management Information Systems), 15th Global Edition Kenne...
azawixotzas
 
assign - id = exprid - A B Cexpr - id + .docx
festockton
 
(eBook PDF) Using MIS 9th Edition by David M. Kroenke
reveykleebt3
 
(eBook PDF) Hands-On Database 2nd Edition by Steve Conger
okogiegwil
 
bgloss.indd 312 11262015 74039 PM .docx
jasoninnes20
 
Database concepts 8th Edition David M. Kroenke
kargerjohmar
 
Microsoft Adonet Professional Projects Professional Projects 1st Edition Sanj...
kigexcr0854
 
bgloss.indd 312 11262015 74039 PM .docx
richardnorman90310
 
Methods Of It Project Management 2nd Edition Jeffrey L Brewer
contejoernn7
 
IBM Big Data Beyond the Hype
Rick VARGAS
 
But today, theyre n o t e n o u g h . D o y o u f i n d .docx
humphrieskalyn
 
Essentials of MIS (Management Information Systems), 15th Global Edition Kenne...
wakedkoutslg
 
Professional Microsoft Smartphone Programming 1st Edition Baijian Yang
uahpirsahrin
 
Excel.vba.for.dummies
Andragon
 
BINDEXXML 06222012 184024 Page 402FFIRSXML 06.docx
AASTHA76
 

Recently uploaded (20)

PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Difference between write and update in odoo 18
Celine George
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Ad

Mastering IDEAScript with Website The Definitive Guide 1st Edition Idea

  • 1. Mastering IDEAScript with Website The Definitive Guide 1st Edition Idea download https://ebookgate.com/product/mastering-ideascript-with-website- the-definitive-guide-1st-edition-idea/ Get Instant Ebook Downloads – Browse at https://ebookgate.com
  • 2. Get Your Digital Files Instantly: PDF, ePub, MOBI and More Quick Digital Downloads: PDF, ePub, MOBI and Other Formats AppleScript The Definitive Guide Definitive Guides 1st Edition Matt Neuburg https://ebookgate.com/product/applescript-the-definitive-guide- definitive-guides-1st-edition-matt-neuburg/ The Leading Edge Manager s Guide to Success with Website Strategies and Better Practices 1st Edition Parmenter https://ebookgate.com/product/the-leading-edge-manager-s-guide- to-success-with-website-strategies-and-better-practices-1st- edition-parmenter/ Closure The Definitive Guide 1st Edition Michael Bolin https://ebookgate.com/product/closure-the-definitive-guide-1st- edition-michael-bolin/ Hadoop the definitive guide 1st Edition Tom White https://ebookgate.com/product/hadoop-the-definitive-guide-1st- edition-tom-white/
  • 3. Cassandra The Definitive Guide 1st Edition Eben Hewitt https://ebookgate.com/product/cassandra-the-definitive-guide-1st- edition-eben-hewitt/ DocBook 5 The Definitive Guide Walsh Norman https://ebookgate.com/product/docbook-5-the-definitive-guide- walsh-norman/ Dojo The Definitive Guide 1st Edition Matthew A. Russell https://ebookgate.com/product/dojo-the-definitive-guide-1st- edition-matthew-a-russell/ SharePoint 2007 The Definitive Guide 1st Edition James Pyles https://ebookgate.com/product/sharepoint-2007-the-definitive- guide-1st-edition-james-pyles/ Postfix The Definitive Guide 1st Edition Kyle D. Dent https://ebookgate.com/product/postfix-the-definitive-guide-1st- edition-kyle-d-dent/
  • 5. Chapter = Date: Feb 18, 2011 Time: 11:49 am
  • 6. Chapter = Date: Feb 24, 2011 Time: 12:45 pm Mastering IDEAScript
  • 7. Chapter = Date: Feb 24, 2011 Time: 12:45 pm
  • 8. Chapter = Date: Feb 24, 2011 Time: 12:45 pm Mastering IDEAScript The Definitive Guide JOHN PAUL MUELLER John Wiley & Sons, Inc.
  • 9. Chapter = Date: Feb 24, 2011 Time: 12:45 pm Copyright © 2011 by CaseWare IDEA Inc. All rights reserved. Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. IDEA® is a registered trademark of CaseWare International Inc. For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993, or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. For more information about Wiley products, visit our Web site at www.wiley.com. Library of Congress Cataloging-in-Publication Data: Mueller, John, 1958- Mastering IDEAScript: the definitive guide/John Paul Mueller. p. cm. Includes index. ISBN 978-1-118-00448-7 (pbk.); 978-1-118-01783-8 (ebk); 978-1-118-01784-5 (ebk); 978-1-118-01785-2 (ebk) 1. Auditing–Data processing. 2. Accounting–Data processing. 3. Scripting languages (Computer science) 4. Data structures (Computer science) I. Title. HF5667.12.M37 2011 657.028553–dc22 2010045246 Printed in the United States of America. 10 9 8 7 6 5 4 3 2 1
  • 10. Chapter = Date: Feb 24, 2011 Time: 12:47 pm Contents Preface xi Acknowledgments xvii CHAPTER 1 Introducing IDEAScript 1 Understanding Automation 1 Understanding How You Use Macros 3 Having Things Your Way 6 Considering Your Skills 7 Summary 8 CHAPTER 2 Creating Your First IDEAScript Application 9 Understanding the Macro Types 9 Opening the Visual Script Editor 11 Writing a Hello World Application 15 Building Your Application 19 Summary 20 CHAPTER 3 Understanding the Basics of the IDEAScript Editor 21 Working with Windows 21 Hiding and Viewing Windows 27 Working with Menus and Toolbars 29 Summary 37 CHAPTER 4 Designing Structured Applications 39 Understanding the Parts of an Application 40 Understanding the Methods Used to Create an Application 41 Using the Macro Recorder 45 Working with Subroutines and Functions 52 v
  • 11. Chapter = Date: Feb 24, 2011 Time: 12:47 pm vi Contents Making Your Code Easy to Read 56 Adding Your Application to a Toolbar or Menu 57 Summary 60 CHAPTER 5 Working with Data 63 Understanding Variables and Constants 63 Choosing a Data Type 67 Employing Operators 82 Formatting Data 85 Creating Custom Data Types 89 Summary 91 CHAPTER 6 Using Conditional Statements and Loops 93 Making Decisions Using the If . . . Then . . . Else Statement 93 Choosing between Options Using Select Case 95 Performing Tasks a Specific Number of Times with For . . . Next 99 Performing Tasks Using Conditions with Do Loop 102 Adding Error Trapping to Your Application 106 Redirecting Macro Flow Using GoTo 112 Summary 112 CHAPTER 7 Understanding IDEA Databases 115 Considering the Parts of a Database 115 Introducing the IDEA Database System 118 Opening a Database for Use 119 Checking the Database History 120 Obtaining Field Statistics 122 Setting Database Criteria 125 Indexing a Database 125 Sorting a Database 127 Modifying Database Comments 129 Committing the Database 131 Closing a Database 133 Summary 133 CHAPTER 8 Working with Databases 135 Adding One Database to Another Using Append Database 135 Comparing Two Databases Using CompareDB 138
  • 12. Chapter = Date: Feb 24, 2011 Time: 12:47 pm Contents vii Working with Keys 140 Exporting a Database Using ExportDatabase 145 Working with Fields Using Field 150 Working with Records 152 Working with Tables 157 Summary 164 CHAPTER 9 Considering the CaseWare IDEA Object Model 165 Considering the IDEA Object Model 165 Working with the Task Object Model 170 Summary 193 CHAPTER 10 Performing Mathematical Tasks 195 Performing Basic Math 195 Using Advanced Math 198 Employing Analysis 200 Summary 205 CHAPTER 11 Interacting with Arrays 207 Understanding How Arrays Work 207 Creating and Using Arrays 208 Copying Data between Arrays 212 Summary 213 CHAPTER 12 Creating Interactive Dialog Boxes 215 Creating Great Dialog Boxes 216 Using the Basic Controls 218 Obtaining the Visual Appearance You Want 232 Interacting with Dialog Boxes Using Code 235 Adding Pictures to Your Dialog Boxes 244 Summary 247 CHAPTER 13 Locating Information in Databases 249 Performing Searches Efficiently 249 Using the Built-in Search Features 251 Creating a Custom Search 268 Summary 269
  • 13. Chapter = Date: Feb 24, 2011 Time: 12:47 pm viii Contents CHAPTER 14 Importing and Exporting Data 271 Considering the Import and Export Features 271 Performing Data Extractions 283 Managing PDF Data 290 Managing Text Data 294 Managing Excel Data 306 Managing Access Data 310 Summary 315 CHAPTER 15 Working with Files 317 Considering the File Format 317 Using the File IO Features 318 Using External Variables 346 Summary 348 CHAPTER 16 Working with Other Applications 349 Considering IDEAScript and Visual Basic for Applications (VBA) Differences 349 Understanding the Word and Excel Object Models 350 Running Word from IDEA 351 Running IDEA from Excel 355 Summary 359 CHAPTER 17 Performing Data Analysis Tasks 361 Performing Stratification 361 Performing Summarization 367 Creating a Pivot Table 371 Employing Random Record Sampling Using RandomSample 374 Performing Gap Detection 376 Checking Distribution Using SystematicSample 378 Merging Databases 380 Summary 389 CHAPTER 18 Working with Charts and Graphs 391 Choosing the Correct Chart or Graph 391 Creating a Basic Graph 393
  • 14. Chapter = Date: Feb 24, 2011 Time: 12:47 pm Contents ix Defining Analytical Charts 399 Summary 405 CHAPTER 19 Defining Reports 407 Defining a Report 407 Outputting Data in PDF Format 412 Outputting Data in Word Format 414 Summary 418 CHAPTER 20 Considering Database Security 419 Considering Programmatic Data Security 419 Choosing the Correct Data Type 421 Validating Data 421 Protecting Dialog Boxes 427 Summary 428 CHAPTER 21 Debugging Your Application 429 Understanding the Kinds of Application Errors 429 Running and Stopping the Application 433 Using Breakpoints 434 Stepping through the Application 435 Using the Watch Window 438 Relying on Message Boxes 444 Summary 445 CHAPTER 22 Performing Project Management Tasks 447 Creating a Plan for Your Application 448 Keeping Track of Application Files 449 Working within a Group 450 Documenting Your Application 451 Summary 453 CHAPTER 23 Converting Visual Script to IDEAScript 455 Considering the Benefits of Using IDEAScript 455 Performing the Conversion 456 Making Changes and Saving the Result 458 Summary 461
  • 15. Chapter = Date: Feb 24, 2011 Time: 12:47 pm x Contents About the Author 463 About the Website 465 Index 467
  • 16. Chapter = Date: Feb 18, 2011 Time: 11:49 am Preface Most people want to perform tasks faster because, let’s face it, time is precious and you’d much rather spend your time doing something other than sitting at your desk waiting for the computer to complete a task. That’s where IDEAScript comes into play. By using IDEAScript, you can automate tasks. You can tell the computer to accomplish tasks and let you know when the work is finished. Mastering IDEAScript: The Definitive Guide is your window to IDEAScript. It helps you understand how IDEAScript works and how you can use it to do amazing things with IDEA, all without having to sit at your desk to observe the computer doing it. If that sounds interesting, read on! About This Book Mastering IDEAScript: The Definitive Guide is designed to help the complete novice develop the skills required to write simple applications using IDEAScript. The overall goal of this book is to make it possible for you to automate all of those tasks that you used to perform manually. Of course, you still have to start the task and interpret the results—even the best automation can’t do that for you. Automation is one of those terms that’s used a lot, but is never quite explained by anyone. For the purposes of this book, automation means that you’ll be able to write an application that follows a procedure you create—the same procedure you use every day to perform tasks. It’s just that simple. Instead of you spending time filling in forms and answering questions, you give all the required information to the computer as part of your application and let it do the work. The result is that you become more productive and spend less time sitting in that chair bored stiff. The techniques in this book go further, though. Let’s say that you have an assistant and want the assistant to help with some of the work. You can write an application that asks the assistant very simple questions and then automates the rest of the task for the assistant so you don’t have to help as much. The result is that your assistant also becomes more capable and efficient. By using forms and other techniques described in this book, you make it possible for less-skilled helpers to perform a task using the same approach you do, making the result look the same as if you had done it. IDEAScript provides a wealth of capabilities and Mastering IDEAScript: The Definitive Guide tells you all about them. For example, you might want to remotely control an external application without having to work too hard to do it. Using IDEAScript, you xi
  • 17. Chapter = Date: Feb 18, 2011 Time: 11:49 am xii Preface create the code required to perform the manipulation one time, and then let the computer perform the task for you from then on. Finally, this book tells you about a few unique tasks you can perform using IDEAScript. Do you have an external file that doesn’t quite want to import using the nor- mal techniques provided by IDEA? Well, you can define an application using IDEAScript that makes it possible to import just about anything into IDEA. This book tells you how to accomplish this kind of task. How This Book Is Organized This book discusses IDEAScript starting from simple topics and moving on toward more complex topics. The initial topics also focus on tasks that you perform more often. As you progress through the book, you start to discover tasks that are less used, but extremely useful in many situations. In fact, this book may present you with some new ways of accomplishing tasks that you hadn’t considered when using the GUI. Here’s a list of the chapters in this book: ■ Chapter 1: Introducing IDEAScript: This chapter helps you understand what automation can help you do. It presents you with the concepts behind using macros and helps you set reasonable goals for working with IDEAScript. ■ Chapter 2: Creating Your First IDEAScript Application: This chapter begins by helping you understand the two kinds of macros you can create with IDEA: IDEAScript and Visual Script. It then presents you with the editors used to create each macro type. This is also the first chapter where you write an application—something very basic that you can use as a starting point for other applications in the book. ■ Chapter 3: Understanding the Basics of the IDEAScript Editor: This chapter provides you with the details of using the IDEAScript Editor. ■ Chapter 4: Designing Structured Applications: This chapter helps you under- stand the basic parts of an application. You discover how to write code quickly and efficiently by copying it from the help file or from IDEA’s history. In addition, you learn how to use the Macro Recorder to create complete applications without writing any code at all. Finally, this chapter shows you how to add your application to an IDEA toolbar or menu so that you can access it quickly. ■ Chapter 5: Working with Data: This chapter helps you understand what variables and constants are (essentially they’re a sort of storage container) and how to use them within your application. This chapter introduces data types, a method of categorizing data stored in variables and constants. Finally, you discover some basic techniques for working with variables and constants. ■ Chapter 6: Using Conditional Statements and Loops: This chapter begins build- ing on the basic structures you learned about in Chapter 4. In this case, you learn how to perform tasks conditionally using any criteria you want and how to perform tasks multiple times (either a specific number of times or until the application meets certain specifications). This chapter also helps you understand what to do about errors that occur in your application.
  • 18. Chapter = Date: Feb 18, 2011 Time: 11:49 am Preface xiii ■ Chapter 7: Understanding IDEA Databases: This chapter introduces databases from an IDEAScript perspective. You discover how databases are put together and learn how to open databases for processing. After the introductory material, this chapter provides you with the information you need to perform basic tasks, such as indexing, sorting, and closing your database. ■ Chapter 8: Working with Databases: This chapter takes the next step after basic database management. You discover how to perform some intermediate level tasks, such as comparing databases and exporting them. Finally, this chapter shows you how to work with fields, records, and tables in a database. ■ Chapter 9: Considering the CaseWare IDEA Object Model: This chapter intro- duces you to the concept of objects, which are a representation of something in your application. Think of objects as they appear in the real world and you have the basic idea. Once you have the basics of objects down, this chapter introduces you to a number of IDEAScript objects, especially those used to perform tasks. ■ Chapter 10: Performing Mathematical Tasks: This chapter helps you understand how to perform math tasks using IDEAScript. You’ll also see details on using a couple of the analysis-related tasks provided by IDEA. ■ Chapter 11: Interacting with Arrays: This chapter demonstrates how to use arrays, which provide a method of storing like or associated values together for easy access. ■ Chapter 12: Creating Interactive Dialog Boxes: This chapter presents techniques for working with complex dialog boxes. IDEAScript lets you create dialog boxes of any complexity so that you can ask the user questions, have the user fill out forms, or interact with the user in other ways. As part of this chapter, you learn how to use the various graphical elements used to create dialog boxes. ■ Chapter 13: Locating Information in Databases: This chapter helps you learn how to find information within databases. These search techniques can make it quite easy to find any data within the database, even if you aren’t quite sure what you’re trying to find. IDEA makes it quite easy to perform complex searches without a lot of work on your part—IDEAScript makes things even easier by automating some tasks associated with common searches. ■ Chapter 14: Importing and Exporting Data: This chapter shows you how you can obtain data from other applications and send IDEA data to other applications. The ability to import and export data is essential in today’s world of connected computers. You want to have a number of solutions available to make data accessible for further analysis or for sharing with other people. ■ Chapter 15: Working with Files: This chapter describes how to work with external files of all types. You can use external files to store other information or import data from external files that IDEA might not support directly. In addition, you can use external files to hold configuration information or even use them to log application errors. In short, external files are really important when creating moderately complex IDEAScript applications. ■ Chapter 16: Working with Other Applications: This chapter describes how to make other applications work with IDEA in a number of ways. In this chapter, you discover specifically how to use IDEA with both Microsoft Word and Microsoft Excel, but the techniques shown will work with other applications, too. Once you
  • 19. Chapter = Date: Feb 18, 2011 Time: 11:49 am xiv Preface complete this chapter, you can create multi-application scenarios and automate data manipulation tasks even further. ■ Chapter 17: Performing Data Analysis Tasks: This chapter discusses advanced database manipulation tasks that you may not use very often, but will find essential to accomplish certain goals. The examples in this chapter discuss advanced database manipulation tasks such as working with pivot tables and finding gaps within data sequences. ■ Chapter 18: Working with Charts and Graphs: This chapter describes how to create graphical presentations of data within a database. Graphics are exciting and usually the best way to present complex information. In addition, by using charts and graphs, you can help others see patterns in data and present a specific message with your data that isn’t possible using other means. ■ Chapter 19: Defining Reports: This chapter describes how to create nicely format- ted reports using database data. In many cases, the way you present data will affect how the viewer receives it, so this chapter is essential if you want to create output with a certain level of fit and finish. ■ Chapter 20: Considering Database Security: This chapter discusses the difficult topic of security in a very simple manner. When you finish this chapter, you’ll be able to create a relatively secure application without a lot of work. Because security is such an important topic today, you’ll want to read this chapter if you plan to share your application with anyone else or if you routinely work on sensitive data. ■ Chapter 21: Debugging Your Application: This chapter presents methods for find- ing errors in your application and fixing them. Most applications have errors at some point in their lifetime. Fixing these errors makes the application more reliable, easier to use, more efficient, and definitely a pleasure to work with as well. ■ Chapter 22: Performing Project Management Tasks: This chapter helps you understand how to work with your application in a larger company environment. In many cases, you’ll find that your application becomes popular after you show it to other people. In other cases, you might find yourself working with other people to create a database management solution in the form of an application. It’s important to know how to work with IDEAScript in a group environment. ■ Chapter 23: Converting Visual Script to IDEAScript: This chapter demonstrates how to convert your Visual Script macro into an IDEAScript macro. Visual Script can be a little limiting because you don’t have good control over every feature the application can do. Using IDEAScript is more flexible and makes it possible to perform advanced database management. What You Need to Use This Book This book doesn’t assume that you have any knowledge about programming or have any programming skills. In fact, it assumes that you don’t have either programming knowledge or skills. However, you do need to know the basics of working with Windows and you must at least be familiar with using IDEA. This book doesn’t tell you how to
  • 20. Chapter = Date: Feb 18, 2011 Time: 11:49 am Preface xv perform tasks such as working with a mouse and it assumes that you know how to use IDEA to perform at least simple tasks such as extracting a database. You won’t need any special equipment or software to use this book. All you need is your copy of IDEA. If you want to perform some advanced tasks, such as working with other applications, you do need the other applications. For the purposes of this book, if you have a copy of Microsoft Excel and Microsoft Word handy, you’ll be able to work with the examples in Chapter 16. Conventions Used in This Book This book doesn’t use many conventions. It emphasizes simple text for most purposes. You’ll see special terms in italics on first use, followed by a definition of that term. Website URLs, all code, file/folder names, and file/folder locations appear in Courier New font type. In procedural text, Bold is used for user interface elements and text you need to enter. This book also provides three special kinds of text as follows: ■ Notes are additional information that doesn’t fit within the flow of text. You might find the information useful because it augments the information found in the para- graphs. In some cases, notes provide sources of additional information or help you understand a concept more clearly. In almost every case, you can skip a note without losing any essential information, but whenever possible, stop to read the notes to get the special information they contain. ■ Tips provide you with insights on how to do something more efficiently, faster, or with less work. Often, tips provide best practices for working with IDEAScript. Even though tips aren’t essential reading, you’ll want to read tips whenever possible to get the most out of this book and IDEAScript. ■ Warnings tell you about things you should avoid doing. In many cases, warnings tell you about situations that will cause data loss or at least cause your application to crash. You should always pay special attention to warnings. In fact, you should note warnings that especially affect you and go back to them later when writing your application. Never skip warnings. In addition to these three special kinds of text, this book does use a special format for code. You’ll see both code snippets (short sections of incomplete code) and code listings (longer sections of complete examples) in the following format: ' This is a comment. MsgBox This is code
  • 21. Chapter = Date: Feb 18, 2011 Time: 11:49 am
  • 22. Chapter = Date: Dec 22, 2010 Time: 11:45 am Acknowledgments Thanks to my wife, Rebecca, for working with me to get this book completed. I really don’t know what I would have done without her help in researching and compiling some of the information that appears in this book. She also did a fine job of proofreading most of my rough draft. Matt Wagner, my agent, deserves credit for helping me get the contract in the first place and taking care of all the details that most authors don’t consider. I always appre- ciate his assistance. It’s good to know that someone wants to help. Finally, I would like to thank Andrew Coles, Vanessa Muckleston, Andy Sloman, Christine Dahlgren, and the rest of the editorial and production staff for their assis- tance in bringing this book to print. It’s always nice to work with such a great group of professionals. xvii
  • 23. Chapter = Date: Dec 22, 2010 Time: 11:45 am
  • 24. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am CHAPTER 1 Introducing IDEAScript You’ve just completed the same analysis for the fiftieth time and wonder if there isn’t an easier way to get the job done. Yes, using IDEA is fast and easy, but there must be a way to make things faster still. Of course, you can try to find some way to improve your own efficiency or try to perform the analysis a few less times, but there are limitations to that approach and they often require additional work on your part. Why not have someone else, or more importantly, something else, do the work for you? That’s what scripting is all about. This book tells you everything you need to know in order to make the computer work for you, rather than you work for it. In this chapter, you discover just how much benefit you can obtain by spending a few hours learning to tell the computer what to do. As you go through this chapter, you learn how to: ■ Understand how automation can make working with IDEA easier. ■ Consider the ways in which you can use automation. ■ Decide which forms of automation to pursue first. ■ Determine how your skills can help you use automation best. Understanding Automation The computer community will use all kinds of technical terms you don’t understand to describe scripting. In fact, the word scripting itself sounds foreign and technical. What this book really describes is automation, and you use automation every day. When you go to the gas station and fill your car with gas, you’re using automation. After all, you don’t have to pump the gas from the storage tank yourself—you let the gas pump do the work. When you go to the store, the cashier uses a cash register and scanner to total the amount of money you owe for food—no one uses pen and paper any longer. The cashier is employing yet another kind of automation. You get home and click a button—the garage door opens. The garage door is yet more automation. In fact, it won’t take long for you to find automation everywhere in your life. Why not automate IDEA as well? All forms of automation rely on some kind of control. When you pump gas, you press buttons or tell the gas pump to begin pumping in some other way. Controls inside the gas pump automatically stop the flow of gas. At the store, the act of clicking a few keys on the 1
  • 25. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am 2 Mastering IDEAScript cash register and scanning the items provides control over the adding process. The garage door opens when you click a button on its control. Likewise, scripting is a form of control over IDEA that you exercise using special words and phrases. As you can see, scripting isn’t anything new—you’ve already been exercising control over things all your life. Scripting is a little more complex than pumping gas, scanning groceries, or opening a garage door, but it also does a lot more for you. The complexity comes in the form of a procedure you must write. Of course, you’ve already been doing that task for a long time too. Any time you have someone stay at your house to water the plants or ask a coworker to perform a task, you write a procedure for them—you tell them what you want them to do and when to do it. Automating tasks in IDEA is no different. You use control words to write a procedure that IDEA performs for you. This procedure is called a macro and you use macros to tell IDEA how to automate tasks for you. The following sections describe the benefits of automating tasks in IDEA in more detail. How Does Automation Benefit You? The main reason you’re reading this book is to gain a new skill that benefits you in some way. After all, why bother to learn something that isn’t going to help you in some way? The following list outlines the benefits you should consider as you read this book: ■ You can perform work faster. ■ The results you obtain will contain fewer errors. ■ Any analysis is performed more consistently. ■ Your work becomes more interesting because you can focus on unique tasks. ■ You don’t have to remember how to perform complex procedures because the procedure is contained in the macro. ■ It’s easy to justify actions you take based on the consistency of your macros. Tip There are many ways in which learning to script will benefit you that this book can’t cover. For example, if you know how to script and none of the other people in your organization do, you’ll likely find that your job security is greater and you’ll receive promotions more often. Many people are afraid of scripting, but you’re brave enough to give it a try. You’ll find that scripting is actually quite easy and straightforward as the book progresses. How Does Automation Benefit Others? Believe it or not, your new skill will also benefit others. When you know how to create macros, you become an important asset to others who don’t know how to perform this task or simply want to benefit from what you’ve learned. The following list outlines the benefits others will receive from your macros:
  • 26. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am Introducing IDEAScript 3 ■ People can use your macros to obtain the same benefits you obtain. ■ Your organization can perform analysis in a consistent fashion, making the analysis easier for everyone to understand. ■ The reports and other output you generate will make it easier to see trends. ■ It’s possible to create a workflow (a standard method of performing a task) for the entire organization. ■ A single employee absence won’t mean that work stops. Best Practices for Using Automation Given the benefits of automation, you may be tempted to use automation all the time. However, automation isn’t always the answer; you must use some discretion in employing automation. For example, you wouldn’t want a completely automated plane—having a pilot is important for safety reasons. The following list provides best practices you should follow when considering automation: ■ Always choose tasks that you’ll repeat. The more often you need to repeat a task, the better a candidate it is for scripting. ■ Always choose well-defined tasks. In order to write a procedure, you must under- stand the task completely. ■ Always plan your macros carefully and completely so that the procedure works as you expect it should. The planning process begins when you separate tasks that will automate well from those that won’t. ■ Whenever possible, create macros that everyone in your organization can use, rather than focus on macros for personal needs. When everyone benefits, the time you use to write the macro is paid off faster. ■ Whenever possible, write down the procedure you use and then test the procedure carefully. This act is no different from any other automation you use. For example, you’d expect that a cashier would receive training that relies on written and tested procedures. ■ Avoid writing macros that are too complicated for your current skill level. Discover scripting a step at a time. As this chapter progresses, you’ll learn tricks you can use to avoid getting in over your head. ■ Never assume that the macro you write for your machine will work on another machine until you test it on that machine. Just as a procedure for one cash register may not work on another, you can’t assume your macro will work on every machine. As the book progresses, you’ll discover methods for testing your macros to ensure they work as anticipated. Understanding How You Use Macros Macros, the written procedures used for scripting, can perform all kinds of tasks. In fact, the number of tasks you can perform is literally limited only by your imagination. Some
  • 27. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am 4 Mastering IDEAScript people have written games and done all kinds of other interesting things with macros. Of course, most people use macros for more practical purposes. The following sections describe some of the common tasks you can perform with macros. Interacting with Databases The task you perform most often in IDEA is interacting with a database of some sort. From your perspective, you’re performing a data analysis. However, from the perspec- tive of the IDEA application, you’re manipulating data found in databases. Whatever the perspective, being able to get the data you need is important, and it’s often repeti- tious. Macros that help you get the information you need are probably the singular most important kind of macro that you can write. Starting with Chapter 7, you begin working with databases and discover that no matter the source, databases often have similar needs and requirements when writing a macro. Chapter 8 shows you how to interact with databases, while Chapter 9 describes the model IDEAScript uses to work with databases. When working with IDEAScript, you can access two kinds of databases: ■ Internal IDEA databases ■ External databases such as SQL Server This book helps you work with both kinds of databases. The external database information starts in Chapter 14 and you see some advanced techniques in Chapter 17. In fact, you’ll find that you can access data in all its forms, even an Excel document (see Chapter 16) or a text file (see Chapter 15) on your hard drive. Procedures that might seem complex when you perform them by hand suddenly become easy and fast when you use a macro to perform them. Customizing the IDEA Interface You can attach (bind) your macros to the IDEA interface. By adding buttons that access your macros, you can customize the IDEA interface to meet your specific needs. Your macros, in essence, become part of the IDEA application and make using IDEA easier. Chapter 4 tells you how to add your macros to the IDEA application interface. Performing Calculations Analysis normally includes performing comparisons and employing equations to calcu- late specific values. Of course, you want to be sure you perform the right comparisons and obtain the correct calculations. Fortunately, your computer is far faster and signifi- cantly more accurate in both comparisons and calculations, so this is one area that you really should let the computer take care of for you. Chapter 6 tells you how to perform comparisons, while Chapter 10 addresses math requirements.
  • 28. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am Introducing IDEAScript 5 Designing New Application Features Binding macros to the IDEA interface isn’t the only kind of customization you can do. In addition, you can create your own interface elements as dialog boxes. You can use dialog boxes for two purposes: ■ To output information to the user. ■ To obtain input from the user. You can do everything from telling the user of your macro the status of a calculation to asking the user for the name of the database they want to use for analysis. Chapter 12 shows you how to create interactive dialog boxes that let you do amazing things. Importing and Exporting Data Most businesses need to exchange data in some form or another. Depending on the kind of analysis you perform, you might have to obtain data from many different businesses. Unfortunately, businesses use different applications and different methodologies to store information. Trying to remember all of the methods used to access this information can prove daunting. Fortunately, macros make fast work of importing and exporting data as needed. Chapter 14 describes the resources that IDEAScript provides for importing and exporting data. Data comes in many forms. Normally, you’ll work with databases, but that isn’t always the case. Besides the database chapters in this book, you can discover how to interact directly with files in Chapter 15 and Excel in Chapter 16. Controlling Other Applications One of the most useful ways to use macros is to control other applications. It’s incon- venient and time wasting to have to interact with more than one application at a time. If you can perform at least part of that work by using a macro, you save time and can maintain a focus on IDEA. Nothing limits the kinds of applications you can control. If you want to start a copy of Excel and use it to create a chart or graph, you can do so with the information found in Chapter 18. Chapter 19 shows how to control other applications, such as Word, to create reports. Warning Never execute macros unless you know what task the macro performs and that the macro is safe to use. Executing a macro that you don’t know about can cause damage to your data or produce unreliable results. In addition, macros can cause significant problems on your machine, such as installing a virus. The macros that are completely safe are the ones you understand and obtain from a reliable source.
  • 29. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am 6 Mastering IDEAScript FIGURE 1.1 The Open Dialog Box Lets You Choose a Macro File on Your Hard Drive You’re probably thinking that controlling another application sounds too hard, but it really isn’t. The first exercise in this book is to execute a macro that starts a copy of Internet Explorer. This macro actually comes with your copy of IDEA. Just follow these steps. 1. Open IDEA and select Tools Macros Open. This command displays the Open dialog box shown in Figure 1.1. IDEA automatically selects the Samples folder for you, which contains a macro named ie.iss. If you don’t see the Samples folder, you can find it by locating My DocumentsIDEASamples in the Look in field. 2. Select ie.iss and click Open. IDEA opens the IDEAScript Editor shown in Figure 1.2. Don’t worry about the editor for now; Chapter 2 tells you how to work with it. The text you see in the right Editor pane is a macro and we’re going to execute it. 3. Click Run Script. The Run Script button is the blue right-pointing arrow on the toolbar. You can also press F5. IDEA executes the macro and opens a copy of Internet Explorer for you. Congratulations! You just executed your first macro. 4. Close Internet Explorer. Select File Exit in the IDEAScript Editor. Having Things Your Way For many people, the idea of scripting can become overwhelming. At first, you can’t quite accept that you can actually write macros, but then, once you get used to the idea, all kinds of macro ideas start coming to mind. It’s nice to have things your way. Once
  • 30. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am Introducing IDEAScript 7 FIGURE 1.2 The IDEAScript Editor Lets You Write Macros That You Can Save to Disk you discover the full capability of scripting, you’ll find that you can do a host of things that you didn’t think were possible in the past. Of course, that list of ideas can become a burden, too. Make sure you write your ideas down because it’s all too easy to forget something you want to do. Even if you don’t know how to write the macro today, write it down. As you work with IDEAScript, your skills will improve and today’s impossible task will become quite possible tomorrow. Make sure you prioritize your list. Use these criteria for prioritization: ■ Skill Level: Your skill level determines the macros you can create today. ■ Existing Knowledge: Macros that play to knowledge you already possess, say a math macro if you’re already a math expert, should be a priority. ■ Pressing Need: Personal or organizational needs can act as a great motivator to finish the macro. Some people try for a short time and then give up—finishing the macro is the only way to build the knowledge you need. ■ Interest: Some projects are definitely more interesting than others. It’s more likely that you’ll finish a macro that interests you, so be sure to tackle these macros first. Considering Your Skills Even though macro writing is like many other things you’ve already done and is basically writing a procedure for IDEA to follow, it’s still a skill. As you write more macros, you’ll
  • 31. Chapter = c01 Date: Feb 17, 2011 Time: 10:13 am 8 Mastering IDEAScript learn more about the IDEAScript language and be able to create procedures that are more complex than those you create at first. The best way to learn scripting is to start slowly and discover new commands one at a time until you become proficient. Some of the skills you already possess will help as you discover IDEAScript. For example, if you already have solid math skills, you’ll find that writing macros that perform math tasks is significantly easier. You may even want to focus on math-related macros when you first begin scripting. Some people already know quite a bit about databases, so working on database-related macros is easier. Don’t force yourself to start out with something too difficult—ease into scripting. You should create some goals for yourself based on the scripting needs you discover as you work with IDEA. Put these goals on your To Do list—the same as you would anything else you want to learn. When you have a little additional time or you’re waiting for another task to complete, take some time to learn a new IDEAScript command and then begin employing it in your macros. It won’t be long before you’ll be writing complex macros without any trouble at all. No one’s asking you to memorize anything. The purpose of this book is to act as your memory. As you work through the book, you’ll discover that IDEA provides a number of other useful aids to make writing macros easier. Writing macros should be something you do to improve your work experience, not ruin your mood. Summary This chapter has started you on the road to a new kind of experience—scripting. The most important idea to take from this chapter is that anyone can write a macro as long as they fully understand the task at hand. While not every task is suitable for automation, many tasks are and you should make full use of this capability in IDEA to reduce your workload. The macros you create help both you and everyone else in your organization, so writing good macros is essential. One of the most important aspects of using automation is to employ it correctly. Of course, only you can decide when automation applies. Before you go to the next chapter, consider a few places in which automation will help you and your organization. Using the information in this chapter, write down the pros and cons of using automation for the tasks you define. Present your list and reasoning to other people and see if they agree that automation is the right choice for the tasks you list. This exercise will save you considerable time trying to automate tasks that you really shouldn’t automate. Now that you have a list of tasks you want to automate, Chapter 2 takes the next step and begins to show how to create macros. Of course, your first macros will be very simple. You want to make scripting fun and easy to perform, so these initial steps are important. The macro in Chapter 2 is functional and you can even show it off to your friends. However, you’ll create significantly more interesting macros as the book progresses.
  • 32. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am CHAPTER 2 Creating Your First IDEAScript Application An IDEAScript application is a group of one or more macros that perform a specific task, such as a particular kind of analysis on a database. The application can contain dialog boxes and other user interface features that make it possible to interact with the user and create a more flexible result. You can even compile your IDEAScript application to execute it at the command line without ever opening IDEA. Many people experience a mental block when they attempt to perform some tasks. For example, most people have a hard time starting to write something when faced with a blank page. Writing an application can be the same way. Many people look at the blank editor screen and simply don’t know what to do next. Just as book authors use a number of tricks to avoid the blank page, you can use some tricks to avoid the blank editor screen. This chapter helps you get started by showing you how to create simple applications. Often, you can start with a simple application and keep adding to it until the resulting application does everything you need. Before you can create a macro, however, you need to know how to perform tasks such as opening the editors and interacting with them in a meaningful way. In fact, you will learn that IDEA actually provides two different editors and you need to decide which editor to use for your application. IDEA also lets you create an executable program—one that you can start from within Windows without starting IDEA. Executa- bles are really interesting because they let you start macros without starting the editor every time. Understanding the Macro Types A macro is always a method of creating a procedure using special control words. You execute the macro by telling IDEA to perform the procedure. However, IDEA provides two different methods for creating a macro. The first, IDEAScript, is more powerful and flexible because it lets you work with the control words directly. The second, Visual Script, is easier because you tell IDEA what you want to do using a graphical interface 9
  • 33. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 10 Mastering IDEAScript and then IDEA creates the control words for you. The following sections describe each macro creation method in more detail. Considering IDEAScript IDEAScript provides you with the ultimate in flexibility when creating macros for IDEA. When working with IDEAScript, you can control the entire IDEA object model, work with dialog boxes, interact with the operating system, and even control other applica- tions. However, with this kind of power comes a certain level of complexity. Don’t let the complexity overwhelm you—take things slowly and you’ll find that it’s quite man- ageable. After all, everyone who’s ever written a macro has started out knowing nothing about performing this task. Even so, it will require a little time to learn how to use IDEAScript. You select IDEAScript when you want the best control over your application and need to perform significant tasks. IDEAScript is the right tool for anyone who has time to learn the special control words used to communicate with IDEA. Anyone reading this book falls into that category. You’ve already shown your interest in having the additional power over IDEA by reading this book. Considering Visual Script Visual Script provides a graphical method of creating a macro. You essentially describe what you want to see and IDEA provides it for you. Visual Script is very good for creating a macro for repeating tasks. For example, you can use it to create a macro that imports a file, runs some tasks to analyze data, and then provides results where the auditor takes over. Using Visual Script is incredibly easy, but it also limits what you can do in a significant way. For example, you can’t create a message box describing the result of executing a task directly. You save Visual Script macros as .vscript files. One of the more important Visual Script limitations is that you can’t run a Visual Script macro on IDEA Server. IDEA Server allows the users to connect to a server and run tasks on a server farm. Consequently, Visual Script isn’t a very good solution for larger enterprises. It’s possible to use Visual Script as a method for starting an IDEAScript application if you want to completely avoid the blank page issue. All you do is create the basics of your application using the Visual Script Editor and then convert the Visual Script macro to an IDEAScript macro. Chapter 23 explains how to convert Visual Script macros to IDEAScript macros. You aren’t completely without resources when working with Visual Script. For exam- ple, you can use macros (either IDEAScript or Visual Script) that you or someone else creates using IDEAScript. Consequently, it’s possible to use Visual Script as a means of gluing modules together—to hide complexity from view. With the right coding tech- nique, you can obtain the simplicity of Visual Script matched with the flexibility of IDEAScript.
  • 34. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am Creating Your First IDEAScript Application 11 Note You can’t use macros that require any sort of input information other than the infor- mation that’s available from a database or other external source. When you insert a macro in Visual Script, the macro is executed in its entirety. Consequently, any macros you use within Visual Script must be self-contained modules (black boxes) that require nothing on the part of the individual using it. Visual Script may not be the option of choice for you, but it could be an option for less skilled workers. You can create IDEAScript modules that others put together as needed to perform tasks in your organization. Consequently, you shouldn’t view Visual Script from the limited perspective of a personal tool. Opening the Visual Script Editor Before you can create a Visual Script macro, you must open the associated editor. Start IDEA and then select Tools Macros New Visual Script. You see the Visual Script Editor shown in Figure 2.1. FIGURE 2.1 The Visual Script Editor Lets You Create Visual Script Macros
  • 35. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 12 Mastering IDEAScript FIGURE 2.2 Choose a Database You Want to Use Unfortunately, the display looks a bit blank, but that’s easily fixed. To begin a new macro, simply open a database or select a macro you want to execute. For the purpose of this example, let’s assume you want to find all of the customers in the Sample- Customers database that have a credit limit equal to or greater than $10,000.00. The following steps show you how easy it is to create the macro. 1. Select Task Insert File Open Database. You’ll see the Select Database dialog box shown in Figure 2.2. This dialog box shows all of the databases that you can access, which are the sample databases when you first install IDEA (found in your current working folder). 2. Select the database you want to use (Sample-Customers in this case) and click OK. IDEA closes the dialog box and adds an entry for the database to the Visual Script Editor. Now that you have a database open, you can do something with it. For the purposes of the example, we’ll create an indexed extraction. 3. Select Task Insert Data Extractions Indexed Extraction. You’ll see the Indexed Extraction dialog box shown in Figure 2.3 (which has already been filled out in the screenshot). 4. In the Field box, select CREDIT LIM. In the Value is fields, select = and then type 10000. In the File name field, type 10K Customers. Each of these actions defines part of the task you want performed on the Sample-Customers database. In this
  • 36. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am Creating Your First IDEAScript Application 13 FIGURE 2.3 Tell IDEA What You Want to Do with the Database case, you’re telling IDEA to extract all of the records in the Sample-Customers database that have a value equal to or greater than 10000 in the CREDIT LIM (credit limit) field and place them in the 10K Customers database. 5. Click OK. IDEA will display a dialog box asking whether you want to perform the task now. Click No. We’ll run the task later. Now, at this point, you’ll probably want to close the Sample-Customers database because you don’t need it anymore. 6. Select Task Insert File Close Database. Again, IDEA will ask whether you want to perform the task now. Click No. At this point, you should have a procedure completed like the one shown in Figure 2.4. That’s all a macro is really—a procedure that you define for IDEA to perform. Note The reason the task message appears is that you may need to program a task based on the output of a previous task. This feature allows you to selectively run only a single task at a time—something that you can’t do using IDEAScript. Let’s try executing the macro. Select Run Run and you’ll see the Sample- Customers database open, IDEA will create the required extraction, and then you’ll see the Sample-Customers database close. At the bottom of the Visual Script Editor window, you’ll see “The Visual Script has completed without any errors.” To save the macro so you can view it later, select File Save. You’ll see the Save Visual Script As dialog box. Type a name, such as 10K Customers, in the File name field and click Save. Select File Exit to close the Visual Script Editor window. To see the results of the macro, double-click the Sample-Customers10K Customers database entry in the File Explorer window. You’ll see the output shown in Figure 2.5. Of course, the question now is whether the macro actually produced code. If you convert this macro using the process described in Chapter 23, you’ll get the macro shown in Listing 2.1.
  • 37. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 14 Mastering IDEAScript FIGURE 2.4 The Completed Macro Is Simply a Procedure FIGURE 2.5 Seeing the Output Tells You That the Macro Worked
  • 38. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am Creating Your First IDEAScript Application 15 LISTING 2.1 Output of the 10K Customers Macro Sub Main Call IndexedExtraction() 'Sample-Customers.imd End Sub ' Data: Indexed Extraction Function IndexedExtraction Const WI_IE_NUMFLD = 1 Const WI_IE_CHARFLD = 2 Const WI_IE_TIMEFLD = 3 Set db = Client.OpenDatabase(Sample-Customers.imd) Set task = db.IndexedExtraction task.IncludeAllFields task.FieldToUse = CREDIT_LIM task.FieldValueIs2 WI_IE_GTEQUAL, 10000.00, WI_IE_NUMFLD dbName = 10K Customers.imd task.OutputFilename = dbName task.PerformTask Set task = Nothing Set db = Nothing Client.OpenDatabase (dbName) End Function It isn’t important that you understand the code shown in Listing 2.1 right now. In fact, after you’ve discovered more about IDEAScript, you can come back to this listing and read it with ease. What’s important is to know that creating a macro using the Visual Script Editor produces real code that you can modify later. Writing a Hello World Application You’ve probably wanted to write your first IDEAScript macro from the beginning of this chapter. Well, the wait is over. To begin this section, select Tools Macros New IDEAScript. You’ll see the IDEAScript Editor shown in Figure 2.6. Notice that IDEA automatically starts a macro for you so that you don’t face a blank page. The keyword Sub is short for subroutine. A macro consists of one or more subrou- tines. You must tell IDEA where the subroutine starts and ends. Placing Sub as the first word on a line always starts a subroutine. The End Sub keyword combination shows the end of the subroutine. The word Main is the name of the subroutine. You must always provide a name for the subroutines you create. The left side of the display contains the Project window, while the right side contains the Editor window where you type the code for your macro. Now that we’re ready for that first macro, the following sections help you create your first macro and show it off to your friends.
  • 39. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 16 Mastering IDEAScript FIGURE 2.6 The IDEAScript Editor Is Where You Type the Code for the Macros You Want to Create Typing in the Editor Window You type code words into the Editor window just as you would a word processor doc- ument, spreadsheet, or other editor. When you create a macro, you place the text you type between the Sub and End Sub lines in the window. This placement tells IDEA that the words you’ve typed are part of a procedure. Fortunately, you don’t have to go it alone when you use IDEAScript, because the Editor window comes with several aids. The first is IntelliSense. When you type some- thing, the Editor window helps you out by telling you about the additional information you can provide as a tooltip. Figure 2.7 shows a typical example of IntelliSense informa- tion. Don’t worry about the other aids for right now, you’ll find them discussed in later sections of the book. For this example, type MsgBox(“Hello World”). The MsgBox function (a kind of command) tells IDEA to display a message box that contains the words Hello World. It’s a simple example that programmers have used throughout history when learning IDEAScript or another language. Don’t worry too much about the specifics of the code FIGURE 2.7 IDEA Provides Help on What to Type Next When You Begin Typing a Function Name
  • 40. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am Creating Your First IDEAScript Application 17 FIGURE 2.8 The First Macro Displays a Message Box With Hello World in It for now. The code is a little hard to read as is, so add three spaces in front of MsgBox to show that Sub Main holds one procedural step that displays a message box. Your code should look like this: Sub Main MsgBox(‘‘Hello World‘‘) End Sub It’s time to try your first macro. Select Debug Run or simply press F5. You see a message box like the one shown in Figure 2.8. Isn’t it exciting to see the first macro run? As you can see, it doesn’t take very much to boss IDEA around. Click OK to remove the dialog box. Saving Your Macro The macro you created exists only in memory right now. Just like your other documents, you must save the macro to disk to reuse it. IDEA will remind you to save the macro if you haven’t done so already. To save your macro, select File Save, click the Save toolbar button, or press Ctrl+S. In all three cases, you see the Save As dialog box shown in Figure 2.9. Use the Save in field to change the location where you save the macro. Type the name of the macro in the File name field. The example uses Hello World as a file name. Click Save to save the file. Understanding .iss Versus .ise Files Macros can appear with two different extensions: .iss or .ise. The .iss file is a stan- dard text file that contains the code you write, while the .ise file is compiled. Compiling the file turns the text into tokens that IDEA can understand. (There’s a third form, an executable file that you can learn about in the “Building Your Application” section, but this isn’t strictly a macro file.) So, if the .iss file contains words you understand and executes as a macro, just like the .ise file, why would you ever use the .iss file? The following list describes situations where the .ise file excels. ■ Code Hiding: You put a lot of work into your macros. If you make the code acces- sible to everyone, someone will almost certainly steal it and claim that they created
  • 41. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 18 Mastering IDEAScript FIGURE 2.9 Save Your Macro so You Can Use It Later it. If you want to maintain control over the code you create, compiling it hides the code from everyone else, while letting them use it for purposes you specify. ■ Faster Execution: Theoretically, the compiled file will provide better execution times since it has already been converted into a form that IDEA recognizes. The interpretation phase of working with the macro is taken care of before you actually use the macro. It’s easy to create a compiled file. Select File Save As, click the Save tool- bar button, or press Ctrl+S. When you see the Save As dialog box shown in Figure 2.9, select the Compiled files (*.ise) option in the Save as type field. Type a name in the File name field as normal and click Save. Figure 2.10 shows the Hello World.ise file. As you can see, the file content looks like pure garbage, yet it executes as nor- mal. To execute this file, select Tools Macros Run in IDEA. Locate the Hello World.ise file and click Open. You see precisely the same result as when using the Hello World.iss file. FIGURE 2.10 It’s Impossible to Read an .ise File, Making It More Secure than an .iss File
  • 42. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am Creating Your First IDEAScript Application 19 Sending Your Macro to Someone Else At this point, you have a lovely new macro. You’re justifiably proud of your efforts and want to share it with someone else. IDEA makes it easy to send others the macros you create. In the IDEAScript Editor, select File Send. IDEA will create an e-mail message using your default e-mail program. The macro is automatically attached to the e-mail message for you. All you need do is supply an address, subject, and message, and send the e-mail to the recipient as normal. Building Your Application IDEA supports the creation of executable files from your macros. Using this technique lets you build complete applications that run outside IDEA, unlike a macro that you have to execute from within IDEA. (You still have to have IDEA installed in order to run the application, but the convenience of using an executable file still makes this a valuable option.) This technique is most useful when you create a complete, self- contained process that you don’t want others to modify. The following sections describe how to build an executable application. Creating the Executable File Before you do anything else, you need to save your macro as described in the “Saving Your Macro” section. It’s important to save your macro before you create an executable application from it. The following steps tell how to create the executable: 1. Select File Build Application Name.exe. For example, if you’ve followed the Hello World example, you’d select File Build Hello World.exe. Interestingly enough, you see a Save As dialog box that looks similar to the one in Figure 2.9. However, in this case, the Save as type field contains an Executable files (*.exe) entry in place of the normal macro entries. 2. Type a name for the executable file in the File name field. 3. Select a location for the executable file in the Save in field. 4. Click Save. You’ll see a new file created in the folder you selected with an .exe extension. Warning Always save a copy of your application code in a safe place. Choose a central location for all of your application code so that you can find it when you need it. For security reasons, keep compiled or executable forms of your application on network drives or the drives of other users. The important thing to remember is that you can’t recover your application code if you lose it—the compiled and executable files are unreadable and you can’t obtain your application code from them.
  • 43. Chapter = c02 Date: Feb 17, 2011 Time: 10:28 am 20 Mastering IDEAScript Executing Your Application from Windows Explorer Now that you have a shiny new executable to use, locate it in Windows Explorer. Double- click the icon as you would any other Windows application and you’ll see the same results as before for Hello World. However, in this case, you don’t have to have IDEA running to use the macro—you can double-click the executable file with IDEA closed. Just as you can add any Windows application to a shortcut or the Start menu, you can place an IDEA executable in these locations as well. You can send the .exe file to a friend and they’ll have your complete application. In short, creating an executable file has every advantage that you obtain from its Windows counterpart—an .exe file is always an executable. Just imagine—your first application and you’ve already created something that takes programmers weeks to learn! Note If you want to run your uncompiled application using the Windows Scheduler, you must do so by specifying the IDEA.EXE file and the/m command line switch. For example, if you have an application named MyApplication, then you would add IDEA.EXE/m=MyApplication.ISS to the Windows Scheduler Run field. How- ever, you can get around this requirement by using the executable form of the IDEAScript application. Summary This chapter has demonstrated how easy it is to create an application using IDEAScript. You don’t need any special skills to perform the task—simply a few instructions. Using the techniques in this chapter, anyone can create an application that will help others work faster and smarter. Of course, you still need to discover more about IDEAScript before you can do anything impressive. The basic ideas in this chapter tell you what you’ll do, but not how to do it—that’s what the rest of the book is for. It’s important that you understand this chapter completely before you proceed. Make sure you create both the 10K Customers database and the Hello World application as well as understand what you’re doing before you proceed. It isn’t necessary at this point that you understand the code—simply the process that you’ll follow. Don’t worry; you’ll discover more about IDEAScript as the book progresses. It’s extremely important to learn about the tools you use to work with IDEAScript. Chapter 3 helps you take this next step by describing all of the elements of the IDEAScript Editor in detail. So far, you’ve simply followed instructions to perform a task. By the time you finish Chapter 3, you’ll understand how the IDEAScript Editor works and will be able to complete many tasks on your own. Knowing your tools is extremely important. Just as you expect a carpenter to know how to use a hammer, others will expect you to know how to use the IDEAScript Editor.
  • 44. Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am CHAPTER 3 Understanding the Basics of the IDEAScript Editor The IDEAScript Editor is your tool for creating IDEA macros. As with any other tool, understanding how the IDEAScript Editor works is central to your ability to create macros efficiently. Trying to use a hammer to drive home a screw might work, but it’s not very efficient and definitely won’t produce a very satisfying result. Likewise, your ability to use the IDEAScript Editor helps determine the efficiency with which you work and partly determines the result you receive. One of the essentials of working with the IDEAScript Editor is to understand the windows it provides. Each of these windows gives you a different perspective of your application. Some windows, such as the Editor window, you use all the time, while others, such as the Watch window, only see use for specific tasks (debugging, or removing errors, in the case of the Watch window). It’s important to know how to hide and view these windows as needed. Along with windows, the IDEAScript Editor includes a number of menus and toolbars that you use to access commands. Locating the correct command quickly will help you work faster. This chapter considers the default configuration of the menus and toolbars first and then looks at ways you can customize the menus and toolbars as needed. Perhaps the most important tool in your arsenal is the Language Browser. No one can possibly remember every function that you can use to create an application. Conse- quently, you need well organized help to locate precisely the function you need. You’ll use the Language Browser regularly as the book progresses, so this is possibly one of the most important tools to learn about first. Working with Windows Think about the windows in the IDEAScript Editor in the same way that you think about windows in your house—they offer a view of your application. You look through the windows to see your application in a certain way. Just as each window in your house offers a different view, so do the windows in the IDEAScript Editor. The following sections describe each of the IDEAScript windows that you use when creating an application. 21
  • 45. Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am 22 Mastering IDEAScript FIGURE 3.1 The Editor Window Provides a Place to Type Code for Your Application Editor The Editor window is where you type the commands that you want IDEA to perform. Figure 3.1 shows the Editor window. In this case, you see the Hello World application created in Chapter 2. However, the Editor window shows whatever code your applica- tion uses. As noted in Chapter 2, whenever you type a keyword in the Editor window, it displays a tooltip with information about that keyword. For example, if you type the name of a function, you see the input that the function requires to perform useful work. One of the Editor window features is hidden. Right-click anywhere within the Editor window and you see the context menu shown in Figure 3.2. You can use the options on this context menu to perform the following tasks: ■ Cut: Removes the text you have highlighted in the Editor window and places it on the Windows Clipboard. You can use the Paste command to place this text in another FIGURE 3.2 The Editor Window Context Menu Contains Options for Working with Text
  • 46. Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am Understanding the Basics of the IDEAScript Editor 23 location and create multiple copies of it. IDEA only enables the Cut command when you have text highlighted. ■ Copy: Places a copy of the text you have highlighted in the Editor window onto the Windows Clipboard. You can use the Paste command to create multiple copies of the text anywhere you need it within the Editor window. It’s also possible to use this feature to copy code to another application. IDEA only enables the Copy command when you have text highlighted. ■ Paste: Writes text that currently appears on the Windows Clipboard to the Editor window at the insertion point (the point at which the text cursor appears). IDEA only enables the Paste command when you have text placed on the Windows Clipboard. Note The Editor window is the only IDEAScript Editor window that you can’t hide. Because you use this particular window for every task, from writing the application to testing it, hiding the Editor window wouldn’t serve a useful purpose. Project The Project window contains details about the elements in your application. Every time you create a new application element such as a function, subroutine, or dialog box, it appears in the Project window. Figure 3.3 shows the Project window as it appears for the Hello World application. Whenever you double-click an element in the Project window, IDEA presents that element to you. For example, if you double-click a subroutine or a function name, IDEA places the insertion pointer next to the subroutine’s or function’s name in the Editor window. Right-clicking the project’s file name, such as Hello World.iss, presents a context menu with a single entry, Close. Choosing this entry will close the project for you. FIGURE 3.3 The Project Window Contains a Complete List of All Application Elements
  • 47. Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am 24 Mastering IDEAScript FIGURE 3.4 The Properties Window Helps You Work with Dialog Boxes Tip It pays to right-click in the IDEAScript Editor wherever you think you might find a context menu. The IDEAScript Editor provides a number of context menus, all of which are designed to make your work easier. Context menus help you perform tasks quickly by making it unnecessary to search for a command on a menu or toolbar. To create a new dialog box, right-click the Dialogs folder and then select New Dialog from the context menu. You see a new dialog box added to the application. Don’t worry too much about the actual use of dialog boxes yet, you will learn about them in Chapter 12. Properties The Properties window shown in Figure 3.4 helps you configure dialog boxes and the objects they contain using properties. A property is basically part of the description of an object, such as the color of an apple, may be red, green, or yellow. Color is the name of the property, and red, green, or yellow are the property values. Don’t worry too much about properties now; you’ll discover them in Chapters 9 and 12. IDEA only enables this window when you work with dialog boxes. Even though the Properties window can appear at other times, it doesn’t have a use outside of modifying dialog boxes. As with many other windows, the Properties window supports a context menu. When working with a text property, you can right-click the text value and see the context menu shown in Figure 3.5. These options help you perform the following tasks:
  • 48. Chapter = c03 Date: Feb 17, 2011 Time: 10:44 am Understanding the Basics of the IDEAScript Editor 25 ■ Undo: Reverses any changes you make to the property value. ■ Cut, Copy, and Paste: Performs the same tasks as the Cut, Copy, and Paste com- mands for the Editor window. Essentially, you can cut, copy, or paste values in the Properties window. ■ Delete: Removes the highlighted property value text. However, this option doesn’t place the text on the Clipboard—the text is simply deleted, so you need to use this option with care. ■ Select All: Highlights the entire property value. This is an exceptionally useful option when the property value contains a lot of text. At the top of the Properties window, you see two buttons. Click the first button if you want to see a list of properties for the selected option by category. For example, if you want to see all of the properties that affect the position of a dialog box on screen. This sort order is helpful when you need to change a number of related properties at one time. Click the second button when you want to see the properties listed in alphabetical order. Using alphabetical order is handy when you remember the name of a property you want to change and need to find it quickly. Dialog Tools The Dialog Tools window shown in Figure 3.6 contains a palette of controls you can use to create a dialog box. Simply drag a control onto the dialog box window and drop it. (Chapter 12 tells you more about working with dialog boxes.) This window only appears when you work with dialog boxes. The Dialog Tools window doesn’t provide any context menus. Dialog Box Editor The Dialog Box Editor window shown in Figure 3.7 is where you create the dialog boxes you want to present to the user. IDEA supports a number of controls such as text boxes, buttons, and labels. To draw a dialog box, you simply drag and drop the controls you want onto the dialog box in the Dialog Box Editor. Chapter 12 describes this process completely. For now, all you need to know is that IDEA takes care of many of the details of creating a dialog box for you and all you really need to know is what you want the user to see. FIGURE 3.5 Use This Context Menu to Manipulate Text Values in the Properties Window
  • 49. Discovering Diverse Content Through Random Scribd Documents
  • 50. damaged disk or other medium, a computer virus, or computer codes that damage or cannot be read by your equipment. 1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the “Right of Replacement or Refund” described in paragraph 1.F.3, the Project Gutenberg Literary Archive Foundation, the owner of the Project Gutenberg™ trademark, and any other party distributing a Project Gutenberg™ electronic work under this agreement, disclaim all liability to you for damages, costs and expenses, including legal fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE. 1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a defect in this electronic work within 90 days of receiving it, you can receive a refund of the money (if any) you paid for it by sending a written explanation to the person you received the work from. If you received the work on a physical medium, you must return the medium with your written explanation. The person or entity that provided you with the defective work may elect to provide a replacement copy in lieu of a refund. If you received the work electronically, the person or entity providing it to you may choose to give you a second opportunity to receive the work electronically in lieu of a refund. If the second copy is also defective, you may demand a refund in writing without further opportunities to fix the problem. 1.F.4. Except for the limited right of replacement or refund set forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
  • 51. INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE. 1.F.5. Some states do not allow disclaimers of certain implied warranties or the exclusion or limitation of certain types of damages. If any disclaimer or limitation set forth in this agreement violates the law of the state applicable to this agreement, the agreement shall be interpreted to make the maximum disclaimer or limitation permitted by the applicable state law. The invalidity or unenforceability of any provision of this agreement shall not void the remaining provisions. 1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the trademark owner, any agent or employee of the Foundation, anyone providing copies of Project Gutenberg™ electronic works in accordance with this agreement, and any volunteers associated with the production, promotion and distribution of Project Gutenberg™ electronic works, harmless from all liability, costs and expenses, including legal fees, that arise directly or indirectly from any of the following which you do or cause to occur: (a) distribution of this or any Project Gutenberg™ work, (b) alteration, modification, or additions or deletions to any Project Gutenberg™ work, and (c) any Defect you cause. Section 2. Information about the Mission of Project Gutenberg™ Project Gutenberg™ is synonymous with the free distribution of electronic works in formats readable by the widest variety of computers including obsolete, old, middle-aged and new computers. It exists because of the efforts of hundreds of volunteers and donations from people in all walks of life. Volunteers and financial support to provide volunteers with the assistance they need are critical to reaching Project Gutenberg™’s goals and ensuring that the Project Gutenberg™ collection will
  • 52. remain freely available for generations to come. In 2001, the Project Gutenberg Literary Archive Foundation was created to provide a secure and permanent future for Project Gutenberg™ and future generations. To learn more about the Project Gutenberg Literary Archive Foundation and how your efforts and donations can help, see Sections 3 and 4 and the Foundation information page at www.gutenberg.org. Section 3. Information about the Project Gutenberg Literary Archive Foundation The Project Gutenberg Literary Archive Foundation is a non-profit 501(c)(3) educational corporation organized under the laws of the state of Mississippi and granted tax exempt status by the Internal Revenue Service. The Foundation’s EIN or federal tax identification number is 64-6221541. Contributions to the Project Gutenberg Literary Archive Foundation are tax deductible to the full extent permitted by U.S. federal laws and your state’s laws. The Foundation’s business office is located at 809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up to date contact information can be found at the Foundation’s website and official page at www.gutenberg.org/contact Section 4. Information about Donations to the Project Gutenberg Literary Archive Foundation Project Gutenberg™ depends upon and cannot survive without widespread public support and donations to carry out its mission of increasing the number of public domain and licensed works that can be freely distributed in machine-readable form accessible by the widest array of equipment including outdated equipment. Many
  • 53. small donations ($1 to $5,000) are particularly important to maintaining tax exempt status with the IRS. The Foundation is committed to complying with the laws regulating charities and charitable donations in all 50 states of the United States. Compliance requirements are not uniform and it takes a considerable effort, much paperwork and many fees to meet and keep up with these requirements. We do not solicit donations in locations where we have not received written confirmation of compliance. To SEND DONATIONS or determine the status of compliance for any particular state visit www.gutenberg.org/donate. While we cannot and do not solicit contributions from states where we have not met the solicitation requirements, we know of no prohibition against accepting unsolicited donations from donors in such states who approach us with offers to donate. International donations are gratefully accepted, but we cannot make any statements concerning tax treatment of donations received from outside the United States. U.S. laws alone swamp our small staff. Please check the Project Gutenberg web pages for current donation methods and addresses. Donations are accepted in a number of other ways including checks, online payments and credit card donations. To donate, please visit: www.gutenberg.org/donate. Section 5. General Information About Project Gutenberg™ electronic works Professor Michael S. Hart was the originator of the Project Gutenberg™ concept of a library of electronic works that could be freely shared with anyone. For forty years, he produced and distributed Project Gutenberg™ eBooks with only a loose network of volunteer support.
  • 54. Project Gutenberg™ eBooks are often created from several printed editions, all of which are confirmed as not protected by copyright in the U.S. unless a copyright notice is included. Thus, we do not necessarily keep eBooks in compliance with any particular paper edition. Most people start at our website which has the main PG search facility: www.gutenberg.org. This website includes information about Project Gutenberg™, including how to make donations to the Project Gutenberg Literary Archive Foundation, how to help produce our new eBooks, and how to subscribe to our email newsletter to hear about new eBooks.
  • 55. Welcome to Our Bookstore - The Ultimate Destination for Book Lovers Are you passionate about books and eager to explore new worlds of knowledge? At our website, we offer a vast collection of books that cater to every interest and age group. From classic literature to specialized publications, self-help books, and children’s stories, we have it all! Each book is a gateway to new adventures, helping you expand your knowledge and nourish your soul Experience Convenient and Enjoyable Book Shopping Our website is more than just an online bookstore—it’s a bridge connecting readers to the timeless values of culture and wisdom. With a sleek and user-friendly interface and a smart search system, you can find your favorite books quickly and easily. Enjoy special promotions, fast home delivery, and a seamless shopping experience that saves you time and enhances your love for reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookgate.com