home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / telix / tlxpcp15.arc / OPTIONS.SLT < prev    next >
Text File  |  1989-01-06  |  8KB  |  319 lines

  1. //This area is for the user configurable variables of this script
  2.  
  3. str message_tone[]="y";
  4. str maintain_log[]="y";
  5.  
  6. ///////////////////////////////////////////////////////////////////////////////
  7. //                                                                           //
  8. //                 options v1.5 Copyright (c) by Charles Lee                 //
  9. //                           January 1989                                    //
  10. //                                                                           //
  11. ///////////////////////////////////////////////////////////////////////////////
  12.  
  13. beep(int freq)
  14. {
  15.     if((message_tone=="y")|(message_tone=="Y"))
  16.     {
  17.         tone(freq,20);
  18.     }
  19. }
  20.  
  21. disp_monthly()
  22. {
  23.     int fp,
  24.         t,
  25.         t1;
  26.  
  27.     str monthly_time_file[76],
  28.         elapse_time[12];
  29.  
  30.     monthly_time_file=_script_dir;
  31.     strcat(monthly_time_file,"mtelapse.pcp");
  32.  
  33.     fp=fopen(monthly_time_file,"r");
  34.     fgets(elapse_time,12,fp);
  35.     fclose(fp);
  36.     pstraxy("Total Monthly Elapsed Time is: ",27,19,10);
  37.     t=stoi(elapse_time);
  38.     t1=t/3600;
  39.     gotoxy(33,20);
  40.     printn(t1);
  41.     pstraxy(" hr(s) ",getx(),gety(),10);
  42.     t1=(t-t1*3600)/60;
  43.     printn(t1);
  44.     pstraxy(" mins.",getx(),gety(),10);
  45.     return;
  46. }
  47.  
  48.  main()
  49. {
  50.     int menu_bar_pos,
  51.         key,
  52.         screen_handle,
  53.         fp,
  54.         fp1,
  55.         connect_time,
  56.         t,
  57.         maintain_log_flag=0;
  58.  
  59.     str usage_log_path[76],
  60.         file_path[76],
  61.         monthly_time_file[76],
  62.         start_time[12],
  63.         elapse_time[12],
  64.         buffer[12];
  65.  
  66.     monthly_time_file=_script_dir;
  67.     strcat(monthly_time_file,"mtelapse.pcp");
  68.  
  69.     if((maintain_log=="Y")|(maintain_log=="y"))
  70.     {
  71.         usage_log_path=_script_dir;
  72.         strcat(usage_log_path,"usage.pcp");
  73.         fp=fopen(usage_log_path,"a+");
  74.         fseek(fp,-3,2);
  75.         if(fgetc(fp)=='P')
  76.         {
  77.             fseek(fp,-3,2);
  78.             fputc(0x20,fp);
  79.             status_wind("Updating usage log!",30);
  80.             t=curtime();
  81.             fseek(fp,0,2);
  82.             fputs("            disconnected at ",fp);
  83.             time(t,buffer);
  84.             fputs(buffer,fp);
  85.             fputs(".",fp);
  86.             fputc(0x0d,fp);
  87.             fputc(0x0a,fp);
  88.         }
  89.         fseek(fp,0,2);
  90.         maintain_log_flag=1;
  91.     }
  92.  
  93.     //Save the screen
  94.     screen_handle=vsavearea(0,0,79,24);
  95.  
  96.     clear_scr();
  97.  
  98.     box(30,5,51,15,4,0,11);
  99.     box(33,6,48,8,4,0,11);
  100.     pstraxy("Options Menu",35,7,15);
  101.     pstraxy("  moves menu bar",32,16,12);
  102.     pstraxy("    ┘ selects    ",32,17,12);
  103.  
  104.     disp_monthly();
  105.     cursor_onoff(0);
  106.     menu_bar_pos=0;
  107.     while(1)
  108.     {
  109.         if(menu_bar_pos==0)
  110.         {
  111.             pstraxy("Goto BBS dialer   ",32,10,0x4f);
  112.         }
  113.         else
  114.         {
  115.             pstraxy("Goto BBS dialer   ",32,10,14);
  116.         }
  117.         if(menu_bar_pos==1)
  118.         {
  119.             pstraxy("Goto CITY dialer  ",32,11,0x4f);
  120.         }
  121.         else
  122.         {
  123.             pstraxy("Goto CITY dialer  ",32,11,14);
  124.         }
  125.         if(menu_bar_pos==2)
  126.         {
  127.             pstraxy("Disconnect City   ",32,12,0x4f);
  128.         }
  129.         else
  130.         {
  131.             pstraxy("Disconnect City   ",32,12,14);
  132.         }
  133.         if(menu_bar_pos==3)
  134.         {
  135.             pstraxy("Log off PC Pursuit",32,13,0x4f);
  136.         }
  137.         else
  138.         {
  139.             pstraxy("Log off PC Pursuit",32,13,14);
  140.         }
  141.         if(menu_bar_pos==4)
  142.         {
  143.             pstraxy("Quit to PCP prompt",32,14,0x4f);
  144.         }
  145.         else
  146.         {
  147.             pstraxy("Quit to PCP prompt",32,14,14);
  148.         }
  149.         _scr_chk_key=0;
  150.         key=inkeyw();
  151.         if(key==0x4800)
  152.         {
  153.             if(menu_bar_pos)
  154.             {
  155.                 menu_bar_pos=menu_bar_pos-1;
  156.             }
  157.             else
  158.             {
  159.                 beep(500);
  160.             }
  161.         }
  162.         if(key==0x5000)
  163.         {
  164.             if(menu_bar_pos<4)
  165.             {
  166.                 menu_bar_pos=menu_bar_pos+1;
  167.             }
  168.             else
  169.             {
  170.                 beep(500);
  171.             }
  172.         }
  173.         if(key==0x0d)
  174.         {
  175.             break;
  176.         }
  177.         if(!((key==0x4800)|(key==0x5000)|(key==0x0d)))
  178.         {
  179.             beep(500);
  180.             status_wind("Unknown command!",10);
  181.             cursor_onoff(0);
  182.         }
  183.     }
  184.     vrstrarea(screen_handle);
  185.  
  186.     if(menu_bar_pos==0)
  187.     {
  188.         ustamp("*** BBS dialer invoked.",1,1);
  189.         if(maintain_log_flag)fclose(fp);
  190.         call("dialbbs.slc");
  191.         return;
  192.     }
  193.     if(menu_bar_pos==1)
  194.     {
  195.         if(maintain_log_flag)fclose(fp);
  196.         call("citydial.slc");
  197.         return;
  198.     }
  199.     if(menu_bar_pos==2)
  200.     {
  201.         status_wind("Attempting to disconnect city!",10);
  202.         cputs_tr("^M~@~^M~D~^M");
  203.         key=waitfor("DISCONNECTED",5);
  204.         if(key)
  205.         {
  206.             beep(3000);
  207.             status_wind("Success!",10);
  208.             ustamp("*** City disconnected.",1,1);
  209.             if(maintain_log_flag)
  210.             {
  211.                 status_wind("Updating usage log!",30);
  212.                 t=curtime();
  213.                 fputs("            disconnected at ",fp);
  214.                 time(t,buffer);
  215.                 fputs(buffer,fp);
  216.                 fputs(".",fp);
  217.                 fputc(0x0d,fp);
  218.                 fputc(0x0a,fp);
  219.                 fclose(fp);
  220.             }
  221.             file_path=_script_dir;
  222.             strcat(file_path,"temptime.pcp");
  223.             fp1=fopen(file_path,"r");
  224.             fgets(start_time,12,fp1);
  225.             fclose(fp1);
  226.  
  227.             fp1=fopen(monthly_time_file,"r");
  228.             fgets(elapse_time,12,fp1);
  229.             fclose(fp1);
  230.  
  231.             connect_time=curtime()-stoi(start_time);
  232.             //Round the elapsed time up to the nearest minute
  233.             t=connect_time/60;
  234.             if((t*60)!=(connect_time))
  235.             {
  236.                 t=t+1;
  237.             }
  238.             connect_time=t*60;
  239.             if(maintain_log_flag)
  240.             {
  241.                 file_path=_script_dir;
  242.                 strcat(file_path,"usage.pcp");
  243.  
  244.                 fp1=fopen(file_path,"a+");
  245.                 fputs("            elapsed time: ",fp1);
  246.  
  247.                 t=connect_time/3600;
  248.                 itos(t,buffer);
  249.                 fputs(buffer,fp1);
  250.                 fputs(" hr(s) ",fp1);
  251.  
  252.                 t=(connect_time-(t*3600))/60;
  253.                 itos(t,buffer);
  254.                 fputs(buffer,fp1);
  255.                 fputs(" mins.",fp1);
  256.                 fputc(0x0d,fp1);
  257.                 fputc(0x0a,fp1);
  258.                 fclose(fp1);
  259.             }
  260.             t=connect_time+stoi(elapse_time);
  261.             itos(t,buffer);
  262.             fp1=fopen(monthly_time_file,"w");
  263.             fputs(buffer,fp1);
  264.             fputc(0x0d,fp1);
  265.             fputc(0x0a,fp1);
  266.             fclose(fp1);
  267.             return;
  268.         }
  269.         else
  270.         {
  271.             beep(500);
  272.             status_wind("Unsuccessful Attempt!",10);
  273.             if(maintain_log_flag)fclose(fp);
  274.             return;
  275.         }
  276.     }
  277.     if(menu_bar_pos==3)
  278.     {
  279.         status_wind("Attempting to log off!",10);
  280.         cputs_tr("^M~@^M~hangup~^M");
  281.         loadfon("telix.fon");
  282.         _dial_time=30;
  283.         ustamp("*** PC Pursuit disconnected.",1,1);
  284.         if(maintain_log_flag)
  285.         {
  286.             beep(3000);
  287.             status_wind("Updating usage log!",30);
  288.             t=curtime();
  289.             fputc(0x0d,fp);
  290.             fputc(0x0a,fp);
  291.             fputs("Logged off PC Pursuit on ",fp);
  292.             date(t,buffer);
  293.             fputs(buffer,fp);
  294.             fputs(" at ",fp);
  295.             time(t,buffer);
  296.             fputs(buffer,fp);
  297.             fputs(".",fp);
  298.             fputc(0x0d,fp);
  299.             fputc(0x0a,fp);
  300.             fclose(fp);
  301.         }
  302.         return;
  303.     }
  304.     if(menu_bar_pos==4)
  305.     {
  306.         status_wind("Returning to PCP Prompt!",10);
  307.         cputs_tr("^M~@~^M");
  308.         if(maintain_log_flag)fclose(fp);
  309.         return;
  310.     }
  311. }
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.