$.stack is not a string
ESTK and FDK documentation and even typeof claims that $.stack is a string. If it is printed with $.writeline it behaves as such and creates multiple lines.
I want to build a function which can be called in any routine and will then indicate the calling level by indentation and the name of the function.
For that puprose I wanted to split the 'string' into an array, the length of which indicating the nesting level of the function in question.
But it turns out that $.stack can not be handled as a string:
function ZTrace () {
// $.stack is not a string - what is it?
var level, aStack = [], s1Stack, s2Stack;
s1Stack = toHex($.stack);
$.writeln (s1Stack); // see what it looks like
s2Stack = $.stack.toString(); // sStack behaves as stack
aStack = s2Stack.split (hex2a("829a")); // does not split
level = aStack.length; // always 1
$.writeln (aStack[0]); // always full stack
$.writeln (aStack[1]); // undefined
} // --- end ZTracefunction toHex(str) {
var hex = '';
for(var i=0;i<str.length;i++) {
hex += ''+str.charCodeAt(i).toString(16);
}
return hex;
}function hex2a(hexx) {
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
// hex2a('32343630'); // returns '2460'
var hex = hexx.toString();//force conversion
var str = '';
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
return str;
}
For example, in a nested function calling ZTrace () will create a stack like this
[ZTrace-test.jsx]
Level_0()
Level_1()
Level_2()
Level_3()
ZTrace()
But the line 05 creates (here both in hex and interpreted):
5b5a54726163652e6a73785da4c6576656c5f302829a4c6576656c5f312829a4c6576656c5f322829a4c6576656c5f332829a5a54726163652829a
[ Z T r a c e . j s x ] ¤ Æ W f u Å ó ??????L e v e l _ 1 ( ) ¤ Æ W f V Å ó ??????L e v e l _ 3 ( ) ¥ ¥ G ????6 R ????
Now, of what type is $.stack?

