The XCMD & XFCN Collection


This section is devoted to xcmd's and xfcn's. These are little bits of code that you can put into your stacks to add some special ability, such as web access, networking, special tools etc. They don't just cut and paste like a Hypertalk script, but instead are copied into the resource fork of your stack. You'll need a handy copy of ResEdit (available from Apple's web site, and on most Mac cd's etc) for this, but don't worry, it's very simple.

The following is a list of all the XCMD's and XFCN's I have on my site. I only put good, working ones here, and there are hundreds more out there on the web, but the best ones I have found are below.


Balloon Help XCMD - This little XCMD allows you to add balloon help to your stacks, using HyperTalk calls and on mouseWithin scripts etc.

Caliban's XCMD's. A bunch of useful xcmd's and xfcn's. It costs $25 to use them for commercial purposes, but freeware authors can use them without hassle. The xcmd's included are:

ActiveHandlers - tells you all the various handlers that are currently running.
Calendar - Displays a nice colour calendar that returns the date clicked on and floats around in a palette.
ChangeResInfo
ClipPictInfo - returns information about whatever picture is in the clipboard, including dimensions, depth and size in bytes.
ClipToPictRes - takes a picture in the clipboard and saves it in the current stack as a pict resource ready for use.
ColorCurs - gives you a cool colour cursor which you can change easily with ResEdit (multiple cursors too). Unfortunately the colour cursor dies when you click again.
CompressPict - compresses a pict file specified using JPEG at around 50% quality.
CreateFolder - simply creates a folder.
DelMenuID
DragRect - allows you to drag a button with the outline visible.
DragSelect - allows you to set the size and position of a button to the rect drawn by the user.
DrawCIcon - very useful, allows you to display colour icons. A must have in colour stacks.
DrawMercury - Used on a button fills it red from the top to a certain percentage of the height of the button. Quite useful and can easily be made into a slidable selection.
findFilePath - finds a file, and if fails asks the user to find it. Quite useful indeed.
findLines - returns the line or lines (controllable) which contain the specified text in the specified variable. Can be useful.
getStr - returns a specified string resourcefrom your stack. Is a great way for making programs with multiple languages, as you just replace the string resource to change the language.
getText - does similar, except grabs the text resource instead, which can be infinite length (I think) and allows formatting as well.
has32bitQD - returns true if the user has 32-bit QuickDraw installed.
HideDesktop - excellent tool for displaying either a colour or a pattern instead of the Finder background, and can easily be manipulated. Very cool, extremely useful and includes a good looking example pattern to boot. :)
HideHCPals - hides all the palettes currently open.
isAPPL - allows you to find out if the Finder knows about a specified application, with the creator type you specify.
isPowerMac - very simple check to see if PowerPC or not.
itemMatch - matches one string with text in another string.
keyEvent - returns various values based on what keys are down. Does strange things if you hold down option and/or control, but recognises the command key and returns true or false based on at.
lineMatch - similar to itemMatch.
MakeTextRes - takes the specified text and puts it into the current stack as a resource.
mappedColor - buggered if I know.
MarchAnts - yes, finally, what you've always wanted, a bunch of black and white lines rotating around something. Is actually quite useful, and gives some nice effects used with buttons.
movieBounds - takes specified movie file and sees what dimensions it is.
NewMenuID - adds a menu to the menubar from the stack resource fork, which allows you to design menu's using ResEdit beforehand.
pictBounds - same as movieBounds but for pict files.
playSndFile - plays a sound file, you know, the ones you double click in the finder to play. Very good if you have many sound files and/or they are large ones. Best used to make sounds optional, so you don't need them and thus cut down the program size.
PostClick - allows you to make the mouse click at a specified point, great for controlling other programs. :)
rasterizePict - only used by those who know what it means. :)
recordSound - allows the user to record a sound which is then saved into the current stack.
resInfo - buggered if I know.
resListSize - same as above.
ScreenShot - takes a snapshot and saves to a pict file. Snapshot can be a particular window, rect area or the whole screen.
SetVisible - sets whether a certain item is visible or not. Very useful for hiding prefs files in time-limited demo's etc.
ShowHCPals - does the reverse of hideHCPals.
wilyOffset - beyond me, you figure it out. :)

