/********************************************************************* * alt02.bz: is a test script designed for using the alternate() * * function contained in the ALT.BZ file. It shows how it * * is possible to alternate between several lines as well * * as alternating one line. * * * * release version 1.0 - released 9573.11 * * * * This source file is hereby released to the Public Domain by the * * author: Stig Johansen. * * * * I can be reached at these addresses: * * BBBSnet: Stig Johansen@47:1000/101 * * FidoNet: Stig Johansen@2:210/20 * * SigNet: Stig Johansen@27:1347/106 * * SkyNet: Stig Johansen@47:300:110 * * Internet: stigj@fix.bbs.no * * * * Have fun... and: release all of your source codes!!! * **********************************************************************/ #include input.bz #include alt.bz var $last, $str; function screen() { printf("\e[1;1H\e[2J"); printf(" -== BarCode BBS =-= Configuration utility ==-\n\n"); printf("Language :\n"); printf("Terminal :\n"); printf("Charset :\n"); printf("Protocol :\n"); printf("Packformat:\n"); printf("Grabformat:\n"); printf("Editor :\n"); printf("\nConfirm"); } function setup() { var $i; $str[1] = copy($bv_txt[360],3,strlen($bv_txt[360])-7); $str[2] = copy($bv_txt[331],8,strlen($bv_txt[331])-7); $str[3] = copy($bv_txt[357],3,strlen($bv_txt[357])-2); $str[4] = copy($bv_txt[358],8,strlen($bv_txt[358])-7); $str[5] = copy($bv_txt[359],8,strlen($bv_txt[359])-7); $str[6] = copy($bv_txt[86],8,strlen($bv_txt[86])-7); $str[7] = copy($bv_txt[334],8,strlen($bv_txt[334])-7); $str[8] = "OK/CANCEL"; $str[9] = "\e[3;12H"; $str[10] = "\e[4;12H"; $str[11] = "\e[5;12H"; $str[12] = "\e[6;12H"; $str[13] = "\e[7;12H"; $str[14] = "\e[8;12H"; $str[15] = "\e[9;12H"; $str[16] = "\e[11;12H"; $last[1] = $bu_language+1; $last[2] = ($bu_termcap&15)+1; $last[3] = $bu_charset+1; $last[4] = $bu_protocol+1; $last[5] = $bu_packtype+1; $last[6] = (($bu_readmode&240)>>4)+1; $last[7] = ((($bu_termcap&240)>>4)+1); $last[8] = 2; for ( $i=1 ; $i<9 ; $i=$i+1 ) { printf("%s", $str[$i+8] ); a_register($str[$i], $last[$i], 0, "", "", 0); a_showchoices(); } } function doit() { var $curr, $ok, $rc; $curr = 1; $ok = 1; while ($ok) { printf("%s", $str[$curr+8]); $rc = alternate($str[$curr],$last[$curr],6,"","",0); $last[$curr] = $rc & 255; switch ($rc>>30) { case "-1": { // DOWN if ($curr<8) $curr = $curr+1; else $curr = 1; break; } case "-2": { // UP if ($curr>1) $curr = $curr-1; else $curr = 8; break; } default: { if (($rc>0)&&($curr==8)) $ok = 0; else { $curr=8; $ok = 1; } break; } } } printf("\e[15;1H"); if ($last[$curr]==1) return (1); else return (0); } function register() { $bu_language = $last[1] - 1; $bu_termcap = $bu_termcap & 240; $bu_termcap = $bu_termcap | ($last[2]-1); $bu_protocol = ($last[4]-1); $bu_packtype = ($last[5]-1); $bu_readmode = $bu_readmode & 15; $bu_readmode = $bu_readmode | (($last[6]-1)<<4); $bu_charset = $last[3] - 1; $bu_termcap = $bu_termcap & 15; $bu_termcap = $bu_termcap | (($last[7]-1)<<4); printf("Your setup is accepted!\n\n"); } function main() { screen(); setup(); if (doit()) register(); else printf("Setup cancelled....\n\n"); }