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

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom 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.