CommConnect. This stack includes xfcn's that allow you to use serial ports, such as those used for networking, printing and modems. It would be very useful for making a game playable over a serial port, and probably has big implications in the modem area, although you'll need to know quite a bit about modem and tcp/ip communication to get the most out of it.

Compression Stack. This stack contains a bunch of xcmd's that use the LZW compression scheme to compress text or files. Manages to get about 50% compression on most things, so it's pretty good, and is quite fast. Personally, I prefer the StuffIt xcmd's, as they do a much better job and are quite fast, but since they require the StuffIt engine, this stack is in some ways better.

Core Collection. A bunch of really useful xcmd's and xfcn's, and a must have. I use a lot of there things in my stacks, and all work perfectly. This may be the most useful stack you can download here, so I strongly suggest you get it now. :)

AboutBoxScroll - displays a window stored in the stacks resource with the stylized text also kept in the resource. Very good for About... dialogs etc.
BootVolume - returns the name of the disk which booted the computer. Good for finding the system folder and thus the prefs folder.
BumpDate - resets the creation and/or modification date of a specified file to the current date and time.
ChangeCreator - changes the creator type of a specified file. Good for creating pref files and associating them with your stack/app. Very useful indeed.
ChangeDelimiter - if you have a list such as "1,2,3,4,5,6,7,8" but you wanted to seperate each number instead with a space, e.g. "1 2 3 4 5 6 7 8", then you use this xfcn. Works very fast, too.
ChangeType - changes the type of a specified file, similar to changeCreator.
CompareDate - allows you to compare two files and see which is the newest one.
CompareString - compares two strings given to it to find if they are the same (case sensitive).
CopyFile - copies the specified file to the specified location. Very useful, and quite fast. Allows you to specify whether or not to replace existing files, as well.
CreateAlias - allows you to create an alias of a file and put it wherever you like, such as the Startup Items folder. :)
CreatePath - give it a path and it will make sure it exists by creating all the neccesary folders for infinite levels. It won't replace existing ones and doesn't effect any existing files, so is quite safe to use.
DeleteFile - very simply deletes a specified file. Useful for uninstalling your stack or something.
DeleteFolder - the above for folders.
DoesExist - checks to see if the specified file exists or not. Useful for finding whether you've got pictures and movie files or not, and should be used before ever using "open file" to make sure you won't be creating a new one, or to make sure you are. :)
EjectDisk - ejects the specified disk, very simple.
FolderContents - really kick ... function that gives you a list of files and folders in the specified folder. Great for building up a database of someones hard drive or a disk. Unfortunately, the stack I have doesn't seem to have the xfcn installed. :(
FolderIsShared - finds out if the specified folder is being shared.
FolderPath - allows you to find certain folders, such as the prefs folder, apple menu items and more.
GetAppPath - finds all copies of an application with the specified creator type.
GetComments - returns whatever is in the comments field in Get Info for the specified file or folder.
GetDefaultFile - the same as answer file really, but apparently fixes a problem with System 7.5.
GetDepth - returns current and maximum depth in bits of the main monitor.
GetFileName - gets rid of the directories and returns just the file name with the result of a answer file dialog.
GetFileSize - tells you how big the specified file is. Doesn't work on folders though. Returns the size of the data fork and the resource fork.
GetFolder - displays file dialog which only lists folders and allows you to select a folder. Useful for install programs etc. except it doesn't allow you to create a folder with the file dialog.
GetInfoBox - opens Get Info on any specified application, but the xfcn seems to be missing.
GetManager - returns whether or not the specified item is available, such as speech, networking, the web etc. Really really useful, a must have. :)
GetRAM - tells you how much ram available. Surprisingly useful for its simplicity. Returns as physical ram and logical ram (which includes virtual memory)
GetSetup - returns machine name, user name and printer type.
GetString - returns the specified string resource, only available in current stack.
GetTypeCount - returns how many files of the type specified on the same disk as the stack calling it. Pity it can't search a specified disk.
GetVersion - utilizes the vers resource in a file or app to return the version information of it.
IsAppleShare - tells you if the specified file is in an Appleshare volume.
IsRunning - tells you if the application of creator type specified is running.
IsVirtualOn - tells you simply whether virtual memory is on or not.
LockFile - allows you to lock or unlock a specified file.
LockName - locks or unlocks the name of a specified file. The file can still be deleted and moved, but can't be renamed.
Mount - mounts an appleshare volume. Really quite cool, but you need a network, which I don't, so I haven't tested it yet. :)
MoveToTrash - moves a specified file to trash. Luckily there's no xcmd to empty the trash, or we'd get a rash of missing system files. :)
PadList - seems to just convert numbers to dollars and cents, i.e. 46 becomes $46.00.
PasswordDialog - displays a dialog box with two input areas, one of which produces bullets instead of letters, and can use a specified default name. Doesn't encrypt the result, which is good.
ProgressBar - if you've tried my stacks you might have noticed I use this a fair bit. Displays a progress bar in the field specified with the percentage specified.
PutDefaultFile - displays a simple save dialog box. Once again, useless except it apparently fixes some bug with System 7.5.
ReadWritePrefs - allows you to write or read a value from a special resource stored in a specified file name in the prefs folder. Really cool and very simple to use, but I don't know what happens if you write to it, whether it goes on the end or overwrites what's there already.
RenameFile - renames the specified file to specified name. Wants a full path name for both, so perhaps a different path in the new name will move the file.
RestoreClut - restores the active colour palette to the normal system one, good if some nasty programs changed it all.
SetComment - puts specified text into the comment field of specified file.
SetDepth - changes the depth of the main monitor using specified bit.
SetTitle - changes the title of the current window. Really cool. :)
SetVisible - makes a file or folder invisible or visible.
ShowAboutBox - displays a simple box stored as a window resource in the current stack with graphics and whatever.
StripList - cuts out various things from a string. Could be useful, but seems a bit useless from my point of view.
Unmount - will unmount a specified Appleshare volume. Simple. :)
UseCustomIcon - tells the specified file or folder to either use a custom icon or not to use one.
Volumes - returns all the mounted volumes in a list, really cool. :)

