A Tale of Two Languages
Listing 1. Describing a CD Tray in Inform 7
094 The CD Tray is part of the old server. 095 The description is "It's a CD tray."
The differences between the two languages are apparent from the first lines. When starting a story in Inform 6, there are some essential housekeeping duties that need to be done at the beginning (i6:001-007) and end (i6:172-193) in order for the story to compile (Listing 2).
Listing 2. Essential Code for Compiling Inform 6
001 !% -SD 002 003 !======================================================== 004 Constant Story "The Server Room"; 005 Constant Headline 006 "^An Interactive Fiction by Daniel Bartholomew.^"; 007 Release 1; Serial "080625"; !for keeping track of releases . . 172 !======================================================== 173 ! Entry point routines 174 175 [ Initialise; 176 location = break_room; 177 "^^^^It's Saturday, a nice one at that, and you've been 178 called to fix a server. Again.^^You've had it. This 179 server is going to run Linux starting today! The process 180 will be easy, just put the disc into the server go. 181 Now where is that Ubuntu CD?^"; 182 ]; 183 184 [ Deathmessage; 185 if (deadflag == 5) print "You have won"; 186 ]; 187 188 !======================================================== 189 ! Standard and Extended Grammar 190 191 Include "Grammar"; 192 193 !========================================================
In Inform 7, the only thing that is absolutely required is the first line (i7:001). To be fair, the initialization routine in Inform 6 also includes the message that is displayed at the beginning of the game. In Inform 7 this also is there (i7:007-011), but it's not required for successful compilation (Listing 3).
Listing 3. Initial Program Code for Inform 7
001 "The Server Room" by "Daniel Bartholomew" 002 003 Include GNU GPL v3 by Free Software Foundation. 004 005 The maximum score is 6. 006 007 When play begins, say "It's Saturday, a nice one at that, 008 and you've been called to fix a server. Again. 009 [paragraph break]You've had it. This server is going to 010 run Linux starting today! The process will be easy, just put 011 the disk in the server and go. Now where is that Ubuntu CD?"
The defining of variables is similar in both versions—for instance, the maximum score variable (i6:009, i7:005). The main difference is that the Inform 6 version uses C-like syntax:
Constant MAX_SCORE = 6;
And, Inform 7 uses a sentence that reads similarly to how one would read the Inform 6 version out loud:
The maximum score is 6.
Some of the differences between versions are similarly minor. One example is the method of inserting paragraph breaks into long sections of text, such as in the description of the Server Room (i6:114-118, i7:082-086, Listing 4). In Inform 6, two carat symbols (^^) are used, and in Inform 7, the statement paragraph break enclosed in square brackets () does the job.
Listing 4. Syntax for Describing a Room
Inform 6 Version: 114 description "The fans, the lights, the chill... yep, it's a 115 server room. Full of servers from a dozen vendors, 116 each with their own quirks.^^Your attention is 117 immediately drawn to a server 2/3 of the way up rack 7. 118 The indicator light is blinking red and beeping.", Inform 7 Version: 082 The Server Room is a room. "The fans, the lights, the chill... 083 yep it's a server room. Full of servers from a dozen 084 vendors, each with their own quirks.[paragraph break]Your 085 attention is immediately drawn to a server 2/3 of the way up 086 rack 7. The indicator light is blinking red and beeping."
One big mistake I made when I started was creating everything first in Inform 7, and then creating the equivalent Inform 6 code. This proved tricky on a couple occasions—most notably with the random beeping messages that appear at every turn while you are in the server room (until you fix the server and win the game). Programming such logic is very different in each version. In Inform 7, writing this took almost no thought at all (i7:097-103). Basically, I described what I wanted to happen every turn, and Inform 7 made it happen. The Inform 6 code to do the same thing is not as advanced (i6:120-134). It's basically a case statement, but it's significantly more difficult to write in comparison (Listing 5).
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- ServersCheck's Thermal Imaging Camera Sensor
- The Italian Army Switches to LibreOffice
- Linux Mint 18
- Petros Koutoupis' RapidDisk
- Chris Birchall's Re-Engineering Legacy Software (Manning Publications)
- Oracle vs. Google: Round 2
- The FBI and the Mozilla Foundation Lock Horns over Known Security Hole
- Privacy and the New Math
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide