//-------------------------------------- //--- 010 Editor v3.1.x Script File // // File:Reverse a string // Author:n0va8o.lau@gmail.com //-------------------------------------- const int entire_always = 0; // 1: do for entire file always, 0: if no selection const string title = "Sring Reverse"; int64 adr, siz, out; int actfile, newfile, bits; char tmp; if (FileCount() == 0) { MessageBox(idOk, title, "No file is open."); return -1; } if ((entire_always != 0) | (GetSelSize() <= 0)) { adr = 0; siz = FileSize(); } else { adr = GetSelStart(); siz = GetSelSize(); } if (siz == 0) { MessageBox(idOk, title, "No bytes to process."); return -1; } actfile = GetFileNum(); newfile = FileNew(); FileSelect(actfile); bits = 0; out = 0; int index = adr + siz-1; //Reverse String... while( index >= adr) { FileSelect(actfile); tmp = ReadByte(index); FileSelect(newfile); WriteByte(out, tmp); index--; out++; } FileSelect(newfile); SetCursorPos(FileSize());