Gestalt. This xfcn returns lots and lots of information about the computer it is running on, including type, cpu, OS version etc etc etc. Very useful indeed.

HyperFTP. Uses various xcmd's and things to actually create a working ftp client. A very good starting point for those thinking of making their own ftp-enabled stacks.

HyperHTTP. One of the best web-orientated stacks I've ever come across. Gives you the ability to receive html files (possibly other files too) via the web, and format them as text using a parsing xcmd, etc etc. I'm using it in my up and coming SiteFetch and FindIt programs, and it should be very good when finished. A simple *must* have stack for anyone on the net, and that obviously means you! :)

InputDialog - Allows you to display a large dialog with multiple text input fields, radio buttons and buttons. Pretty good, but the documentation and format for using the xfcn is a bit difficult to grasp.

MacTCP Toolkit. This collection of files, stacks and xcmd's allows you to do all kinds of wonderous things with TCP/IP. It supports connection, data transfer, domain name lookup etc etc. I haven't had time to experiment properly with it, but it looks to be a very good and well documented stack.

SendAEdata. This is a really great little xcmd which allows you to send appleEvents in a way much easier and more powerful than the normal Hypercard method. It allows you to very easily specify class, the id, the data (up to something like 60000 chars in the worst-case scenario!). I've adopted it in my NetChat programs, because you can easily specify class and ID etc. I suggest if you are going to do anything involving AppleEvents you definitely get this little beauty of a xcmd right now.

SetCursorVisible. Deserves a special mention. Allows you to turn the cursor invisible and visible, but when you click on a menu it becomes visible. Can be solved by hiding the menubar though. :) Requires $15 licensing fee for anything but freeware distribution and even wants $15 if you use it in-house.

Shutdown. This very powerful xcmd allows you to shutdown or restart the computer upon which it is running. The xcmd call sets up the restart/shutdown, and when the user or a script quits Hypercard, the computer does as was set.

SoundVol. Another special mention. Allows you to find out and also to change the sound volume.

StuffIt XCMD's. This is one of the greatest little xcmd's. It allows you to compress and uncompress the specified file, while also allowing you to specify the compressed files filename etc etc. It requires the StuffIt Engine to be installed in the system folder, though.

