*****************************************************************
***                   HexSel AkelPad plugin v7.2              ***
*****************************************************************

2006-2018 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)


*** Description ***

Conversion from text to hex/decimal/octal code and vice versa.


*** Functions ***

HexSel::Main
Main dialog.


*** External call ***

Call("HexSel::Main", 1, FLAGS, "PREFIX", "SUFFIX", "INPUT", INPUTLEN, INPUTCODEPAGE, **OUTPUT, *OUTPUTLEN)
  Parameters:
    1
      Convert selection or specified text.
    FLAGS (sum of the following members):
        1  text to hex.
        2  hex to text.
        4  single-byte conversion (Ansi).
        8  double-byte conversion (Unicode).
       16  select conversion result.
      256  decimal convertion.
      512  octal convertion.
     4096  only converted to output.
      By default: 8+16=24.
    "PREFIX"
      String before symbol code. By default current setting used.
    "SUFFIX"
      String after symbol code. By default current setting used.
    "INPUT"
      Text for convertion.
    INPUTLEN
      Text length (default is -1). If -1, text string is terminated with NULL symbol.
    INPUTCODEPAGE (for Win9x/Me)
      Text for convertion codepage. By default ANSI system codepage is used.
    **OUTPUT
      Pointer to a pointer to a buffer, that receives convertion result. String type is Unicode.
    *OUTPUTLEN
      Pointer to a variable, that receives characters count in convertion result.
  Remarks
    If flags 1 and 2 not specified, automatic direction of text convertion is used.
    After using OUTPUT parameter in Scripts plugin, it must be released with AkelPad.MemFree.
  Example. Convert selection (1+4+16=21):
    Call("HexSel::Main", 1, 21, "\x", "")
  Example. Convert text and paste to edit window (8+16=24):
    Call("HexSel::Main", 1, 24, "\x", "", "MyText")
  Example. Get convertion result (script):
    WScript.Echo(GetHex("MyText", "", ""));

    function GetHex(pInput, pPrefix, pSuffix)
    {
      var pOutput="";
      var lpOutput;
      var lpOutputLen;
      var lpOutputPtr;

      if (pInput)
      {
        if (lpOutput=AkelPad.MemAlloc(_X64?8:4 /*sizeof(wchar_t *)*/))
        {
          AkelPad.Call("HexSel::Main", 1, 9 /*1+8*/, pPrefix, pSuffix, pInput, pInput.length, 0, lpOutput);
          lpOutputPtr=AkelPad.MemRead(lpOutput, 2 /*DT_QWORD*/);
          pOutput=AkelPad.MemRead(lpOutputPtr, 1 /*DT_UNICODE*/);
          AkelPad.MemFree(lpOutputPtr);
          AkelPad.MemFree(lpOutput);
        }
      }
      return pOutput;
    }

Call("HexSel::Main", 2, FLAGS, "PREFIX", "SUFFIX", ANSICODEPAGE, UNICODECODEPAGE, "INPUT", INPUTLEN, INPUTCODEPAGE, **OUTPUT, *OUTPUTLEN)
  Parameters:
    2
      Same as 1, but with additional parameters: ANSICODEPAGE, UNICODECODEPAGE.
    ANSICODEPAGE
      Codepage for single-byte conversion (Ansi).
      If -1, codepage automatically selected.
      If -2, use current plugin settings.
      Default: -2.
    UNICODECODEPAGE
      Codepage for double-byte conversion (Unicode).
      If -2, use current plugin settings.
      Default: -2.
