

date:;

  while (TRUE)
    {
 print("\f\n------------> Classified Ads <------------\n\n");
     print("******************************************\n");
     print("* [1] Enter a  Want to Buy ad            *\n");
     print("* [2] Enter a Item for Sale or Trade ad  *\n");
     print("* [W] View Want to buy classifieds       *\n");
     print("* [S] View For Sale or Trade classifieds *\n");
     print("* [Q] Quit                               *\n");
     print("******************************************\n");

     k = key_match("12wsq");

     if ( k == '1' )
       {
         j = 1;
        e$="d:\\wantad\\WANT.";/* change to what drive you want */
        z$="want.num";
         gosub announce;
       }
     else if ( k == '2' )
            {
             j = 1;
        e$="d:\\wantad\\SELL.";/* change to what drive you want */
         z$="sell.num";
         gosub announce;
            }
    else if ( k == 'W' )
           {
           e$ = "d:\\wantad\\WANT.";/* change to what drive you want */
           n$ = "WANT.1";
           print("\f");
           gosub Showad;                
           } 
     else if ( k == 'S' )
            {
            e$ = "d:\\wantad\\SELL.";/* change to what drive you want */
            n$ = "SELL.1";
            print("\f");
            gosub Showad;
            }
    else if ( k == 'Q' )
           {
         j = 0;
         execute ("gameout");/* I highly recommend using gamein & gameout */
            }

   }
announce:;

     f$ = "d:\\wantad\\clasif.hlp";/* change to what drive you want */
        list(f$);
        print("\n\n");
        pause("hit any key to continue:");
 date_data:;

   t$ = " ";
   a$ = "\f";

   w = current_date();
  
   /* convert to days */

   x = ( w & 31 );
  
   /* convert to months - get date again becuase var w is corrupted */

   w = current_date();

   t = ( w >> 5 );

   y = ( t & 15 );

   /* convert to years */

   t = ( w >> 9 );

   z = ( t & 127 ) + 1980;

  /* convert date to a string and output to a file */

   str( t$, y );
   strcat( a$, "month: " );
   strcat( a$, t$ );
   str( t$, x );
   strcat( a$, " day: " );
   strcat( a$, t$ );
   str( t$, z );
   strcat( a$, " year: ");
   strcat( a$, t$ );
   

   /* data entry portion */
   print("\f\n\n       Enter item. ( Max 30 Char. )\n");
   print("     >------------------------------<\n");
   y$="Item : ";
   input("ITEM: ", b$, 30);
   strcat(y$,b$);
   print("\f\n\n  ", h$, " Enter 7 lines about your item.\n");
   input("\n1: ", m$, 75 );
   input("\n2: ", x$, 75 );        
   input("\n3: ", o$, 75 );
   input("\n4: ", p$, 75 ); 
   input("\n5: ", q$, 75 );
   input("\n6: ", r$, 75 );
   input("\n7: ", s$, 75 );

   print("\n\nIs the information correct? [Y/N/Q]  ");
  
k = key_match("ynq");
 
if ( k == 'N' )
        {
        print("N\n");
        goto date_data;
        }
else if(k == 'Q')
        {
        print("Q\n");
        return;
        }
print("Y\n");
        f$="d:\\wantad\\";/* change to what drive you want */
        strcat(f$,z$);
        open(f$);
        read(w$);
        b=atoi(w$);
        b=b+1;
        str(w$,b);
        delete(f$);
        logfile(f$,w$);
        f$=e$;
        str(d$,b);
        strcat(f$,d$);
logfile(f$,a$);
logfile(f$,y$);
b$="Author: ";
strcat(b$,username$);
a$="\n\n";
strcat(b$,A$);
logfile(f$,b$);
logfile(f$,m$);
logfile(f$,x$);
logfile(f$,o$);
logfile(f$,p$);
logfile(f$,q$);
logfile(f$,r$);
logfile(f$,s$);
return;
Showad:; while(1){
        print("[Want Adds]\n\n");
        x=1;
        p=0;
        f$="d:\\wantad\\";/* change to what drive you want */
        strcat(f$,n$);
while (exist(f$)) {
        if(p > 9){
        gosub list2;
         }

        p=p+1;
        open(f$);
        z$="[";
        str(x$,x);
        strcat(z$, x$);
        strcat(z$, "] ");
        if (x < 10)
                strcat(z$, " ");
        if (x < 100)
                strcat(z$, " ");
        read(x$);
        read(y$);
        if (len(y$) > 35)
                left(y$, y$, 35); 
        strcat(z$, y$);
while (len(z$) < 41)
        strcat(z$, " ");
        strcat(z$, "[");
        strcat(z$, x$);
        strcat(z$, "]\n");
        print(z$);
        x=x+1;
        f$=e$;
        str(d$,x);
        strcat(f$,d$);



}
while(1){
        p=0;
        print("\nWhich Ad to read? [#] or [RETURN] to exit ");
while(1) {
        input("?: ",y$,2);
        y=atoi(y$);
        if ((y >= '0') && (y <= '9')) {
                chr(y$,y);
                print(y$);
}
        else if (y == '\r'){
                return;
}
f$=e$;
strcat(f$,y$);
if(!exist(f$)) {
strcat(f$, ": Not found!");
return; }
list(f$);
pause("Hit any key to continue.");
return;
}
}
        if (x == 0) {
                print("No AD files found!\n\n");
                continue; 
}
}
list2:;
while(1){
        print("\nWhich Ad to read? [#] or [RETURN] for next page");
while(1){
        p=0;
        input("?: ",y$,2);
        y=atoi(y$);
        if ((y >= '0') && (y <= '9')) {
                chr(y$,y);
                print(y$);
}
        else if(y == 0) 
{
        print("\f[ More Ads ]\n\n");
        return;
}
f$=e$;
strcat(f$,y$);
if(!exist(f$)) {
strcat(f$, ": Not found!");
return; }
list(f$);
pause("Hit any key to continue.");
execute("CLASIFAD");
}
}
