TweetFollow Us on Twitter

Jan 97 Tips

Volume Number: 13 (1997)
Issue Number: 1
Column Tag: Tips & Tidbits

Tips & Tidbits

By Jessica Courtney

When releasing a number of public development, alpha, and beta versions of software, it is a good idea to display the version number within the application - for example, in the splash screen, or about box. However, the format of the 'vers' resource is a little bizarre, making getting to this information a little difficult.

GetVersNumString() is a handy function that reads an application's 'vers' resource, constructs the version number, and returns it in a pascal string. It might not be the most efficient way to do this, but it does the job. My version of this function will not print the third piece of the version number if it equals zero (i.e., print "1.1" not "1.1.0"). The if-statement controlling this decision is easy to remove - more ambitious programmers might make it an optional parameter.

I've also included Str255-copy and Str255-concatenation routines to make this tip complete, just incase you don't already have some available.

/* GetVersNumString
 * Reads 'vers' resource #1 and constructs a string like "\p1.0d3"...
 * If it can't find 'vers' #1, it returns an empty string.
 * NOTE: The application resource file must be the active resource file!
 */
void GetVersNumString(Str255 versStr)
{
 Handle  versHdl;
 long    version;
 unsigned char   ver1,ver2,ver3,relStatus,prerelNum;
 Str255  tmp;

    // clear string;
 versStr[0]=0;

    // read version no. information
 versHdl = GetResource('vers',1);
 if (!versHdl) {
 return;
 }
 version = *((long *)(*versHdl));
 ReleaseResource(versHdl);

    // Set ver1-3, relStatus, prerelNum from the version info.
    // Note that the first two bytes are in an unusual format.
 ver1 = ((char *)&version)[0];
 ver1 = (((ver1 & 0xF0) >> 4) * 10) + (ver1 & 0x0F);
 ver2 = (((char *)&version)[1] & 0xF0) >> 4;
 ver3 = (((char *)&version)[1] & 0x0F);
 relStatus = ((char *)&version)[2];
 prerelNum = ((char *)&version)[3];

    // Insert v1 and v2 into our version string.
 NumToString((long)ver1,tmp);
 PStringCat(versStr,tmp);
 PStringCat(versStr,"\p.");
 NumToString((long)ver2,tmp);
 PStringCat(versStr,tmp);
    // For convenience, we only print the third number if it is  non-zero.
    // If you always want all three numbers, remove the if-statement.
 if (ver3) {
 PStringCat(versStr,"\p.");
 NumToString((long)ver3,tmp);
 PStringCat(versStr,tmp);
 }

    // If the release status is development, alpha, or beta, add a
    // 'd', 'a', or 'b' to our version string.
 switch(relStatus){
 case 0x20: // development
 PStringCat(versStr,"\pd");
 break;
 case 0x40: // alpha
 PStringCat(versStr,"\pa");
 break;
 case 0x60: // beta
 PStringCat(versStr,"\pb");
 break;
 default:
 ;
 }

    // lastly, if we've added a 'd', 'a', or 'b', print the pre-release
    // number at the end.
 if (relStatus != 0x80) {
 NumToString((long)prerelNum,tmp);
 PStringCat(versStr,tmp);
 }
}

/* PStringCopy
 * Copy pascal string a into b.
 */

void PStringCopy(Str255 a, Str255 b)
{
 BlockMove(a,b, a[0] + 1);
}

/* PStringCat
 * Concatenate pascal strings a & b, return in a. If there isn't enough
 * room in our array to join both strings, return what we can.
 */

void PStringCat(Str255 a, Str255 b)
{
 short len;

 if ((a[0] + b[0]) > 255)
 len = 255-a[0];
 else
 len = b[0];

 BlockMove(&(b[1]),&(a[a[0]+1]),len);
 a[0] += len;
}

Michael Trent
mtrent@msn.fullfeed.com

 
AAPL
$99.80
Apple Inc.
-1.83
MSFT
$46.49
Microsoft Corpora
+0.25
GOOG
$576.89
Google Inc.
+3.79

