Download Porting a SAS/AF Application from PC to a MAC

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
Transcript
Interactive Systems
PORTING A SAS/AF APPLICATION FROM A PC TO A MAC
Sharilyn Fabian-Ross, James Carter: SCT Corp.
Abstract
SASIAF provides the ability to construct intricate GUI
applications for various platforms including Pes and
Macintoshes. Given the nature of Murphy's Law, if
you have constructed the SASIAF application on a
PC, a customer will materialize saying 'We'll use your
application IF it runs on a Mac." Since programmers
regularly tum Murphy's Law to their advantage, this
paper will cover the issues encountered when a
SASIAF application is ported from a PC to a Mac.
Issues include transforming frame size, maintaining
widget size and style, providing interactive help,
accounting for user expectations, developing
program branches based on platform, accesSing
local directories and changing system options.
What do we mean by .•.••
Alias:
A Mac term meaning a duplicate of
a file icon. It is not the file itseH but
does point to it.
AppleScript:
Software delivered on the Mac that
provides a "batch" language facility.
Extension:
A memory resident program that
provides additional functionality to
the Mac operating system.
Finder:
The Mac program for viewing the
folders and files on the system
(similar to Windows File Manager).
Folder:
The organizational structure in the
Macintosh file system. Similar to a
directory on a PC.
SEM:
Strategic Enrollment Management.
The SCT software product that we
ported to the Macintosh.
=>
The character "::>" is used in the
AppleScript code to deSignate a
single line that has been split to fit
the format of this paper. Splitting
command lines in AppleScript
results in a syntax error.
Introduction
Beginning with SAS release 6.10 for Windows and
release 6.10 for Macintosh, a complete environment
for GUI development now exists. However an
application generally has a "home" operating system
and the software will eventually have to be ported. In
our case, we developed our ·Strategic Enrollment
Management" software (SEM) in SASIAF for
Windows and then ported it over to the Macintosh.
The purpose of this paper is to describe areas in the
Windows to Macintosh port that required particular
attention. The following sections will refer to the
tools used, anomalies encountered and code
switches developed to migrate the application across
platforms. We are assuming the reader is familiar with
AFlFrame and SCL. We intend that this paper could
be used as a rough outline of steps for migrating a
SASIAF appfication from Windows on a PC to a
Macintosh.
.
General Approach
Very few applications have reached "software
nhvana." That is, most applications still require
development to meet customer needs. Our
application is no exception: Enhancements are
constantly being added. Consequently, it made
sense for us to have only one master copy of the
SCl code in SEM in order to ease maintenance
issues. We decided to have the master copy of the
software reside on Windows for three important
reasons. First, it is the location where the majority of
the code was Originally developed. Secondly, our
Caveat: SAS 6.10 is the first production release of
SAS/Macintosh, and as such, contains the usual
assortment of first·release "features." We expect
that many of these will have been addressed by the
6.11 release which is supposed to be available
between the time this paper is published and the
conference. Accordingly, a "6.11 Update" section
will be included during our presentation at the 1996
NESUG conference.
493
NESUG '96 Proceedings
Interactive Systems
programmer expertise base leans largely toward the
PC environment. It is more efficient for us to solve
design and coding issues on a PC. Thirdly, we have
far more PC resources available.
SAS/AF Porting Tools
To maintain a master copy of our application's SCL
on the PC, we need a repeatable transport process.
To facilitate this, we built a porting tool using SASIAF
to provide us with an easy interface to the SAS
CPORT procedure. This procedure writes out SAS
catalogs into a proprietary transport file format.
Transport files are the vehicle by which SAS catalogs
and data sets are moved from the PC to the
Macintosh. As changes are made to the master copy,
the associated catalogs need to be ported over to
the Macintosh. The porting tool provides us a pointand-click interface to select the catalog entries to
transport, the final location of the transport file and
whether to compress the transport file (using the
DOS shareware program: PKZIP).
I Pith: I c:\irill.
I 'tDiV 5r!In!F!!r't. tn, to ,,: driII "ZIP' Iih! !r!n!pgQ til.
CPORT Tool Interface: PC Interface
The 'Library' list box displays the current libraries.
Once the user clicks on a library, the catalogs in that
library display in the 'Catalog' list box. After the user
selects the catalog, the 'Entries' list box displays the
entries in that catalog. The 'Items to port' radio box
gives the option of selecting short cuts when
selecting the entries to port. The default is to build a
transport file from the selections made in the list box
but if the user selects "SCL only" or "All" from the list
box, all SCL entries or all entries, respectively, will be
used in building the transport file. When the user
has selected the parameters and clicked on the OK
button, the information is retrieved from the widgets
on the frame and the following section of code is run.
NESUG '96 Proceedings
Sample Code 1: SCL - CPORT tool
The above section of code is the core component of
our AFlFrame transport file tool. Many of the SAS
products have functionality that is not directly
available in SCL but can be accessed through the
"submiVendsubmif construct. This means that, for
example, data steps, SAS/STAT procedures and
Base SAS functionality can be embedded in SCL.
The "cporf procedure shown in the above example
is an example of calling a Base SAS procedure from
SCL. The code between the ·submitlendsubmif
blocks is buffered until a "submit continue!
endsubmif block is reached. At that point all the
494
Interactive Systems
BUII.O:'DIS.lIf ...............UEI'
buffered code is pushed to be processed by the
SAS executive. The buffering permits a single call to
the cport procedure followed by a loop containing
the submit of the each catalog entry being rolled into
the transport file. Also, SCl variables can be
accessed in a submiVendsubmit block by preceding
them with an ampersand.
r---------
U_~::~~L
·D""""""""""":...
q,
,,
I
:'G;)""'--':
·
.
·
,-"::~::-,:,,, -,,:
._-------_..
,----- -------- ._. ----- --_.-..
····
...
,
I
Updat
•
",",
The import procedure residing on the Mac uses
similar logic through a slightly different interface.
•
•
'"
k
I
••
,
:,0
:,
r: i,
···..· -------------------- ---_."...
(For more information on how this tool works, see our
related paper: ·Cooking Up Tools in the SAS/AF
Kitchen.")
\
AFlFrame: Macintosh Version
AFlFrame Port: Frame Entries
General 6.10 frame porting weirdness
Once the frames have been ported, a brief look at
their appearance will trigger the ·something isn't
quite right here" response.
The following two pictures demonstrate this:
~-
----SUILO.DISPLAY lMPORr FRt.M£
I
I C....ntUbroryA. .lg .......
I
I
I
I
I
I
I
1
I """'lIoble D... sets lor ImpGl1
I
I
I
I
I
I
JEI
- - - ----
Aside from some differences in default color
settings, it is evident that some of the widgets do not
pass through the transport process unscathed. For
example on the frame above, the button Cancel has
been truncated to Cance , we have Updat rather than
Update, Assig rather than Assign and the title on the
list boxes are obviously too wide to now fit in the
widget.
Below is a list of general weirdness encountered
when transporting frame entries from a PC to a
Macintosh.
Widg_et
General
List Box
L
AFlFrame: PC VeiSlon
Push
Buttons
Observation
Widgets are no longer centered
on frame.
The scroll bars move contents
either flush right or flush left, not
in between.
The Mac's interpretation of the
default title font may leave the list
box too narrow to display all the
Original text.
All push buttons Shrink by 3
characters during the porting
process. SAS Institute is aware
of this problem. (See note below)
Table 1. Problems noticed when porting AF FJa/T1II entries
(Note: We tried to address the shrinking buttons by
editing the transport file itseH, but we were unable to
find all the embedded codes that control the push
495
NESUG '96 Proceedings
Interactive Systems
buttons' size. For more information on this
technique, see our other paper "Cooking Up Tools
in the AF Kitchen.")
AFlFrame Port: SeL Entries
Conditional
Execution
Unfortunately we found no way other than editing
each individual frame to fix the "general weirdness·
introduced by building a transport file.
Consequently, we only wanted to port the frame
entries once. We are extremely careful to keep a
backup copy of the edited frames in case we
accidentally overwrite them during a port of other
entries from the same catalog. As new frames are
introduced into our product, these are transported,
edited and added to the application on the
Macintosh.
Unlike transporting frame entries, building and
importing transport files generated solely from SCl
entries has been problem free. (Yay!) Since this is a
process we can easily repeat, we are able to have
one master copy of the SCl code. The cornerstone
of creating one master SCl code is the ability to
query the local machine to determine the current
operating system. Conveniently, SAS provides the
macro variable SYSSCP that will return the name of
the operating system.
Widget Appearance:
So You Want Green Text?
.]od.ilQs';'sYihg~t{~SY"$Scp');)L·) .,
Sample Code 2: SCL - SYSSCP example
You Got it!
During our initial experiments with the Mac, several
Mac users told us that they expect to have control
over the general appearance of the application. On
the Mac, SAS provides the ability to control push
button style, check box style, radio button style,
slider style, icon style and font size and type through
the "flavors" option under the
"preferences/customize global options" selections
from the "File" pull down menu. In order to allow the
user to have more control over the appearance of
our application, some widgets' colors are set such
that changing the color associated with a window
element will change the color of the widgets. Users
can adjust the colors by using the color setup
selection under the "Global/Options" pull down.
Widget
Text EntlY
Text Label
List Box
This returns the string "WIN" on Windows 3.x or
Windows95 and "MAC" on a Macintosh into the
variable foca/os. A new macro variable SYSSCPl,
available in SAS 6.11, returns the specific operating
system name. Currently our product runs in
Windows 3.x, Windows 95, and on the Macintosh, so
we don't require the level of detail provided by
SYSSCPL.
In SEM the call to the SYSSCP macro variable
resides in a simple method, called "Whichos,· that
retums both the operating system name and an error
code. A method is a section of code in an SCl entry
that can be called from other SCl entries. It is
efficient to use a method when a section of code
needs to be called repeatedly since it Will be centrally
located. In the case of calls to SYSSCP we use a
method since we need to know the operating
system for calls to toolbars, pulldown menus, graphic
device drivers, the help system and the tutorial.
Color selection
Foreground
Label
Title - title
Contents - black
Table 2. Widgets with vanable colors
All other widgets are black on a gray background.
The main motivation for some rigidity in defining
widget color is that regardless of the color setup
chosen by the user, the black Canoe/and OK
buttons will always be visible on a gray background.
With this restriction at least frame navigation is always
possible.
Sample Code 3: SCL - WI"ichos me1hod
The call to the macro variable SYSSCP will retum the
abbreviation "MAC" or "WIN" into the variable Iocafos.
Hthe macro returns with a code other than "MAC" or
"WIN" an error code is set and the calling SCl
program will display a specific error message.
NESUG '96 Proceedings
496
Interactive Systems
Printing
Text
In SEM, we use the SYSPRINT option and the
PRINTER filename to send text output to the default
printer. You can change the printer setting using the
DlGPRTSETUP command using the EXECCMDIO
function. Since the system specific print
characteristics (e.g. printer drivers, fonts, pitch) are
controlled at the ·SAS level," this code all ports to
the Mac without modification.
Sample Code 4: SCl· General call to method "whichos"
Above "methloc.scl" is the name of the SCl entry
containing the method "whichos." The variable
/oca/os is returned with the code for the operating
system and error is retumed set to a value. Here the
code that is executed depends on the local
operating system.
Graphic
procedure
devices
In our product, we often display graphics output. To
do this we use SAS/Graph procedures which require
the setting of a device driver. Consequently before
calls to the procedures GCHART, GMAP, and
GPlOT, the following section of code is run.
Sample Code 6: Sel· Text Printing
Printing
Graphics
There are two basic sets of printer drivers to employ
when printing graphics from SAS. The first set is the
"generic" SAS/Graph drivers (listed in the table
below). The second set are hardware-dependent
and not shown here but for more information on
these drivers, refer to the Companion Manual for
either Windows or Macintosh.
Driver
Sample Code 5: SCl· Example call to whichos method
The above code is a specific example of the call to
the "whichos" method and its result. The operating
system affects the setting of the option "device"
used by SAS/Graph procedures.
Name
Plotter
Color Printer
Gray-scale Printer
Monochrome Printer
..
Mac
Name
MACPlOT
MACPRTC
MACPRTG
MACPRTM
Windows
Name
WINPlOT
WINPRTC
WINPRTG
W1NPRTM
Table 3: Printing G!aphics
497
NESUG '96 Proceedings
Interactive Systems
macro at compile time, the same section of code can
be maintained on the two separate systems.
The graphics printed from our application are all
stored as catalog entries, so they are printed by
using Proc GREPLAY and by setting the appropriate
printer driver. The names of the printer drivers are
stored in an SCL list. The following code sets the
devices by differentiating between the
environments.
Sample Code 8: SCL· Conditional Compilation
The above code also demonstrates our approach to
on-line help for our application. In the PC world, the
standard help-viewing tool is the MS WinHelp
program that is distributed as part of the Windows
operating system. In our application, we used one of
the commercial help-authoring tools to create
WinHelp .HLP files, that we could then call using the
WINHELP() function.
On the Mac operating system, there is a WinHelp
equivalent called Apple Guide, but SAS provides no
means of calling it. As an alternative, we found the
easiest way to migrate the help database to the
Macintosh was to save the source WinHelp files as
text files and to then write a converter tool using
AF/Frame and SCL to read the text files into SCL
lists. The SEM product accesses these lists through
a series of frames that display the help text and allow
the user to search by keyword and link to related
subjects. Although the process is different, the
intent is to provide functionality on the Mac similar to
that available in WinHelp on the PC.
Sample Code 7: SCL- Graphics Prhting
Tutorial
Providing On-Line
Compilation
Help:
Conditional
Tutorials perform a vital function of giving the user
information about the mechanics of using the
software, as well as aiding the development of
functional expertise. We wrote the SEM tutorial
using IconAuthor software because it provides a
playable version of its executable for the Macintosh.
Although we can not develop the tutorial on the
Macintosh, it's a fairly simply process to take the text
and graphics files from the SEM tutorial on the PC
Another use of the SYSSCP macro variable is to
differentiate between platforms at compile time
using macro coding. This technique is very useful
when using platform specific SCL functions, such as
the WINHELP() function. Macro coding can be used
in SCL as in Base SAS, to generate program code at
compile time. By checking the value of the SYSSCP
NESUG '96 Proceedings
498
Interactive Systems
and port them to the Macintosh. IconAuthor has its
own executable so the tutorial can be run from
outside of SAS as a stand-alone application or from
inside SAS. For convenience, the tutorial is available
from all pulldown menus in the SEM product. When
the user chooses 'Tutorial' from the pulldown menu,
the following code is executed.
This code starts the IconAuthor tutorial application
by passing the AppleScript command "tell Finder" to
the Mac operating System using the system
command. Because of the single-threaded nature of
SAS on the Mac, when the user closes the tutorial,
the SEM application is again available.
A Directory By Any Other Name•••
Sample Code 9: PMENU Source Code - Launching 1he Tutorial
The code executed by the call to the labeled section
in the PMENU.SCl is as follows.
In the PC world, files are stored in a hierarchical
directory structure. Directory names can be up to
eight characters long and are delimited with a slash
character ("\") (Note: A future release of 6.11 is
supposed to support names longer than 8
characters.) SAS cares about this primarily when
associating a LlBREF with a location on your hard
drive. For example, you might have a LlBREF
defined in your PC SAS session as:
.L.··IBNAMB··.·tEsttIB···.•.~c:\SAsBmS\tEsmm('i.;;
,,,,.>,, . .·. ~t";;
"
, '__'
"
.:.
,>.' ,',
__
___
0.'
~_ ,._,_,_
'_' ',.,
A
,_"
',_,',',
-,
,,'
"
.,,',",'
.,'
Sample Code 11: SAS
The Mac equivalent of a PC directory is a folder.
Just like directories, folders can contain files and
other folders. In fact, the organization of folders on a
disk looks very similar to the directory structure on a
PC. However, in contrast to PC directory names, Mac
folder names:
•
•
•
can be longer than on a PC
use upperand lowercase letters
are delimited with a colon
The Mac version of the above LlBREF might look
like:
~t:WN~y:r.. ;reS1t~.rS~My~~'$g~;1::~,m;
San1JIe Code 12: SAS
One of the frames in our product provides a graphical
point-and-click interface where the user can define
various LlBREFs. The code behind the frame makes
extensive use of some of the SCl directory
functions (DOPENO, DREADO, DNUMO, and
DClOSEO.) Luckily, these functions work identically
on Folders as on PC directories, so most of this code
ports very smoothly. Watch out for code that does
not check upperJlower case names though, since
the Mac supports lowercase folder and file names.
(This will apply to code ported to UNIX as well.)
Sample Code 10: SCL -l..aLn:h1ng 1he Tutorial
499
NESUG '96 Proceedings
Interactive Systems
A brief note about toolbars ...
Since there are many commercial installation
packages available, evaluate each based on its
"canned" procedures. Does the package have
procedures that allow you to easHy answer all
installation environment questions?
SAS 6.10 on the Mac supports only one toolbar
whereas PC SAS provides for the use of multiple
toolbars. The user can alter the single toolbar on the
Mac by using the preferences pull down. On the PC
we use the toolbar to echo commonly used options
found on the pull down menus. Users prefer to have
the frequently chosen options "one click away" on
the toolbar rather than two or more clicks away on the
pulldown menu. The local operating system code
switch is used to determine whether or not to call the
code that will display a new tool bar.
Building an application icon
Ideally, we want the result of a successful installation
to be an icon that starts the application. Clicking on
the icon needs to issue a command that the
operating system traps and takes action on.
The PC version •••
On the PC, the installation utility gives us the
functionality to communicate with the Program
Manager and to create a program group and various
icons for the application. The command line for the
application icon specifies the configuration fHe that
starts the application, as follows:
Sample Code 13: SCL • Toolbar Display
If the local operating system is Windows then the
toolbar "ENR.MENUS.MAINMENU· is loaded.
c:\SA$\sA.srEXE;i~;~CQm!g19:~r;N·fflou..\SEM~§A.~:;ffY:
NOTE: SAS 6.11 for the Mac should support
multiple toolbars.
~
In the configuration file (SEM.SAS), an INITCMD
statement is used to issue an AFA command to start
the application, as in:
SAS/AF Application Installation
Checking the
Installation
Code 14: PC Icon Command fine
"s$f,t:Nj:rb;\SOm~djr'
..........." •. ;? .·.
/i:
·i:· i' .ii·' :':
:::::}~!;1'~tli~
-INIT~P~MAC=ENR;SEM.MAINME;NU;f:8M1E;~:~;
Environment
Sample Code 15: SAS code in PC Config. File
As marketing people know, the packaging of a
product is integral to successful delivery. Users are
now accustomed to inserting installation disks,
clicking a few times and finding the application ready
to go. Due to this expectation, programmers inherit
the responsibility to check for the proper installation
environment.
The Mac version .••
On a Macintosh the easiest way to build an
executable application is to use AppleScript. In order
to do this SAS Institute has provided an Apple
scripting extension called "Invoke SAS: When the
"Invoke SAS" command is issued in a script, the
operating system recognizes it because of the
extension. The command takes various parameters
and will ultimately start SAS.
Prior to installing SEM onto a new Macintosh, the
installation environment needs to be evaluated. We
must answer the following questions:
(Note: The invoke SAS scripting extension is "preproduction experimental" material in SAS 6.10 for
the Mac.)
Is there enough disk space?
Is there enough memory?
Is this the proper hardware?
Are all the other necessary applications present?
-Is SAS loaded?
- Is AppleScript loaded?
What is the version of the operating system?
- We require at least Macintosh System 7.5
Does the target folder already exist?
NESUG '96 Proceedings
To obtain the "invoke SAS' scripting addition, install
the Product Updates from the SAS CD or floppies.
The installation places the extension in the
"<SASROOT>:SAS Extras:Applescript extension"
folder. The "invoke SAS" command .takes many
different parameters detailed in the text file, "Invoke
SAS Documentation" in the same folder. The
500
Interactive Systems
extension needs to be moved to the "<Hard
drive>:System Folder:Scripting Additions" folder in
order to be recognized as an available extension by
AppleScript. We wanted to create an icon that starts
our application. Using the AppleScript editor, the
following code can be entered and saved as a runonly application which we send to the end user.
Sample Code 16: AppleScript - Start SAS and SEM
"SEM.SAS" is the autoexec file that sets up the
SAS environment for our application.
Sample Code 17: SAS - Mac Autoexec File
The first two lines set up our required SAS libraries.
The "OM" command is used to issue the AFA
command to start our SEM system.
The Macintosh operating system provides the abifity
to create an icon that will start an application in a
different folder. This construct is called an "alias." As
part of our install process, we create an alias of the
AppleScript application that starts up SEM and place
the alias on the desktop. This allows the user to start
SEM without having to traverse the folder structure
to find the SEM application icon.
After writing the installation script, we wanted to
. create an easily reproducible process for building the
application floppies delivered to the customers. Our
distribution center duplicates the master floppies so
we simply needed a process for creating a master set
of disks. AppleScript provides the functions needed
to do the job.
Sample Code 18: AppIeScript - Make ins1allation floppy process
(Note: Oraglnstall is the drag-and-drop installation
software for the Macintosh that we chose to use.)
Most of the AppleScript code above performs
operations on files and folders seting up the proper
environment for the installation software. The
display dialog command creates a diafog box with a
message, an OK button and icon number 0, a stop
sign.
Other Useful Mac-isms
ResEdit
'ResEdH' is a free program available from several sites
on the Worfd Wide Web. It opens various
characteriStics of files for editing such as the file icon,
creator, file locks, label and Finder flags.
Apple Extensions
Apple Extensions are memory resident programs .
that reside in the ·System Folder/Extensions· folder.
When loaded at system boot-time, they are always
running. Sometimes, this can cause a conflict. For
example, we found that on our system the extension
"Apple Guide" will interfere with the ability to toggle
501
NESUG '96 Proceedings
Interactive Systems
the insert/overstrike mode in both the SAS Program
Editor and the SCl editor.
SAS Institute, Inc., SAS Screen Control Language,
Version 6, Second Edition Cary, NC: SAS Institute,
Inc., 1994.
Note: Generally, after you switch an extension on or
off, you must reboot the computer.
Commercial
Memory Issues:
Mentioned
Apple, Macintosh, AppleScript and Apple Guide are
registered trademarks of Apple Computer, Inc.
SAS publishes a requirement of a minimum 8 meg of
memory with 18 meg suggested. Rick Aster in his
paper "Getting Organized in Mac OS" recommends
21 meg. SAS seems to use whatever memory is
available (Slight exaggeration) so have lots of
memory or set the virtual memory relatively high.
Draglnstall is a registered trademark of Ray Sauers
Associates, Inc.
IconAuthor is a registered trademark of AimTech
Corporation.
Conclusion
SAS is a registered trademark of SAS Institute Inc.
This paper covered issues encountered in a PC to
Macintosh port of an AFlFrame application including:
• AF tools that we built to help maintain the
porting process
• Widget anomalies that occur during the
CPORT procedure
• SCl code switches that depend on the
local operating system
Draglnstaljlll
Ray Sauers Associates, Inc.
1187 Main Avenue, Suite 18
Clifton, NJ 07011-2252
1-201-478-1970
IconAutho~
AimTech Corporation
20 Trafalgar Square
Nashua, NH 03063
References
Aster, Rick. "Getting Organized in Mac OS' NESUG
Conference Proceedings, 1995. p353-358
Contacts
Sharilyn Fabian-Ross, James Carter
SCT
3000 Ridge Road East
Rochester, NY 14622
Intemet: [email protected], [email protected]
Carter, James. ·Cooking Up Tools in the AF Kitchen"
NESUG Conference Proceedings, 1996.
Goodman, Danny. Danny Goodman's AppleScript
Handbook, Second Edition, New York, NY: Random
House, Inc., 1994.
Goodman, Danny and Jeremy Joan Hewes. Danny
Goodman's Apple Guide Starter Kit, Reading, MA:
Addison-Wesley, 1995.
SAS Institute, Inc., SAs/AF Software Frame Entry,
Usage and Reference, Version 6, First Edition Cary,
NC: SAS Institute, Inc., 1993.
SAS Institute, Inc., SAS Companion for the
Macintosh, Version 6, First Edition Cary, NC: SAS
Institute, Inc., 1995.
SAS Institute, Inc., SAS Companion for the Microsoft
Windows Environment, Version 6, First Edition Cary,
NC: SAS Institute, Inc., 1993.
NESUG '96 Proceedings
Products
502