| ! -------------------------------------------------------------- | |
| ! Dunno - A Libary Extension by Neil Cerutti (cerutti@together.net) | |
| ! Version 1.0 - 25 Jun 1999 | |
| ! Initial release | |
| ! Version 1.1 - 2 Apr 2001 | |
| ! Modified by Andrew Plotkin for Glulx compatibility. | |
| ! | |
| ! If, for some reason, you always wanted the Infocom-style error | |
| ! messages that say: | |
| ! | |
| ! I don't know the word "kludge". | |
| ! | |
| ! here's one way to do it. | |
| ! | |
| ! To use this file, put the command | |
| ! | |
| ! Include "dunno.h"; | |
| ! | |
| ! somewhere in your program's source code. | |
| ! | |
| ! The DontKnowError() routine must be called from within your | |
| ! program in one of the following two ways: | |
| ! | |
| ! 1. in the ParserError entry point [Inform Designer's Manual, | |
| ! Graham Nelson, Section 29]. For example: | |
| ! | |
| ! [ ParserError pe; | |
| ! if (pe == CANTSEE_PE) return DontKnowError(); | |
| ! rfalse; | |
| ! ]; | |
| ! | |
| ! or | |
| ! | |
| ! 2. in the LibraryMessages object [Nelson, Section 21]. For example: | |
| ! | |
| ! Object LibraryMessages with before [; | |
| ! Miscellany: if (lm_n == 30) return DontKnowError(); | |
| ! ]; | |
| ! | |
| ! If you need help getting this to work, or just have comments or | |
| ! suggestions, write me at cerutti@together.net. | |
| ! --------------------------------------------------------------- | |
| ! Check for an unknown word in the input starting at word 2. If one | |
| ! is found, print "I don't know the word ~xxx~." and return true. | |
| ! Otherwise, return false. | |
| [ DontKnowError | |
| wordnum; | |
| wordnum=FindUnknownWordToken(2); | |
| if (wordnum ~= 0) | |
| { print "I don't know the word ~"; | |
| PrintToken(wordnum); | |
| "~."; | |
| } | |
| else rfalse; | |
| ]; | |
| ! Find the word number of the word in the input that is an | |
| ! unknown word, starting at wordnum, and return it. If no unknown | |
| ! word is found, return false. | |
| ! | |
| ! An unknown word is defined: An item that is not in the | |
| ! dictionary and not a number. | |
| [ FindUnknownWordToken wordnum | |
| w twn numwds; | |
| numwds = parse-->0; | |
| numwds = parse->1; | |
| ! Throw out invalid word numbers | |
| if (wordnum <= 0 || wordnum > numwds) rfalse; | |
| twn=wn; ! save the value of wn so it can be restored | |
| wn=wordnum; | |
| while (1) | |
| { w=NextWordStopped(); | |
| if (w == -1) { wn=twn; rfalse; } | |
| if (w == 0 && TryNumber(wn-1) == -1000) | |
| { wordnum=wn-1; | |
| wn=twn; | |
| return wordnum; | |
| } | |
| } | |
| ]; | |
| ! Print the exact text in the input at wordnum. | |
| [ PrintToken wordnum | |
| k l m numwds; | |
| numwds = parse-->0; | |
| numwds = parse->1; | |
| if (wordnum <= 0 || wordnum > numwds) return; | |
| k=WordAddress(wordnum); | |
| l=WordLength(wordnum); | |
| for (m=0: m < l: m++) | |
| print (char) k->m; | |
| ]; | |
| ! --------------------------------------------------------------- | |
Xet Storage Details
- Size:
- 2.7 kB
- Xet hash:
- ee3bad8d683c2f9990d5770bc310dffb1ca38ad8f72c06cccb8c6a9c8a690391
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.