MacTech Search:
Community Search:

Software Updates via MacUpdate

Adobe Acrobat Pro 11.0.09 - Powerful PDF...
Adobe Acrobat allows users to communicate and collaborate more effectively and securely. Unify a wide range of content in a single organized PDF Portfolio. Collaborate through electronic document... Read more
Adobe Reader 11.0.09 - View PDF document...
Adobe Reader allows users to view PDF documents. You may not know what a PDF file is, but you've probably come across one at some point. PDF files are used by companies and even the IRS to... Read more
iFFmpeg 4.6.1 - Convert multimedia files...
iFFmpeg is a graphical front-end for FFmpeg, a command-line tool used to convert multimedia files between formats. The command line instructions can be very hard to master/understand, so iFFmpeg does... Read more
NTFS 11.3.62 - Provides full read and wr...
Paragon NTFS breaks down the barriers between Windows and OS X. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS, providing full read and write access to... Read more
OS X Yosemite 10.10 DP8 - Developer Prev...
Note: This is a Developer Preview. You must be a registered Apple Mac Developer to download this update. You can also sign up for the free OS X Beta Program to download and preview public beta... Read more
FotoMagico 4.5 - Powerful slideshow crea...
FotoMagico lets you create professional slideshows from your photos and music with just a few, simple mouse clicks. It sports a very clean and intuitive yet powerful user interface. High image... Read more
Screenshot Path 1.2.1 - Change the defau...
Screenshot Path lets you change the folder where OS X saves screenshots. Screenshots are saved by default to the user’s desktop. This is handy for the occasional screenshot but those looking to take... Read more
Fantastical 1.3.16 - Create calendar eve...
Fantastical is the Mac calendar you'll actually enjoy using. Creating an event with Fantastical is quick, easy, and fun: Open Fantastical with a single click or keystroke Type in your event details... Read more
GIMP 2.8.14 - Powerful, free image editi...
GIMP is a multi-platform photo manipulation tool. GIMP is an acronym for GNU Image Manipulation Program. The GIMP is suitable for a variety of image manipulation tasks, including photo retouching,... Read more
HoudahSpot 3.9.3 - Advanced front-end fo...
HoudahSpot is an advanced file search tool built upon MacOS X Spotlight. Spotlight unleashed Create detailed queries to locate the exact file you need Narrow down searches. Zero in on files Save... Read more

Latest Forum Discussions

See All

