// ROT13.VDM - Convert to or from ROT-13 // Date: 05/10/2004 // // The Starving Hedonist - http://cu2.home.comcast.net // // From OS: vpw|vedit|vpw64 -x rot13.vdm %1 // // where '%1' is the name of the file to convert. // // vpw|vedit|vpw64 -x rot13.vdm %1 -a %2 // // where '%1' is the name of the file to convert. // It will be saved as the file '%2'. // ////////////////////////////// // // // Process highlighted block or entire file. // If (Block_Begin < 0) { // No block marker set -- Process entire file If (! Is_Quiet) { Alert() If (OS_TYPE==1) { #106 = Dialog_Input_1(106,"`Confirmation`,`OK to convert the entire file to/from ROT-13?\n\nYou cannot undo this.`,`[&Yes]`,`[&No]`",APP+CENTER,0,0) If (#106!=1) { Goto DONE } } Else { // Key value AND 95 allows recognition of upper and lower case input #106 = Get_Key("OK to convert entire file? (You cannot undo this.) [Y]es [N]o ",STATLINE) & 95 If (#106!='Y') { Goto DONE } } } Block_Begin(0) Block_End(File_Size) } Else { // Block markers set -- Process selected block If (Block_End < 0 ) { Block_End(Cur_Pos) } If (Block_Begin > Block_End) { #106=Block_Begin Block_Begin(Block_End) Block_End(#106) } If ((Block_End-Block_Begin) > 100) { Alert() If (OS_TYPE==1) { #106 = Dialog_Input_1(106,"`Confirmation`,`OK to convert the block to/from ROT-13?\n\nYou cannot undo this.`,`[&Yes]`,`[&No]`",APP+CENTER,0,0) If (#106!=1) { Goto DONE } } Else { #106 = Get_Key("OK to convert block to/from ROT-13? (You cannot undo this.) [Y]es [N]o ",STATLINE) & 95 If (#106!='Y') { Goto DONE } } } } Goto_Pos(Block_Begin) While (Cur_Pos < Block_End) { #105 = Cur_Char If (Match("[a-z]",REGEXP)==0) { #105 = (Cur_Char - 'a' + 13) % 26 + 'a' } If (Match("[A-Z]",REGEXP)==0) { #105 = (Cur_Char - 'A' + 13) % 26 + 'A' } Ins_Char(#105,OVERWRITE) } Block_Begin(-1) If (Is_SaveAs && Is_Quiet) { File_Close(NOEVENT|NOMSG) } :DONE: Key_Purge() Return(0,DELETE)