TweetFollow Us on Twitter

HyperCard 2.0
Volume Number:6
Issue Number:11
Column Tag:XCMD Corner

HyperCard 2.0

By Donald Koscheka, MacTutor Contributing Editor

The Revolution

Thomas Jefferson once stated that “Revolution is that event which allows all ordinary events to continue”. Based on this definition, I’m inclined to feel that HyperCard 2.0 is a bit revolutionary. For the past 3 years, stack developers have expended a tremendous amount of energy trying to squeeze the last bit of performance from HyperCard.

This effort almost always leads to the development of some suite of XCMDs to supercharge an existing stack. As I watched this evolution develop, I noticed that XCMDs typically fall along a specific set of tasks. These include file I/O, interfacing to external devices, print management and window management (including dialogs). From the perspective of the XCMD programmer, the HyperCard 2.0 revolution is not at all subtle: HyperCard incorporates many features found previously only in XCMDs.

HyperCard 2.0 brings more to the party than new XCMD capability but in keeping with the spirit of this column, I will focus on what’s new in the XCMD world.

What’s New and What’s Not

Whenever you need to develop for a new version of any software package, you need to evaluate the scope of the update. You can perform this evaluation very quickly by asking yourself two questions: “What changed since the last version” and “What hasn’t changed since the last version?”

Armed with these two questions, the best place to find the answers is in the interface and library files in HyperCard 2.0. My version of HyperCard 2.0 came with just 3 files: HyperXCMD.p, HyperXCMD.h and HyperXlib.o. I was immediately surprised to find that XCMDGlue was missing from the distribution disk. At first I thought this was a mistake but a quick disassembly of HyperXLib.o showed this not to be the case; XCMDGlue is no longer needed, that function is now performed directly in the Callback Library.

So the first change is that we no longer need to compile our code with a glue routine. The interface code varies incrementally beyond this point (that is, they’ve ADDED stuff but all of the old stuff is still intact). For example, XCMDs are still called with the same parameter block record as in earlier versions of HyperCard with the exception that the the fields in the block take on special meaning for external windows. External windows adds a whole new dimension to HyperCard so look for a lot of discussion about them in future installments of this column.

The parameter block is not only used for interfacing between the calling script and the XCMD but also for interfacing between the XCMD and the HyperCard callbacks. The callback engine has been increased to over 75 callbacks (I counted two callbacks that appear in the library but are not documented as of this writing). The new callbacks can be divided into groups according to the class of services they perform: Hypertalk utilities, Memory Utilities, String Utilities, String Conversions, field utilities, miscellaneous utilities, Creating and disposing windows, window utilities, text edit utilities, script editor utilities, debugging tools. The categories are Apple’s, not mine. I will use this list to set the agenda for this column for the next several months. We will look at each of these categories in detail in turn.

One of the most salient additions to XCMDs in HyperCard 2.0 is the addition of “version control” information. From now, whenever the user passes ! as the first parameter to an xcmd, you need to return the version of that XCMD. if the user types passes ? as the first parameter, you should pass usage information to the user. This is straightforward and simple enough to abide by. Funny how those darned “command lines” have a habit of appearing in the most unusual of places. With this in mind, we will start at the beginning again, introducing “Simple XCMD 2.0.c” with this new twist. This is the building block for all 2.0 XCMDs and you can use it as a sort of template. A controversy will no doubt arise over the hard coding of strings in the XCMD code resource, but without a lot of thought, I think that you can convince yourself that there isn’t a better way to do this.

An XCMD For 2.0

While we haven’t answered both questions in great detail on this pass, we have learned enough to jump right into trying our hand at an XCMD for 2.0. We learned that the interface is pretty much unchanged and that old XCMD should work fine under 2.0 although they won’t be able to take advantage of 2.0’s features. Most importantly, we learned that this isn’t a complete restart; we can easily build on existing experience as we migrate our code to 2.0. This is good -- nobody likes to spend 3 years doing anything just to discover on such and such a date that everything they know is wrong!

Listing 1 is a sample HyperCard 2.0 XCMD. It is quite straightforward since it doesn’t actually do anything. I am taking the introduction of HyperCard 2.0 as a rare opportunity to “wipe the slate clean” and start all over again with a fresh look at XCMDs. Since this is the first of many columns in which I will discuss 2.0, I have decided to start off slow and sure and build from here. Listing 1 conforms to the structure of a 2.0 XCMD without relying on the new XCMD glue. If you don’t have 2.0 yet, you can build and test this XCMD under earlier versions of HyperCard until you get version 2.0. I did this to allow those of you who want to follow along with this column to get caught up first. I will start in earnest on 2.0 next month. Until then, Happy Hacking!