Hyper Trip Review
Hyper Trip Review By Jennifer Allen on September 16th, 2014 Our Rating: :: HYPER TWITCHYUniversal App - Designed for iPhone and iPad Tough and unforgiving, Hyper Trip is a bit like Snake – if Snake was really harsh.   | Read more »
Collectible Card Game Earthcore: Shatter...
Collectible Card Game Earthcore: Shattered Elements is Set to Arrive on iOS in 2015 Posted by Ellis Spice on September 16th, 2014 [ permalink ] Polish developers | Read more »
Boogey Boy Review
Boogey Boy Review By Jennifer Allen on September 16th, 2014 Our Rating: :: PRETTY BUT BASICUniversal App - Designed for iPhone and iPad It looks delightful but lack of Game Center support and more variety really affects the fun... | Read more »
Vizzywig 4K (Photography)
Vizzywig 4K 1.0 Device: iOS iPhone Category: Photography Price: $999.99, Version: 1.0 (iTunes) Description: REQUIRES: iOS 7 on iPhone 5S with 32GB or 64GB. (Do not use iOS 8)The world's FIRST mobile 4K video capture, editing and... | Read more »
The Sleeping Prince Review
The Sleeping Prince Review By Jennifer Allen on September 15th, 2014 Our Rating: :: RESTRICTIVE KINGDOM SAVINGUniversal App - Designed for iPhone and iPad The Sleeping Prince looks and feels great to play, but its lack of peril and... | Read more »
It Came From Canada: Terra Battle
In some way or another, most Japanese RPGs owe something to Final Fantasy. But with Terra Battle, the now-common mix of Western medieval fantasy with Eastern anime aesthetic feels earned. After all, its developer, Mistwalker, was founded by the... | Read more »
Five Nights at Freddy’s Review
Five Nights at Freddy’s Review By Rob Thomas on September 15th, 2014 Our Rating: :: FIVE FRIGHTS AT FREDDY'SUniversal App - Designed for iPhone and iPad Can you survive five nights as the new night watchman of Freddy Fazbear’s... | Read more »
Phantom Rift Review
Phantom Rift Review By Nadia Oxford on September 15th, 2014 Our Rating: :: FRIENDLY PHANTOMUniversal App - Designed for iPhone and iPad Despite a snag here and there, Phantom Rift is a well-crafted and imaginative adventure RPG.   | Read more »
Phantom Rift – Tips, Tricks, Strategies,...
Hello, Wanderers: | Read more »
Meet the Newest Character for Temple Run...
Meet the Newest Character for Temple Run 2, from National Geographic Kids’ Action-Adventure Book Posted by Jessica Fisher on September 15th, 2014 [ | Read more »

Price Scanner via MacPrices.net

Free GIMP Professional Grade Graphics App Ver...
The latest 2.8.14 version of the oddly-named GIMP (acronym for: GNU Image Manipulation Program) open source, high-end image editing and creation alternative to Adobe’s Photoshop and refuge from... Read more
10% off iPhone 6 and 6 Plus Otterbox cases
Get 10% off on popular Otterbox iPhone 6 and iPhone 6 Plus cases at MacMall through September 19th. Use code OTTERBOX10 to see the discount. Read more
15-inch MacBook Pros on sale for up to $125 o...
Amazon has the new 2014 15″ Retina MacBook Pros on sale for up to $125 off MSRP including free shipping: - 15″ 2.2GHz Retina MacBook Pro: $1899.99 save $100 - 15″ 2.5GHz Retina MacBook Pro: $2374... Read more
27-inch 3.2GHz iMac on sale for $1698, $101 o...
Abt has the 27″ 3.2GHz iMac on sale for $1698 including free shipping. Their price is $101 off MSRP. Read more
More To Making A Larger iPad Than Expanded Sc...
CNET’s Ross Rubin has posted a thoughtful analysis of prospects for a larger display iPad Pro, noting that Microsoft and Samsung currently have the large-display touchscreen tablet category to... Read more
SwiftKey Keyboard Finally Coming To iPhone An...
At the TechCrunch Disrupt event in San Francisco, Swiftkey unveiled the first details about SwiftKey Keyboard for iPhone, iPad & iPod touch. SwiftKey’s philosophy is that you should be able to... Read more
Save $75 on the 16GB iPad mini with Retina Di...
Best Buy has the 16GB iPad mini with Retina Display on sale for $324.99 on their online store for a limited time. Their price is $75 off MSRP, and it’s the lowest price available for this mini.... Read more
21-inch 1.4GHz iMac on sale for $979, $120 of...
B&H Photo has the new 21″ 1.4GHz iMac on sale for $979.99 including free shipping plus NY sales tax only. Their price is $120 off MSRP. B&H will also include free copies of Parallels Desktop... Read more
Apple restocks refurbished 21-inch 1.4GHz iMa...
The Apple Store has restocked Apple Certified Refurbished 21″ 1.4GHz iMacs for $929 including free shipping plus Apple’s standard one-year warranty. Their price is $170 off the cost of new models,... Read more
13-inch 2.6GHz/256GB Retina MacBook Pro on sa...
Adorama has the 13″ 2.6GHz/256GB Retina MacBook Pro on sale for $1379 including free shipping plus NY & NJ sales tax only. Their price is $120 off MSRP, and it’s the lowest price available for... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.