Undocumented script commands - Suggestions

Discuss and share scripts and script files...
bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

namespace
Defines a functional namespace.
Assigns namespaces to user-defined functions to disambiguate them.

Syntax

Code: Select all

namespace name
name    the name of the namespace.
        Must conform to the same rules as the names of functions:
        can only consist of letters (a-z, A-Z), numbers, underscores, and must not start with a number.
        Note that you cannot use any script variables to construct the name.
        Quotes around the name are optional.
Remarks:
  • functions under specific namespace are called by prepending the namespace to the function name separated by "::".
  • namespace statements are terminated by linebreak, not by semicolon. In other words, namespace statements are not to be suffixed with a ";".
  • namespace statements must be the only statement in their own line, not followed by any other statements nor comments.
  • namespaces always have global scope, regardless of indentation.
  • namespace can not be nested. Instead, a namespace inside another is elevated to global scope.
  • There is a reserved namespace "xy" to refer to XY native functions. It can become useful when user-defined function names collide with native built-in functions. See examples.
Examples

Code: Select all

Example 1
~~~~~~~~~
  Loaded script:
    "Test sum"
      echo sum(1, 2, 3);        //3; calls the first sum function
    "Test math::sum"
      echo math::sum(1, 2, 3);  //3; calls the first sum function in namespace "math"
    "Test math2::sum"
      echo math2::sum(1, 2, 3); //6; calls the first sum function in namespace "math2"
    include "math.inc"
    include "math2.inc"
  Included library math.inc:
    namespace "math"
    function sum($x, $y) { return $x + $y; }
  Included library math2.inc:
    namespace "math2"
    function sum($x, $y, $z) { return $x + $y + $z; }

Example 2
~~~~~~~~~
You can have more than one "namespace" statements in one resource:
  Loaded script:
    "Test sum"
      echo sum(1, 2, 3);        //3; calls the first sum function
    "Test math::sum"
      echo math::sum(1, 2, 3);  //3; calls the first sum function in namespace "math"
    "Test math2::sum"
      echo math2::sum(1, 2, 3); //6; calls the first sum function in namespace "math2"
    include "math3.inc"
  Included library math3.inc:
    namespace "math"
    function sum($x, $y) { return $x + $y; }
    namespace "math2"
    function sum($x, $y, $z) { return $x + $y + $z; }
    
Example 3
~~~~~~~~~
There is a reserved namespace "xy" to refer to XY native functions:
   echo xy::asc("a"); //97
Normally you can skip this, but it can become useful when your user 
function names collide with native functions:
  echo asc("a");     //ASC=97
  echo xy::asc("a"); //97
  function asc($a) { return "ASC=" . xy::asc($a) }

Example 4
~~~~~~~~~~
function embrace($arg) { return "($arg)" };
namespace curly
function embrace(arg) { return "{$arg}" };
namespace square
function embrace($arg) { return "[$arg]" };
namespace angle
function embrace($arg) { return "<$arg>" };
"test"
  echo angle::embrace(square::embrace(embrace("tag")));
History:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

dectohex()
Converts a signed decimal integer into hexadecimal.

Syntax

Code: Select all

dectohex(integer, [rlen=0])

integer  the signed decimal number to convert.
rlen     return this many rightmost characters from return value.

Return
The hexadecimal number.

Remarks:
  • The highest value is 2147483647 (0x7fffffff), the lowest value is -2147483648 (0x80000000).
Examples

Code: Select all

text dectohex("-1"); // ffffffff
text dectohex("1234567890");    // 499602D2
text dectohex("1234567890", 4); //     02D2
History:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

esc
Sets a character sequence that will be removed from arguments to subsequent statements after all variables in them are resolved. So it can be used as an "escape" sequence.

Syntax

Code: Select all

esc [sequence=""]

sequence    the string that will be removed from subsequent scripting commands' arguments.
Examples

Code: Select all

::esc "*"; msg "<*curitem> is: <curitem>";
::esc "<>"; msg "Right now <<>date> is <date> but it won't last.<crlf>There is nothing here: <>.";
::esc "\"; msg "Right now <\date> is <date> but it won't last.<crlf>There is nothing here: \.";
Remarks:
  • This is a stateful command that affects other commands called after itself. Call esc ""; to reset.
History:
  • Added: 2008-08-26
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

The most glorious command
curdir
Displays current directory path in a popup message box.
Syntax

Code: Select all

curdir
Examples

Code: Select all

curdir;
Note by admin:
No, it just returns <xypath>. It's a forgotten remains from some debugging and totally useless now. I will remove it. :)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

showcommandfromotherinst
Toggles a debug flag to display commands passed to XYplorer from the command line.

Syntax

Code: Select all

showcommandfromotherinst [state]

state      1 or 0 enables or disables the feature.
           empty value toggles the feature.
Examples

Code: Select all

::showcommandfromotherinst;   // toggle
::showcommandfromotherinst 1; // enable
::showcommandfromotherinst 0; //disable
History:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

dbcsencode()
Encodes a string into specific codepage.

Syntax

Code: Select all

dbcsencode(string, [codepage], [hexdump])

string      the string to encode
codepage    the codepage to encode into
            if 0, the current locale codepage is applied [citation needed]
hexdump     create hexdump for debug
Return
The encoded string.

Examples

Code: Select all

text dbcsencode("蒙古天韵 Ⅱ", 936); // ÃɹÅÌìÔÏ ¢ò
text dbcsencode("เลขไทย", 874); // àÅ¢ä·Â
Remarks
This command seems to be aware of more codepages than just DBCS.

History:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

dbcsdecode()
Decodes a string from specific codepage.

Syntax

Code: Select all

dbcsdecode(string, [codepage], [hexdump])

string      the string to decode
codepage    the codepage to decode from
            if 0, the current locale codepage is applied [citation needed]
hexdump     create hexdump for debug
Return
The decoded string.

Examples

Code: Select all

text dbcsdecode("ÃɹÅÌìÔÏ ¢ò", 936); // 蒙古天韵 Ⅱ
text dbcsdecode("àÅ¢ä·Â", 874); // เลขไทย
Remarks
This command seems to be aware of more codepages than just DBCS.

History:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Undocumented script commands - Suggestions

Post by bdeshi »

rtb
Unknown. Refresh taskbar button?
Syntax

Code: Select all

rtb [?]
Examples

Code: Select all

rtb;
Remarks
Command now deprecated. See note by admin below.


Note by admin:
It's a forgotten remains from some debugging and totally useless now. I will remove it. :)
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Undocumented script commands - Suggestions

Post by admin »

PeterH wrote: 13 Mar 2015 15:24 wait
pause script execution for the specified time

Syntax

Code: Select all

wait [period=100]

period    milliseconds to wait
Return

Example

Code: Select all

 echo "Hi"; wait 1000; echo "Nice day"; //echo two messages with 1 second (1000ms) pause inbetween.
Will be official in next beta.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Undocumented script commands - Suggestions

Post by admin »

bdeshi wrote: 21 Dec 2015 16:47 echoraw
shows how XYplorer interprets the raw string that was passed upto the end of the statement.

Syntax

Code: Select all

echoraw text

text     the text to display
Example

Code: Select all

  echoraw 'Hi!'; //returns 'Hi!' with the quotes
  echoraw <<<>>
"heredoc text."
>>;
  $a = 42; echoraw "the value is: $a";
Removed.

Post Reply