/**********************************/
/* File: Sample.c*/
/* */
/* A sample XCMD for Hypercard*/
/* 2.0  */
/* */
/* Well-behaved XCMDs for HC2.0  */
/* will respond to the ! and ?*/
/* requests by returning version */
/* and usage information  */
/* respectively. */
/* */
/* ----------------------------  */
/* ©1990, Donald Koscheka */
/* All Rights Reserved    */
/**********************************/

/*
 Project:

 ANSI-A4-- standard “C” libraries assembled
 off of register A4
 
 MacTraps
 Sample2.0.c (contents of listing 1)

 Set Project Type:
 Type == XCMD | XFCN
 Name == SimpleXCMD
 id == 1000
 
 Usage
 
 SimpleXCMD “?”
 SimpleXCMD “!”
 put the result
 
 OR
 
 Put simpleXCMD( “?” )
 Put simpleXCMD( “!” )
*/

#include<SetUpA4.h>
#include<string.h>
#include<HyperXCMD.h>
 
#ifndef NIL
 #define NIL(void *)0L
#endif

Handle  strToParam( str )
 char *str;
/***************************
* Given a pointer to a string,
* copy that string into a handle
* and return the handle.
*
* The input and output strings
* are both null-terminated
*
***************************/
{
 Handle outH = NIL;
 long len = 0;
 
 len = strlen( str );
 if( len )
 if( outH = NewHandle( len ) )
 BlockMove( str, *outH, len + 1 );
 
 return( outH );
}

pascal void main( paramPtr )
 XCmdPtrparamPtr;
{
 Handle answer = NIL;
 char *str;
 long len;
 
 paramPtr->returnValue = NIL;

 /** The first thing that a well-behaved           **/
 /** HC2.0 XCMD should do is check to see    **/
 /** whether the first (and only) parameter  **/
 /** is the user request for information or  **/
 /** or usage information.  If so, just pass **/
 /** your answer back to the user, otherwise **/
 /** go ahead and perform your xcmd services **/
 
 if (paramPtr->paramCount == 1){
 if ( **(paramPtr->params[0]) == ‘!’ ){
 paramPtr->returnValue = strToParam(“Simple XCMD, version 1.0, ©Donald 
Koscheka, 1990”);
 return;
 }
 
 if ( **(paramPtr->params[0]) == ‘?’ ){
 paramPtr->returnValue = strToParam(“Simple takes no parameters and does 
nothing with them.”);
 return;
 }
 }
}

Listing 1. SimpleXCMD.c

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »

Price Scanner via MacPrices.net

Apple’s 24-inch M3 iMacs are on sale for $150...
Amazon is offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150 off... Read more
Verizon has Apple AirPods on sale this weeken...
Verizon has Apple AirPods on sale for up to 31% off MSRP on their online store this weekend. Their prices are the lowest price available for AirPods from any Apple retailer. Verizon service is not... Read more
Apple has 15-inch M2 MacBook Airs available s...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs available starting at $1019 and ranging up to $300 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at Apple.... Read more
May 2024 Apple Education discounts on MacBook...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $300 off the purchase of a new MacBook... Read more
Clearance 16-inch M2 Pro MacBook Pros in stoc...
Apple has clearance 16″ M2 Pro MacBook Pros available in their Certified Refurbished store starting at $2049 and ranging up to $450 off original MSRP. Each model features a new outer case, shipping... Read more
Save $300 at Apple on 14-inch M3 MacBook Pros...
Apple has 14″ M3 MacBook Pros with 16GB of RAM, Certified Refurbished, available for $270-$300 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year warranty is... Read more
Apple continues to offer 14-inch M3 MacBook P...
Apple has 14″ M3 MacBook Pros, Certified Refurbished, available starting at only $1359 and ranging up to $270 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more
Apple AirPods Pro with USB-C return to all-ti...
Amazon has Apple’s AirPods Pro with USB-C in stock and on sale for $179.99 including free shipping. Their price is $70 (28%) off MSRP, and it’s currently the lowest price available for new AirPods... Read more
Apple Magic Keyboards for iPads are on sale f...
Amazon has Apple Magic Keyboards for iPads on sale today for up to $70 off MSRP, shipping included: – Magic Keyboard for 10th-generation Apple iPad: $199, save $50 – Magic Keyboard for 11″ iPad Pro/... Read more
Apple’s 13-inch M2 MacBook Airs return to rec...
Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices currently... Read more

Jobs Board

Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
*Apple* App Developer - Datrose (United Stat...
…year experiencein programming and have computer knowledge with SWIFT. Job Responsibilites: Apple App Developer is expected to support essential tasks for the RxASL Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.