Category : Miscellaneous Language Source Code
Archive   : MTRANS.ZIP
Filename : MTRANS.CB

 
Output of file : MTRANS.CB contained in archive : MTRANS.ZIP
/*
Brief 3.0 macro to translate across multiple buffers
By Steven Polsky
5011 Dalton Rd.
Chevy Chase, MD. 20815
12/89
*/

#define TRUE 1
#define FALSE 0
#define YES 1
#define NO 0
#define ALL 2
#define ESC -1

extern _t_pat,
_r_pat,
_reg_exp,
_t_dir;

extern block_search (int);
int get_y_n_a(string str);

void mtrans(void)
{
/* multibuffer translate */
int start_buf,
cur_buf,
num_trans,
tot_trans,
tot_buf,
y_n_a,
blk_srch_type;

y_n_a = NO;
tot_buf = 0;

start_buf = inq_buffer();

/* do the translate in start_buf as if called from keyboard */
set_calling_name("");
tot_trans = translate();

if (tot_trans >= 0) {
if (tot_trans > 0) {
tot_buf = 1;
}

cur_buf = next_buffer();
set_buffer(cur_buf);
attach_buffer(cur_buf);

blk_srch_type = block_search (1);

/* for each buffer, offer to do translation */
while ((cur_buf != start_buf) && (y_n_a != ESC)) {

save_position();

if (search_fwd(_t_pat, _reg_exp, NULL, 1) < 1) {
restore_position();
cur_buf = next_buffer();
set_buffer(cur_buf);
attach_buffer(cur_buf);
}
else {

if (y_n_a != ALL) {
y_n_a = get_y_n_a("Translate in this buffer? (Y/N/All_buffers) ");
}

restore_position();

if (y_n_a != ESC) {

if (y_n_a == ALL) {
num_trans = translate (_t_pat,
_r_pat,
1,
_reg_exp,
NULL,
inq_marked(),
_t_dir);

if (num_trans > 0) {
tot_trans += num_trans;
tot_buf++;
}
}

else if (y_n_a == YES) {
num_trans = translate (_t_pat,
_r_pat,
NULL,
_reg_exp,
NULL,
inq_marked(),
_t_dir);

if (num_trans > 0) {
tot_trans += num_trans;
tot_buf++;
}
}

cur_buf = next_buffer();
set_buffer(cur_buf);
attach_buffer(cur_buf);
}
}
}

block_search (blk_srch_type);

if (y_n_a == ESC) {
message ("Command cancelled.");
}
else if (tot_trans == 0) {
message ("DONE! No Translations performed!");
}
else {
message ("DONE! %d Translations in %d Buffers", tot_trans, tot_buf);
}
}
}

/****************************************************************************/

int get_y_n_a(string str)

{
int ret_val;
string y_n_a;

ret_val = 1;
y_n_a = "";

while (ret_val && y_n_a != "Y" && y_n_a != "N" && y_n_a != "A") {
ret_val= get_parm(NULL, y_n_a, str, 1);
y_n_a = upper(y_n_a);
}

if (ret_val == 0) {
ret_val = ESC;
}
else if (y_n_a == "Y") {
ret_val = YES;
}
else if (y_n_a == "N") {
ret_val = NO;
}
else {
ret_val = ALL;
}

return(ret_val);
}


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : MTRANS.ZIP
Filename : MTRANS.CB

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/