// E-BASE64.VDM -- Encode Text to Base64 - the 'Right Brain' method :-) // // Date: 05/09/2004 // // Requires: VEDIT 6.12 or later. // // The Starving Hedonist - http://cu2.home.comcast.net // // ---------------------------------------- #10 = Buf_Num #11 = Buf_Switch(Buf_Free()) File_Open_Write("E-STAGE1.TXT",OVERWRITE|NOEVENT) Buf_Switch(#10) BOF() While (! AT_EOF) { Statline_Message("Stage 1 Processing: |@(10)") Set_Marker(1,Cur_Pos) Set_Marker(2,Cur_Pos+3) Reg_Copy_Block(10,Marker(1),Marker(2)) Buf_Switch(#11) Out_Ins() Reg_Type(10,8192) // bitwise // Reg_Type(10,4096) // octal // Reg_Type(10,2048) // hex // Reg_Type(10,1024) // literal Out_Ins(CLEAR) Ins_Newline(1) Buf_Switch(#10) Char(3) } // ---------------------------------------- #12 = Buf_Switch(Buf_Free()) File_Open_Write("E-STAGE2.TXT",OVERWRITE|NOEVENT) Buf_Switch(#11) BOF() While (! AT_EOF) { Statline_Message("Stage 2 Processing: |@(10)") Set_Marker(1,Cur_Pos) Set_Marker(2,EOL_Pos) Reg_Copy_Block(10,Marker(1),Marker(2)) Buf_Switch(#12) Ins_Text(@10) Ins_Newline(1) Buf_Switch(#11) Line(1) } Buf_Switch(#12) Replace(".","",BEGIN|ALL|NOERR) // ---------------------------------------- #13 = Buf_Switch(Buf_Free()) File_Open_Write("E-STAGE3.TXT",OVERWRITE|NOEVENT) Buf_Switch(#12) BOF() While (! AT_EOF) { Statline_Message("Stage 3 Processing: |@(10)") Set_Marker(1,Cur_Pos) Set_Marker(2,EOL_Pos) Reg_Copy_Block(10,Marker(1),Marker(2)) #50 = Reg_Size(10) // Pad to 6 bits if (#50 < 24) { // #51 = 24 - #50 #51 = (24 - #50) / 4 Out_Reg(10,APPEND) Type_Space(#51) Out_Reg(CLEAR) #50 = #50 + #51 // #50=24 } Buf_Switch(#13) // Show Bit Count // -------------- // Out_Ins() // Num_Type(#50,FORCE|EXTRA|NOCR) // Out_Ins(CLEAR) // Ins_Text(":") Ins_Text(@10) BOL for (#50/=6;#50!=0;#50--) { Char(6) Ins_Text(".") } EOL Ins_Newline(1) Buf_Switch(#12) Line(1) } // ---------------------------------------- #14 = Buf_Switch(Buf_Free()) File_Open_Write("E-STAGE4.TXT",OVERWRITE|NOEVENT) Buf_Switch(#13) BOF() While (! AT_EOF) { Statline_Message("Stage 4 Processing: |@(10)") Search(".",ERRBREAK) Char(-6) if (Match("|{X,|B}|{X,|B}|{X,|B}|{X,|B}|{X,|B}|{X,|B}.")==0) { Set_Marker(1,Cur_Pos) Set_Marker(2,Cur_Pos+6) Reg_Copy_Block(10,Marker(1),Marker(2)) } else { StatLine_Message("ERROR: STAGE4") Buf_Switch(#14) return } Buf_Switch(Buf_Free(EXTRA)) #50 = 0 Ins_Text(@10) BOL if (Cur_Char != 32) { #50 += 32 } Char(1) if (Cur_Char != 32) { #50 += 16 } Char(1) if (Cur_Char != 32) { #50 += 8 } Char(1) if (Cur_Char != 32) { #50 += 4 } Char(1) if (Cur_Char != 32) { #50 += 2 } Char(1) if (Cur_Char != 32) { #50 += 1 } Buf_Quit(OK) Buf_Switch(#14) // Experimental // ---------------------------------------- // Translate_Load("BASE64.TBL") // Ins_Text(Translate_Char(#50)) // Goto Skip // ---------------------------------------- if (#50 == 0) { Ins_Text("A") } if (#50 == 1) { Ins_Text("B") } if (#50 == 2) { Ins_Text("C") } if (#50 == 3) { Ins_Text("D") } if (#50 == 4) { Ins_Text("E") } if (#50 == 5) { Ins_Text("F") } if (#50 == 6) { Ins_Text("G") } if (#50 == 7) { Ins_Text("H") } if (#50 == 8) { Ins_Text("I") } if (#50 == 9) { Ins_Text("J") } if (#50 ==10) { Ins_Text("K") } if (#50 ==11) { Ins_Text("L") } if (#50 ==12) { Ins_Text("M") } if (#50 ==13) { Ins_Text("N") } if (#50 ==14) { Ins_Text("O") } if (#50 ==15) { Ins_Text("P") } if (#50 ==16) { Ins_Text("Q") } if (#50 ==17) { Ins_Text("R") } if (#50 ==18) { Ins_Text("S") } if (#50 ==19) { Ins_Text("T") } if (#50 ==20) { Ins_Text("U") } if (#50 ==21) { Ins_Text("V") } if (#50 ==22) { Ins_Text("W") } if (#50 ==23) { Ins_Text("X") } if (#50 ==24) { Ins_Text("Y") } if (#50 ==25) { Ins_Text("Z") } if (#50 ==26) { Ins_Text("a") } if (#50 ==27) { Ins_Text("b") } if (#50 ==28) { Ins_Text("c") } if (#50 ==29) { Ins_Text("d") } if (#50 ==30) { Ins_Text("e") } if (#50 ==31) { Ins_Text("f") } if (#50 ==32) { Ins_Text("g") } if (#50 ==33) { Ins_Text("h") } if (#50 ==34) { Ins_Text("i") } if (#50 ==35) { Ins_Text("j") } if (#50 ==36) { Ins_Text("k") } if (#50 ==37) { Ins_Text("l") } if (#50 ==38) { Ins_Text("m") } if (#50 ==39) { Ins_Text("n") } if (#50 ==40) { Ins_Text("o") } if (#50 ==41) { Ins_Text("p") } if (#50 ==42) { Ins_Text("q") } if (#50 ==43) { Ins_Text("r") } if (#50 ==44) { Ins_Text("s") } if (#50 ==45) { Ins_Text("t") } if (#50 ==46) { Ins_Text("u") } if (#50 ==47) { Ins_Text("v") } if (#50 ==48) { Ins_Text("w") } if (#50 ==49) { Ins_Text("x") } if (#50 ==50) { Ins_Text("y") } if (#50 ==51) { Ins_Text("z") } if (#50 ==52) { Ins_Text("0") } if (#50 ==53) { Ins_Text("1") } if (#50 ==54) { Ins_Text("2") } if (#50 ==55) { Ins_Text("3") } if (#50 ==56) { Ins_Text("4") } if (#50 ==57) { Ins_Text("5") } if (#50 ==58) { Ins_Text("6") } if (#50 ==59) { Ins_Text("7") } if (#50 ==60) { Ins_Text("8") } if (#50 ==61) { Ins_Text("9") } if (#50 ==62) { Ins_Text("+") } if (#50 ==63) { Ins_Text("/") } :SKIP: // Experimental // Out_Ins() // Num_Type(#50,NOCR) // Out_Ins(CLEAR) // Ins_Text(":") // Ins_Text(@10) // Ins_Text(".") if (Cur_Col >= 73) { Ins_Newline(1) } Buf_Switch(#13) Char(8) } // Apply Pad if needed Buf_Switch(#14) EOF BOL Set_Marker(1,Cur_Pos) Set_Marker(2,EOL_Pos) Reg_Copy_Block(10,Marker(1),Marker(2)) #50 = Reg_Size(10) / 4 if (Remainder > 0) { #51 = 4 - Remainder } else { #51 = 0 } EOL Ins_Text("=",COUNT,#51) // ---------------------------------------- Reg_Empty(10) Buf_Switch(#11) Buf_Quit(OK) Buf_Switch(#12) Buf_Quit(OK) Buf_Switch(#13) Buf_Quit(OK) Buf_Switch(#14) BOF Statline_Message("Done!") return