HOWPRMPT.TXT ============================================================================= WildCat Prompt Files Explained for wcCode Applications by Richard R. Sands email: rrsands@aol.com or 70274.103@compuserve.com "I am not affiliated with Mustang Software, Inc" "I am not responible for any errors" "All Comments and Suggestions are Welcome" ----------------------------------------------------------------------------- Overview -------- Prompt files are just binary files which have every prompt and message your program uses in a quickly accessible format. Whenever your program requires a string to display, it reads the string from disk. Although this seems like it would be slow, in reality, it is hardly even noticed. While using prompt files makes your program slightly slower and somewhat more complicated, it generally make your program smaller and gives it a lot more versatility. If you provide a prompt and default file, you and other sysops working with your application can customize it for both language and "look and feel". As a nice addition, it will also make RIP support easier. ----------------------------------------------------------------------------- Creating A New Prompt File -------------------------- The following steps will allow you to create a "standard" prompt file that can be read and edited by Mustang's wcPrompt program and processed quickly by your wcCode application. 1. Create a text file with an .ASC extension using a ASCII text editor (eg. MSDOS EDIT). See sections "ASCII Prompt Format" and "What To Make Prompts?". 2. Start the wcPrompt program and use the "Load ASCII prompts" to bring in the newly created file. 3. Save the new prompt file with the "Save Prompts" command with the default .PRM extension. This creates the Binary Prompt file that is used by your application. 4. Save the file AGAIN but this time instead of using the default file extension of .PRM, save it to the same location with a .DEF file extension. This creates the file that is used with the RESTORE command while editing a prompt if you accidently messed one up. ----------------------------------------------------------------------------- ASCII Prompt Format ------------------- When creating the ASCII file to convert to a WildCat prompt file, you need to ensure two things: 1. None of your prompts are over 160 characters including any @codes@. 2. You need to include a RIP copy of all your prompts following your normal prompts. The easiest way to start out is to just copy the whole ansi section and duplicate it after the last line. Here is a two line prompt file (2 "ansi" and 2 RIP): @0E@This is the @0F@first@0E@ prompt. @0E@This is another, @0F@better@0E@ prompt. @0E@This is the @0F@first@0E@ prompt. @0E@This is another, @0F@better@0E@ prompt. ----------------------------------------------------------------------------- What To Make Prompts? --------------------- You will want to put all the literals ("A Literal") in your application into the prompt file including the @codes@. The major exception to this rule would be your logo and copyrights. The easiest way to do this is to copy your programs into another file, and then delete everything but the literals. You need to then remove the double-quotes, and if you have variables being printed out in a prompt, you need to replace those with @SUB1@, @SUB2@, etc. The @SUBn@ command is used to pass information from your program into a prompt or display file. You use the command SUBTEXT to set the values of the @SUBn@ codes before printing the prompt. Wildcat supports up to ten @SUBn@ codes. For instance, if you have: "You have ";Score;"points, Hiscore is ";HiScore Your prompt would then look like: You have @SUB1@ points, Hiscore is @SUB2@ In your program you would then use the SUBTEXT command to set the values in place: SubText 1, str(Score) SubText 2, str(HiScore) Print "You have @SUB1@ points, Hiscore is @SUB2@" Of course, you wouldn't actually have the prompt literally like that, it would be taken from the prompt file. See the next section. ----------------------------------------------------------------------------- Code Implementation (from WcList) --------------------------------- Consult the file PRMFILE.WCC taken from the sample "WCLIST" program included in the CODESAMP directory. That file defines two routines you need to know about. [NOTE: I have included PRMFILE.WCC just so you don't have to hunt around for it if you have already deleted that directory] sub OpenPrompts(fname as string) Before printing anything, this routine is called and will open the prompt file using the file handle #9 or halt the program with a fatal error. You should pass the name of the prompt file itself without the path. Example: OpenPrompts("MYPROG.PRM") function GetText(i as integer) as string This routine will return the string specified by prompt number I, or display a RIP file and return "". Since this routine will do the work of displaying a rip file, that implies you cannot read in a prompt into a variable to use later. Example: Print GetText(23) 'whatever 23 is defined as If that prompt needs a SubText command, then include those commands before printing. SubText 1, str(Score) SubText 2, str(HiScore) Print GetText(prShowScore) 'defined const makes clearer