X-Archive. Yes, finally, the great archive itself, created by F. Rinaldi, a famous Hypercard xcmd'er. I personally think the Core Collection is more useful and has better documention, but I can't argue with the thousands of Hypercarders who do use Rinaldi's scripts. There are quite a few useful bits in there, but a lot of them seem either beyond my needs or beyond my capabilities as a normal person to understand. Anyway, the xcmd's included are (there's a lot):

Align - aligns text using a specified format. Really complicated to the point of stupity, for me, anyway. :) But it is extremely powerful if you figure out how it works.
ArchiveContent - returns a list of files in the specified CompactPro archive. Pity no one uses CompactPro anymore. :P
ATalkZones - returns the current zone and the available zones on known networks. Quite useful probably, though I haven't looked in any great detail.
Calendoid - Displays a nice colour calendar which tells you exactly which day and which week the selected date is. Very similar to the Caliban's XCMD calendar.
CapsLock - very simply tells you if the caps-lock key is down or not. Useful for auto-fire in games etc.
ChooseColor - opens up the colour selection box and returns the chosen colour back. Quite useful I suppose, for some things.
Chooser - tells you the current printer, available printers and allows you to set the printer. Could be useful for printing out stacks over networks etc.
ClipInfo - tells you the type of resource in the clipboard, whether sound, pict or text etc...
ClipToPict - takes the picture on the clipboard and either saves it in the specified file or the resource fork of the current stack, and allows you to set things like depth, compression etc.
CompressPictFile - uses QuickTime JPEG to compress the specified file.
CopyFolder - copies a specified folder to somewhere including all files within it.
CopyRes - copies the specified resource type and id from a specified file to another file, with options such as don't overwrite etc.
CreateAlias - creates and alias of the specified file in the specified location.
CreateCustomIcon - creates a custom icon in the specified image file, using the image data to create a small preview.
CreateFolder - creates a folder at the specified location.
CreateHelpMenu - really useful for creating help about various menus and their items. Includes a built-in editor for creating the menu help, and looks like it could work very very well.
CreateStack - creates a stack with the specified name (puts it in same folder as current stack) or pathname. Doesn't do anything with it though.
CreateThumbnail - adds a preview resource to any picture file supported by Quicktime, which means if you have QuickTime 3, just about any file. This makes the files pretty big though.
DateConverter - converts a specified date to the number of seconds since January 1st, 1904, and back. Can't imagine any actual use for this myself.
DateSort - sorts all the lines in a variable and returns them in date sorted format, from earliest at the top to no-date on line at the bottom.
DocCreater - returns the full Hyper-happy pathname of all files of a specified type on the specified or all volumes.
DocTypes - returns a list of documents the specified application can open.
DoMenu - apparently some kind of enhanced doMenu xcmd, but it doesn't seem to work properly according to its own demonstration.
ExtractItem - extracts a bunch of items from a list. Why? Because you can.
FileCopy - copies a specified file to specified location.
FileIsOpen - tells you if the specified file is open or not.
FileMaker - no, not the award winning database program, but some kind of editor thing that does weird things and has almost no documentation. Bugger. :(
FileSharing Master - a collection of 3 xcmd's & 3 xfcn's that allow you to control file sharing. These could be useful for automating a web site.
FindFolder - returns the full path of all active system folders and system-related folders.
FolderSize - returns a bunch of numbers which don't seem to be formated properly about a folder.
FontMaster - handles fonts and stuff, but seems a bit underpowered and limited.
FormatNum - does some pretty complex stuff with specified number using specified format. Apparently works like the similar function in M$ Excel, but since we're all loyal Mac supporters and don't use Micro$haft Bloatware, we wouldn't know, would we... :)
FullBalloons - allows you to display balloon help. Might be the same thing as the seperate Balloons stack I mentioned earlier, I'm not sure.
FullDrag - allows you to drag various buttons and rects, and has room for a condition which runs a script if true. Pretty neat, and the demo is nice but limited.
FullFind - we've seen enough of these to know what they do.
FullHPop - displays a popup menu which can use special fonts and icons and things, which is pretty cool, but apparently there are several problems with it under various conditions. Still, it seems to work fine for me.
FullMove - moves the specified file or folder to the specified location which must be on the same volume (obviously).
FullOffset - I apologise, but although I know the offset command is good and useful, I haven't used it before. And thus, this extention for it means little to me, but I gather from looking at it that it adds search modes and more options which look like they could be quite helpful.
FullRemove - say byebye to the specified file or folder. This deletes it completely (it doesn't move it to the trash).
FullRename - renames a file or folder and updates user & groups info so it works just like the old version.
FullReplace - another search and replace. Need I say more? :)
FullResList - gives you a list of all the resources of the specified type in the specified file. Doesn't work in the example, but that's just bad exampling, and it probably works when you use it properly.
FullSFPack - now this is a really useful little bit. It allows you to use any type of file dialog you can think of and have seen, including multiple-selection, quicktime (gives you a preview box) and volume selection. This could be very very useful, and now that I've just realized it's here, I'm going to implement it in several of my stakz. :) Thanks people for making me type this up, if I hadn't, I never would have know. ;)
FullSFPut - don't know why this exists, since its covered by the previous xfcn, but its here.
FullSort - *boggle* This looks very very complicated, and I haven't used it before, but from reading and testing it I'd say it would work perfectly for anyone needing to sort something. I'm guessing though, so don't take my word for it. :)
GetFullText - this takes the text from a field along with style information, so bold text remains bold rather than reverting to plain. Its sister xcmd setFullText puts this text into another field. Great for duplicating fields.
GetBootVol - returns the boot volume, obviously.
GetDir - returns a list of items in the specified directory. Also returns a : after folders so you can figure out which is which.
GetFInfo - returns all the Get Info information about the specified file. Example doesn't work but I'm pretty sure it does work if you do it properly.
GetIcon - allows you to add an icon from the specified file to the current stack. Could be good for building an icon database.
GetMode - returns depth and dimensions of the current monitor along with other strange information which makes it slightly confusing.
GetPassword - obviously Rinaldi never heard of the "ask password" function. This is totally pointless.
GetSysFolder - returns the system folder path, which also points out the boot volume. Very helpful.
GetVInfo - returns a bunch of Get Info information about the specified volume. Is pretty good.
GlobalList - returns all the global variables currently initialized. The example doesn't work because answer dialogs are limited to 255 chars, so if you want to see it working you'll have to put the result into a field.
GlobalMaster - saves globals and clears them and stuff. Could be useful when restarting a game or stack.
HowMany - returns how many times specified text appears in the second bit of specified text, usually a variable holding a field. Is good for counting various things, such as the number of "a" 's or something. :)
ICNTtoICON - copies icons from one file to another, supposedly. I can't get it to work, though.
Infoid - opens a palette containing some info about the specified object. Doesn't have a check to see it the palette already exists though, which is kind of silly.
IsDate - tells you if a specified date is the current date. Don't know why "if mydate = the date" doesn't work, but... :)
IsFile - supposedly searches for specified file on specified volume, but doesn't seem to return anything but false no matter what I type. Wierd.
IsFinderLocked - returns whether or not the Finder file itself is locked. Doesn't work in the example though.
IsFolder - returns whether the specified path exists or not. This one actually works, too.
IsObject - returns whether a specified object (e.g. "cd fld something") exists or not. Seems to work as well.
KillRes - deletes the specified resource in the specified file or current stack.
LaunchDoc - This either opens or prints the specified file by finding the application that owns it and opening that. Don't know what happens if it can't find the application.
LineCount - returns the amount of physical lines in a field, treating all lines that are wrapped as their own line, rather than one. This gives you true lines, rather than how many numToChar's of 13 as the normal "number of lines in field xxx" does.
ListComponents - returns all the installed components, whatever that means. On my computer it says can't put more than 30k in a field, so it sorta screws up, but it seems to work okay, apart from that, obviously.
ListLogic - allows you to perform AND, OR, XOR & NOT functions on two specified pieces of text and returns the result. Could have easily been done with HyperTalk as a script, but with large fields and variables, it is probably a lot faster.
Listoid - displays a nice colourful window with the specified contents. When clicked, the window sends some kind of message to the current card or something, and when doubleclicked also sends which item was clicked on. Quite useful.
ListSelect - allows you to display many different selection dialogs, with custom fonts and other things. No real *need* for this, since similar things can already be achieved without it, but some people just *have* to have all the gadgets. Like me. :)
MacType - this returns all the information about your computer, including CPU type and make, OS version etc etc.
Menu - does a bunch of things with menu's, including giving them icons and things, but doesn't seem to work in the example, although I didn't play around for that long.
Mouseoid - displays a palette with information about the mouses current position in it relative to the current stack window (so to the left is a negative value as is above the stack window, in the menu bar and whatever).
NameNewFile - only useful in version of HC before 2.0 which didn't have the "ask file" feature.
Notification - You know those programs that, if left running in the background, beep and flash the program menu impatiently? Well, now your stacks can be one of those impatient programs. :) It's actually quite good, and has many practical applications.
NubusList - returns a list of installed nubus cards. Although my PPC is Nubus, it doesn't have any cards installed, so I don't have a clue how the result is formatted and whatever.
PictFile - copies the clipboard to file or the other way round, but as with nearly everything in the main stack, the demonstration doesn't work.
PictToClip - moves Jfif, MooV, Pict and JPEG file specified to the clipboard, changing it as needed.
PPCList - returns a list of PPC-happy programs on the specified computer on the specified node, as well as that applications creator type. Bit too much use in the areas of snooping on other people, but it seems harmless enough.
PrinterInfo - gives you info on the current printer. Since I don't have one installed, all I get are errors, but others might have more luck.
PrintPICT - prints a file, clipboard or resource specified.
PrintPictList - same as above except allows a big long list of files to print.
Privileges - returns information about the specified folder to do with file sharing.
Prompt - displays information about whats happening apparently. Doesn't work though.
Promptoid - the working version of the above. Displays a prompt dialog with an icon and the width of the first string. Larger strings after that I assume expand the dialog, but knowing this stack, probably just get cut off.
QCopy - small xcmd that copies all the resources of the current stack into the specified file.
RemoveFolder - deletes the specified folder, including contents.
ReplaceCharSet - allows you to replace the specified letters with the second set of specified letters in the specified text.
ResolveAlias - returns the pathname of the original file of an alias.
ResText - allows you to get text from the resource of any specified file or stack.
ScrapXCMDs - a bunch of xcmd's that allow you to move the clipboard to a specified scrapbook and the reverse.
SelectDir - allows you to provide a folder select dialog. Already include in the FullSFPack, so is pretty useless by itself.
SelectFile - standard file selection dialog. Why? Who knows.
SendPS - send postscript data over a network to a printer. In the demonstration simply shows a bunch of letters at the top of the screen which I can't get rid of unless moving something over them. Freaky.
SetFileFlag - allows you to change the specified flag of the specified file to the specified value. :)
SetFinderLock - unlocks and locks the specified file, very simple.
SetFInfo - allows you to change the file type and/or creator type of the specified file.
SetMode - changes the screen depth. Not recommended...blahblahblah... :)
Set XCMD - intercepts all "set ..." messages, and allows you to set the userlevel to 0, which is similar to userlevel 2, but with no go menu and a smaller edit menu. Probably quite good, but I have no need for it in any of my open staks.
ShowHideFolder - makes the specified folder invisible or visible.
SoundRecord - neato little thing that allows you to record a sound using the standard 10-second record dialog. Can save into any stack. Also works with Supercard, as a bonus.
StringDup - removes all duplicated items from the specified string.
StrWidth - returns the width in pixels of the specified text using specified font, size and style. Good for figuring out what font to use that will fit into a field properly.
Switch - transforms lines to comma-delimeted list, and back again. Pretty useless, imho.
Tabloid - displays a table in a new window with specified values and of specified size. Looks pretty good and might have some half-decent implementations.
Textoid - allows you to display some really good looking windows with the specified text and someone it calls a certain script when clicked on. Neato.
TextRes - allows you to create a text or string resource in the specified file with the specified value.
WindName - changes the name of the stack window. Boring.
XRef - cross-references various handlers or something. I'm too tired at the moment to go back and have a look, so :P

Pretty Lousy Privacy. This simple stack has an XCMD that encrypts the specified data using ROT13 or ROTxx encryption, both of which are pretty hopeless as far as security is concerned, but a few thousand characters take half a second, so it's fairly quick.


Email me - waderad@i.net.au
1