sub Authors ( \ byval Page_ID as string ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim Date_Now as date dim Time_Now as time ////////////////////////////////////////////////////////////////////// File_Num = FreeFile open Authors_BBS for append as File_Num CurrentDate ( Date_Now ) CurrentTime ( Time_Now ) ? #File_Num, FormatDate ( Date_Now, "yyyy-mm-dd" ); " "; ? #File_Num, FormatTime ( Time_Now, "hh:mm:ss" ); ? #File_Num, " "; Pad ( User.Name, 25 ); " Page "; Page_ID close ( File_Num ) end sub function Page_Options ( \ byval Page_ID as string ) as string ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim Line as string dim Options as string ////////////////////////////////////////////////////////////////////// Options = "" if Exists ( OPTIONS_PATH + Page_ID + ".OPT" ) then File_Num = FreeFile open OPTIONS_PATH + Page_ID + ".OPT" for input as File_Num do while not EOF ( File_Num ) input #File_Num, Line Options = Options + UCase ( Left ( Line, 1 ) ) loop close ( File_Num ) Page_Options = UCase ( Options ) end if end function function Page_Number ( byval Option as string ) as string ////////////////////////////////////////////////////////////////////// dim Next_Page as string ////////////////////////////////////////////////////////////////////// do ? ? "If you have a page number in mind already that this option should" ? "link to, you can enter it now. Otherwise, just hit ENTER and a" ? "page number will be determined automatically." ? ? "Page numbers (DOS filenames, really) should not be longer" ? "than 8 characters and will be converted to uppercase." ? ? "Special page numbers are 0 (quit game) and 1 (first page)." ? ? "Next page for option '"; Option; "' [ENTER = AUTOMATIC]: "; input Next_Page if Next_Page = "" then exit do end if Next_Page = UCase ( Left ( Trim ( Next_Page ), 8 ) ) rem Need to filter the filename better here if InStr ( Next_Page, "\" ) = 0 then if InputYesNo ( "{Page " + Next_Page + "}. Correct? (Y/n): ", true ) then if Next_Page = "0" then exit do end if if Exists ( OPTIONS_PATH + Next_Page + ".BBS" ) then ? "This page already exists. Link this option to it? (Y/n): "; if InputYesNo ( "", true ) then exit do end if else exit do end if end if else Beep ? "'\' characters should not be used in your page number." ? "Please try something different." WaitEnter end if loop Page_Number = Next_Page end function sub Page_Option_Add ( byval Page_ID as string ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim Next_Page as string dim Option as string*1 dim Options as string ////////////////////////////////////////////////////////////////////// Options = Options_Reserved + Page_Options ( Page_ID ) do ? ? "The option character will automatically be converted to uppercase." ? "The following option characters have already been used or reserved:" ? Options ? ? "Please enter the character for the new option [ENTER=Abort]: "; Input Option if Option = "" then exit sub end if Option = UCase ( Option ) if InStr ( Options, Option ) = 0 then exit do end if Beep ? "Option character '"; Option; "' has already been used or reserved." ? "Please choose another character for your new option." WaitEnter loop Next_Page = Page_Number ( Option ) File_Num = FreeFile open OPTIONS_PATH + Page_ID + ".OPT" for append as File_Num print #File_Num, Option + " " + Next_Page close ( File_Num ) end sub function Page_Create_Description ( byval Page_ID as string ) as boolean ////////////////////////////////////////////////////////////////////// Cls ? "You have 150 lines for your page description." ? ? "In your page description, you should present a menu of" ? "options for the reader to choose from." ? "Use single character letters or numbers for option keys." ? "Do not use the reserved characters """; Options_Reserved; """." ? ? "To save or abort, press your ESCAPE key then S or A." ? ? "If you know Wildcat @-codes, you can add colors." ? WaitEnter Page_Create_Description = \ EditFile ( OPTIONS_PATH + Page_ID + ".BBS", 150, \ "Description for page " + Page_ID, true ) end function function Options_Special ( byval Page_ID as string ) as string ////////////////////////////////////////////////////////////////////// dim Option as string*1 ////////////////////////////////////////////////////////////////////// do ? ? "SPECIAL OPTIONS" ? ? "Page "; Page_ID ? ? "A Add an option to this page" ? "B Back to the Page 1" ? "D Change this page's description" ? "Q Quit this program" ? "R Return to page" ? ? "Option [R]: "; input Option if Option = "" then Option = "R" end if Option = Ucase ( Option ) Options_Special = Option select case Option case "A" Page_Option_Add ( Page_ID ) exit function case "B" exit function case "D" Page_Create_Description ( Page_ID ) case "Q" exit function case "R" exit function case else Beep ? Option; " is not a recognized option. Please choose another." WaitEnter end select loop end function function Menu_Generic ( \ Page_ID as string, \ byval Options as string, \ byval Default as string ) \ as string ////////////////////////////////////////////////////////////////////// dim Option as string*2 ////////////////////////////////////////////////////////////////////// Options = UCase ( Options ) do ? ? "{Page "; Page_ID; "} Option? (!"; Options; ") ["; Default; "]: "; input Option Option = UCase ( Option ) if Option = "" then Option = UCase ( Default ) end if Menu_Generic = Option if Option = "!" then select case Options_Special ( Page_ID ) case "A" exit function case "B" Page_ID = "1" exit function case "Q" Page_ID = "0" exit function end select elseif InStr ( Options, Option ) > 0 then exit function else Beep ? ? Option; " is not a recognized option. Please choose another." ? WaitEnter end if DisplayFile ( PAGES_PATH + Page_ID ) loop end function function Page_ID_Next ( \ byval Page_ID as string, \ byval Option as string ) \ as string ////////////////////////////////////////////////////////////////////// dim File_Name_Num as long dim Temp as string ////////////////////////////////////////////////////////////////////// Temp = Page_ID + Option if ( len ( Temp ) > 8 ) \ or Exists ( OPTIONS_PATH + Temp + ".OPT" ) then File_Name_Num = 1 do while Exists ( OPTIONS_PATH + Temp + ".OPT" ) Temp = FormatNumber ( File_Name_Num, "@#######" ) File_Name_Num = File_Name_Num + 1 loop end if Page_ID_Next = Temp end function sub Menu_Page ( Page_ID as string ) ////////////////////////////////////////////////////////////////////// dim Create_Page_Ask as boolean dim Default as string*1 dim File_Num as integer dim Line as string dim Option as string*1 dim Options as string dim Page_ID_Old as string ////////////////////////////////////////////////////////////////////// Page_ID_Old = Page_ID Options = Page_Options ( Page_ID ) if Options = "" then Default = "!" else Default = Left ( Options, 1 ) end if Option = Menu_Generic ( Page_ID, Options, Default ) if not ( Option = "!" ) then File_Num = FreeFile open OPTIONS_PATH + Page_ID + ".OPT" for input as File_Num do while not EOF ( File_Num ) input #File_Num, Line if UCase ( Left ( Line, 1 ) ) = Option then Page_ID = UCase ( Trim ( Right ( Line, Len ( Line ) - 1 ) ) ) exit do end if loop close ( File_Num ) end if if Page_ID = "0" then Create_Page_Ask = false elseif Page_ID = "" then Create_Page_Ask = true elseif not DisplayFile ( PAGES_PATH + Page_ID ) then Create_Page_Ask = true else Create_Page_Ask = false end if if Create_Page_Ask then ? Color ( 12 ) ? "The page for this option has not been completed." ? if InputYesNo ( "Would you like to create this page? (y/N): ", false ) then if Page_ID = "" then Page_ID = Page_Number ( Option ) if Page_ID = "" then Page_ID = Page_ID_Next ( Page_ID_Old, Option ) end if end if if Page_ID <> "0" then if not Exists ( OPTIONS_PATH + Page_ID + ".BBS" ) then if not Page_Create_Description ( Page_ID ) then Page_ID = Page_ID_Old else File_Text_Replace_Line ( OPTIONS_PATH + Page_ID_Old + ".OPT", \ Option + " " + Page_ID, InStr ( Options, Option ) ) Authors ( Page_ID ) end if else File_Text_Replace_Line ( OPTIONS_PATH + Page_ID_Old + ".OPT", \ Option + " " + Page_ID, InStr ( Options, Option ) ) ? "Option '"; Option; "' has been linked to the existing page """; Page_ID; """." WaitEnter Page_ID = Page_ID_Old end if else Page_ID = Page_ID_Old end if else Page_ID = Page_ID_Old end if DisplayFile ( PAGES_PATH + Page_ID ) end if end sub sub Intro ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// cls ? Copyright ? Registration ? ? "This is a story adventure game with many different paths." ? "Occasionally one of the paths dead-ends." ? "It is then up to you to write the next page!" ? ? "Of the many options available to you on each page, one is" ? "always '!'. Press this for special options such as quitting" ? "this game or changing the page." ? ? "Have fun and be creative!" ? ? "-- David Croft" ? WaitEnter end sub sub Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Page_ID as string ////////////////////////////////////////////////////////////////////// Intro ( Registration, Copyright ) Page_ID = "1" DisplayFile ( PAGES_PATH + Page_ID ) do Menu_Page ( Page_ID ) if Page_ID = "0" then exit do end if loop ? ? "The End." WaitEnter end sub