//------------------------------------------------ //--- 010 Editor v3.1 Script File // // File: StringReverse.1sc // Authors: n0va8o // E-mail: n0va8o.lau@gmail.com // Version: 1.1 // Purpose: Utility for reversing a string. // Category: Text // History: // 1.1 2016-02-10 SweetScape Software: Updated header for repository submission. // 1.0 n0va8o: Initial release. //------------------------------------------------ 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());