sub DailyTax_Config_Init ( \ Config as DailyTax_Config_Type ) ////////////////////////////////////////////////////////////////////// Config.Daily_Tax = DailyTax_Default_Daily_Tax end sub sub DailyTax_Config_Load ( \ Config as DailyTax_Config_Type ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim Line as string ////////////////////////////////////////////////////////////////////// if Exists ( PROGNAME_CFG ) then File_Num = FreeFile open PROGNAME_CFG for input as File_Num if not EOF ( File_Num ) then input #File_Num, Line // Configuration version number would go here. // end if // if not EOF ( File_Num ) then // input #File_Num, Line // if String_Is_Integer ( Line ) then // Config.Kill_Days = Val ( Line ) // end if // end if if not EOF ( File_Num ) then input #File_Num, Line if String_Is_Integer ( Line ) then Config.Daily_Tax = Val ( Line ) end if end if close ( File_Num ) else ? PROGNAME_CFG; " configuration file not found." end if end sub sub DailyTax_Config_Menu ( \ Config as DailyTax_Config_Type ) ////////////////////////////////////////////////////////////////////// dim Config_Changed as boolean dim Option as string*1 dim Default as string*1 dim New_Setting as integer ////////////////////////////////////////////////////////////////////// Config_Changed = false Default = "K" do cls ? Copyright; ". Registered to "; Registration; "." ? ? "If you change the configuration settings, be sure to save"; ? " them if you " ? "want them to stay changed for the next time DailyTax is run." ? ? "If DailyTax is installed as an event and run while the SysOp" ? "is not logged in, these configuration settings will be used." ? ? "1 -- Daily tax rate = "; ? Dollars_Str ( Config.Daily_Tax ) ? "D -- set all settings to initial installation Defaults" ? "L -- Load configuration from file" ? "Q -- Quit" ? "S -- Save current configuration settings to file" ? "T -- Tax users now" ? ? "Option ["; Default; "]: "; input Option ? if Option = "" then Option = Default end if Option = UCase ( Option ) select case Option case "1" ? "This setting determines the amount, in cents, subtracted" ? "from the user's account balance each time DailyTax is run." ? New_Setting = Integer_Ask ( \ "Daily tax (cents) ", 0, 999, \ Config.Daily_Tax ) if New_Setting <> Config.Daily_Tax then Config_Changed = true Config.Daily_Tax = New_Setting Default = "S" end if case "D" ? "Setting to installation defaults..."; DailyTax_Config_Init ( Config ) ? "done." Default = "T" Config_Changed = true WaitEnter case "L" ? "Loading..."; DailyTax_Config_Load ( Config ) ? "done." Default = "T" Config_Changed = false WaitEnter case "Q" exit do case "S" ? "Saving..."; DailyTax_Config_Save ( Config ) ? "done." Default = "T" Config_Changed = false WaitEnter case "T" DailyTax_Run ( Config ) if Config_Changed then Default = "S" else Default = "Q" end if case else Beep end select loop if Config_Changed then ? ? "You have changed your configuration settings." ? "You may save these new settings to a file if you want them to" ? "load as currently set each time you run "; Program_Name; "." ? ? "Do you want to save your current configuration settings?"; if InputYesNo ( " (y/N): ", false ) then ? "Saving..."; DailyTax_Config_Save ( Config ) ? "done." WaitEnter end if end if end sub sub DailyTax_Config_Save ( \ Config as DailyTax_Config_Type ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer ////////////////////////////////////////////////////////////////////// File_Num = FreeFile open PROGNAME_CFG for output as File_Num ? #File_Num, "1.0" ? #File_Num, Config.Daily_Tax close ( File_Num ) end sub sub DailyTax_Run ( \ Config as DailyTax_Config_Type ) ////////////////////////////////////////////////////////////////////// dim Option as string*1 dim User_Found as boolean dim User_Rec as UserRecord ////////////////////////////////////////////////////////////////////// ActivityLog ( Program_Name + ": charging users daily tax" ) if EventRunning then MorePrompt Off else Color ( 14 ) ? "Press SPACEBAR to stop taxing users." end if User_Found = GetUser ( User_Rec, "" ) do while User_Found if not EventRunning then if ( Inkey <> "" ) or DisplayStopped then if not InputYesNo ( \ "Continue searching for users to tax? (Y/n): ", true ) then exit sub end if end if end if Color ( 10 ) ? FormatNumber ( User_Rec.UserID, "@####" ); ? " "; Pad ( User_Rec.Name, 25 ); " $"; ? FormatNumber ( User_Rec.SubscriptionBalance / 100, "@##.##" ); ? " "; Color ( 14 ) // if Days_Last_Called >= Config.Kill_Days then // if Days_Since_Today ( User_Rec.UserSince ) >= Config.Kill_Days then if Trim ( User_Rec.Name ) <> "DEFAULT" then if not User_Is_Never_Delete ( User_Rec ) then if User_Rec.SubscriptionBalance < Config.Daily_Tax then ? "NOT ENOUGH" else Color ( 12 ) if User.UserID <> User_Rec.UserID then User_Rec.SubscriptionBalance \ = User_Rec.SubscriptionBalance - Config.Daily_Tax if UpdateUser ( User_Rec ) then ActivityLog ( Program_Name + ": taxed " \ + Dollars_Str ( Config.Daily_Tax ) \ + " from user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name ) ? "PAID TAX" else ? "FAILED" end if else User.SubscriptionBalance \ = User.SubscriptionBalance - Config.Daily_Tax ActivityLog ( Program_Name + ": taxed " \ + Dollars_Str ( Config.Daily_Tax ) \ + " from user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name ) ? "PAID FEE" end if Color ( 10 ) end if else ? "NEVER DELETE" end if else ? "SPECIAL USER" end if // else // ? "CALLED RECENTLY" // end if // else // ? "CALLED RECENTLY" // end if User_Found = GetNextUser ( User_Rec ) loop if not EventRunning then ? ? "End of search." ? WaitEnter end if end sub sub DailyTax_Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Config as DailyTax_Config_Type ////////////////////////////////////////////////////////////////////// cls ? Copyright; ". Registered to "; Registration; "." ? DailyTax_Config_Init ( Config ) DailyTax_Config_Load ( Config ) if not EventRunning then DailyTax_Config_Menu ( Config ) else DailyTax_Run ( Config ) end if end sub