home *** CD-ROM | disk | FTP | other *** search
- // AUTOGAP.slt
- // Automatic up/download for GAP using Zmodem
- //
- // CS AUTOGAP to compile to .slc
- // TELIX SAUTOGAP to execute from command line or event
- //
- // ............... ..............................................
-
- str first_name[] = "Tony", // user's first name
- last_name[] = "vanRoon", // user's last name
- line_num[] = "3", // line # in Telix Dialdir
- bbs_id[] = "SCOTTS", // BBS identification
- graphics[] = "y", // "n" = graphics
- up_default[] = "n", // "y" = upload is default
- copy_bak[] = "y", // "y" = copy to .BAK
- modem_spkr[] = "y"; // "y" = modem-speaker is ON
- int nsec = 10, // countdown in seconds
- busy_pause = 15; // pause between busy's
-
- // ............... user configured parameters .................
-
- str down_file[64]; // download path + filename
- str up_file[64]; // upload path + filename
- str cap_file [12]; // capture filename
- str rep[12]; // upload filename
- str ns[64], qmail[16], s[64], sw[5];
- str logoff_sw[3];
- int t, to10, pt, psl;
- int t1, t2, t3, t4, t5, t6;
- int t7, t8, t9, t10, t11, t12, stat;
- int c, c1, c2, cb, ct; // values of colors
- main()
- {
- clear_scr();
- if (t == 0)
- hi();
- _add_lf = 0; // line feed added
- _local_echo = 1; // local echo ON
- _dial_pause = busy_pause;
- strupper(bbs_id);
- down_file = _down_dir;
- strcat(down_file, bbs_id);
- strcat(down_file, ".QWK");
- up_file = _up_dir;
- strcat(up_file, bbs_id);
- strcat(up_file, ".REP");
- cap_file = bbs_id;
- strcat(cap_file, ".CAP");
- rep = bbs_id;
- strcat(rep, ".REP");
- ns = "";
- upper(first_name);
- upper(last_name);
- strcat(ns, first_name);
- strcat(ns, " ");
- strcat(ns, last_name);
- sw = "start"; // sw = upload switch
- if (graphics == "y")
- {
- _back_color = 7;
- _fore_color = 0;
- c = 112; // black on grey
- c1 = 14; // yellow on black
- c2 = 113; // blue on grey
- cb = 116;
- ct = 112;
- }
- else
- {
- c = 7; // light grey
- c1 = 112;
- c2 = 2;
- cb = 116;
- ct = 4;
- }
- if (up_default == "y" && filefind(up_file) == 0)
- {
- tone(40, 50);
- s = up_file;
- strcat(s, " was not found - NO UPLOAD!");
- status_wind(s, 40);
- up_default = "n";
- }
- s = " Do you wish to UPLOAD also ";
- if (up_default == "y")
- {
- sw = "yes";
- strcat(s, "(Y/n)? ");
- keyset(13, 0, "y");
- }
- else
- {
- sw = "no";
- strcat(s, "(y/N)? ");
- keyset(13, 0, "n");
- }
- heading(c, c2, sw, rep);
- pstraxy(s, 22, 15, c1);
- to10 = nsec;
- pt = nsec;
- nsec = nsec * 10 + 1; // assure that 0 is displayed
- itos(pt, s);
- psl = strlen(s);
- cursor_onoff(0); // cursor OFF
- flushbuf();
- t1 = track("h", 0); // h(i)
- t2 = track("n", 0); // n(o)
- t3 = track("y", 0); // y(es)
- t = timer_start(nsec);
- while (!time_up(t))
- {
- stat = track_hit(0);
- if (stat == t1)
- hi();
- if (stat == t2)
- {
- sw = "no";
- break;
- }
- if (stat == t3)
- {
- if (filefind(up_file) > 0)
- {
- sw = "yes";
- break;
- }
- else
- {
- up_default = "y";
- nsec = to10;
- main();
- }
- }
- countdown(t, to10, pt, psl, cb, ct);
- }
- heading(c, c2, sw, rep);
- s = " Do you wish automatic LOG OFF after download (Y/n)? ";
- pstraxy(s, 13, 15, c1);
- nsec = to10;
- pt = nsec;
- nsec = nsec * 10 + 1;
- itos(pt, s);
- psl = strlen(s);
- t = timer_start(nsec);
- keyset(13, 0, "y");
- s = "LOG OFF at Main Board";
- logoff_sw = "yes";
- flushbuf();
- while (!time_up(t))
- {
- stat = track_hit(0);
- if (stat == t2) // no
- {
- s = "WAIT FOR INPUT at Main Board";
- logoff_sw = "no";
- break;
- }
- if (stat == t3) // yes, log off
- break;
- countdown(t, to10, pt, psl, cb, ct);
- }
- track_free(0);
- keyset(13, 0, "");
- _add_lf = 1;
- cursor_onoff(1);
- heading(c, c2, sw, rep);
- strcat(s, " after download.");
- pstraxy(s, 19, 5, c);
- gotoxy(0, 7);
- if (modem_spkr != "y")
- {
- status_wind("AUDIO is OFF", 20);
- cputs("at m0 ^m"); // speaker OFF
- _sound_on = 0; // false, alarms OFF
- }
- dial(line_num, 0, 1); // dial # of entry in dir.
- // (1 does not link script)
- if (_entry_enum < 1)
- abort(); // if Esc
- if ((timer_total(t)) > 300)
- {
- alarm(1);
- delay(10);
- alarm(1);
- }
- capture("trouble.cap"); // begin LOGIN <-----------
- status_wind("TROUBLE.CAP is ON", 20);
- t2 = track("Ansi Color? (Y/N/Help) [Enter] =", 1);
- t3 = track("First Name ", 1);
- t4 = track("Last Name ", 1);
- t5 = track("correct? ", 1); // 0 = case is significant
- t6 = track("Password ", 1);
- t7 = track("[Any Key] To Continue", 0);
- t8 = track("No New Messages To Export", 1);
- t9 = track("QWK Packet Successfully Exported", 1);
- t10 = track("Main Board Command ", 0);
- t11 = track("Forum Command ", 0); // remembered forum?
- t12 = track("NO CARRIER", 1);
- timer_free(t);
- t = timer_start(900);
- while (not time_up(t)) // loop 90 seconds
- {
- terminal(); // read input, any BBS function
- stat = track_hit(0); // see if any matches
- if (stat == t2)
- {
- cputs(graphics); // graphics (y/n)
- cputs("^M");
- }
- if (stat == t3)
- {
- cputs(first_name); // send first name
- cputs("^M");
- }
- if (stat == t4)
- {
- cputs(last_name); // send last name
- cputs("^M");
- }
- if (stat == t5)
- cputs("^M"); // answer correct
- if (stat == t6)
- {
- cputs(_entry_pass); // send password
- cputs("^M");
- }
- if (stat == t7) // any key to continue
- cputs("^M");
- if (stat == t10) // Main Board prompt <----
- {
- cputs("qwk^M"); // invoke QWK module <----
- break;
- }
- if (stat == t11) // abandon forum
- cputs("a^M");
- if (stat == t12) // BBS trouble
- abort();
- }
- if (time_up(t)) // timed out
- {
- status_wind("TIMED OUT", 30);
- prints("TIMED OUT");
- abort();
- }
- clear_scr();
- capture("*CLOSE*");
- if (copy_bak == "y")
- {
- status_wind("Copy TROUBLE.CAP to TROUBLE.BAK", 20);
- dos("copy trouble.cap trouble.bak", 0);
- }
- status_wind("Delete TROUBLE.CAP", 20); // if no trouble
- fdelete("trouble.cap");
- capture(cap_file); // bbs_id.cap on
- s = cap_file;
- strcat(s, " is ON.");
- status_wind(s, 30);
- prints("");
- date(curtime(), s); // stamp date
- printsc(s);
- printsc(" ");
- time(curtime(), s); // stamp time
- printsc(s);
- printsc(" ");
- printsc(bbs_id);
- printsc(" ");
- prints(ns);
- if (sw == "yes") // u(pload) <----
- {
- waitfor("[Q]uit, [H]elp :", 1800); // QWK command line
- cputs("u^M");
- prints("Upload messages.");
- waitfor("Zmodem Upload", 1800);
- send('Z', up_file);
- s = "Delete ";
- strcat(s, up_file);
- status_wind(s, 40);
- fdelete(up_file);
- prints("");
- prints(s);
- waitfor("[Any Key] To Continue", 1800);
- cputs("^M");
- }
- else
- prints("NO UPLOAD.");
- // // d(ownload) <----
- _zmod_rcrash = 0; // crash recovery OFF
- waitfor("[Q]uit, [H]elp :", 1800);
- cputs("d^M");
- while (1)
- {
- terminal();
- stat = track_hit(0);
- if (stat == t8) // no new messages
- break;
- if (stat == t9) // messages found
- {
- sw = "found";
- break;
- }
- }
- if (waitfor("[Any Key] To Continue", 10)) // output randomly in
- cputs("^M"); // (2) versions of GAP
- waitfor("[Q]uit, [H]elp :", 1800);
- cputs("q^M"); // quit to BBS
- waitfor("Main Board Command", 1800);
- if (logoff_sw == "yes")
- cputs("g^M");
- while (1)
- {
- terminal();
- stat = track_hit(0);
- if (stat == t12) // NO CARRIER <-----
- break;
- }
- if (sw == "found")
- prints("PACKET DOWNLOADED");
- else
- prints("NO MESSAGES FOUND");
- capture("*CLOSE*"); // .cap OFF
- if (modem_spkr != "y")
- {
- cputs("at m1 ^m"); // speaker ON
- _sound_on = -1; // true, alarms ON
- }
- exittelix(0, 1); // return to DOS
- }
-
-
- ////////////////////////////// functions //////////////////////////////
-
- countdown(int t, int to10, int pt, int psl, int cb, int ct)
- {
- int i, tt;
- str sec[4];
- tt = timer_total(t);
- tt = to10 - tt / 10;
- itos(tt, sec);
- box(36, 8, 39+strlen(sec), 10, 2, 1, cb);
- pstraxy(sec, 38, 9, ct); // prints all tenth's
- pstra(" ", ct);
- gotoxy(0, 17);
- if (tt < pt) // if a whole second
- {
- pt = tt; // previous time
- tone(650, 5); // "tick"
- if (strlen(sec) < psl) // if shorter string
- {
- psl = strlen(sec); // previous string length
- box(36, 8, 39+strlen(sec)+1, 10, 0, 1, cb);
- box(36, 8, 39+strlen(sec), 10, 2, 1, cb); // smaller box
- }
- }
- gotoxy(0, 17);
- }
- ///////////////////////////////////////////////////////////////////////
-
- hi()
- {
- int i, t, ldit, ldah;
- t=500; ldit=8; ldah=3*ldit; // length of dit and dah
- tone(0, ldit); // why delay needed?
- for (i=0; i<4; i=i+1)
- {
- tone(t, ldit);
- tone(0, ldit);
- }
- tone(0, ldit);
- tone(0, ldit);
- for (i=0; i<2; i=i+1)
- {
- tone(t, ldit);
- tone(0, ldit);
- }
- }
- ///////////////////////////////////////////////////////////////////////
-
- heading(int c, int c2, str sw, str rep)
- {
- str s[6];
- clear_scr();
- pstraxy(bbs_id, 19, 2, c);
- pstraxy(ns, 60-strlen(ns), 2, c);
- if (sw == "start")
- {
- pstraxy("If an upload,", 18, 4, c);
- pstraxy(rep, 32, 4, c);
- pstraxy("will be deleted.", 45, 4, c);
- }
- else if (sw == "yes")
- {
- s = "UPLOAD";
- pstraxy(s, 19, 4, 206); // blinking
- pstraxy("---", 27, 4, c);
- pstraxy(rep, 32, 4, c);
- pstraxy("will be deleted.", 45, 4, c);
- }
- else
- pstraxy("NO UPLOAD", 19, 4, c);
- box(14, 1, 64, 6, 3, 1, c2);
- gotoxy(0, 17);
- }
- ////////////////////////////////////////////////////////////////////////
-
- upper(str s)
- {
- str f[64];
- int n;
- n = subchr(s, 0);
- n = toupper(n);
- f = n;
- delchrs(s, 0, 1);
- strcat(f, s);
- s = f;
- }
- ////////////////////////////////////////////////////////////////////////
-
- abort()
- {
- clear_scr();
- hangup();
- status_wind("ABORT - Return to DOS", 20);
- if (modem_spkr != "y")
- {
- cputs("at m1 ^m");
- _sound_on = -1;
- }
- exittelix(0, 1);
- }
-
- ///////////////////////////////// end ///////////////////////////////
-