Home   Help Search Login Register  

Author Topic: to test simple sqf-console  (Read 5329 times)

0 Members and 1 Guest are viewing this topic.

Offline Denisko-Redisko

  • Members
  • *
to test simple sqf-console
« on: 24 Apr 2009, 19:07:49 »
I would like to share a small tool for debugging scripts (sqf-console), and ask to test it. Any suggestions - welcome. At the same time want to ask the scripters what tools they use in their work. thanx :)
PS.
to call the console in the game, you must exit the menu (Esc) and press ~
« Last Edit: 24 Apr 2009, 19:10:42 by Denisko-Redisko »
sorry for my english

Offline Trexian

  • Members
  • *
Re: to test simple sqf-console
« Reply #1 on: 24 Apr 2009, 20:21:28 »
Can't wait to test this out.  :clap:

One thing that I've been wrestling with lately is a bunch of scalar errors because of scope.  I know, I know, part of that is just bad/n00bish scripting. :D  But, since scalar or nil/nul returns are generally not intended, perhaps some way to catch them?  I have no idea about how to do something like that, but there you go.

(Maybe some way to identify variables that you want to watch, and have the console tell you when they return a scalar or something?)
Sic semper tyrannosauro.

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: to test simple sqf-console
« Reply #2 on: 24 Apr 2009, 20:23:55 »
Nice job Denisko-Redisko  :good:

To make it easier to get what its all about.



Quote
This is very simple sqf-console is able to perform the expression and display the result in digestible format. To sqf-code type or paste it in the text-input and press "Enter".

Formatted output is displayed in the "Result". Copy the result to the clipboard can be in the "Copy". Try these examples:

[weapons player, magazines player]
[getpos player nearObjects 100, configFile >> "CfgAmmo"]

Pressing the key "Insert" in the "Result" copies the current line of result in the "Copy" if the current line opens the container (open bracket or config classname), the entire contents of the container will be moved to the window to copy.

Each time the phrase is stored in history, double-click or keystroke "Insert" on the item list in the "History" will place the selected phrase in the box and executes it. Unwanted items "history" you can delete the key "Delete".

Some thoughts:
  • * Fullscreen mode (to have max usable area) and top bar mode (to see in 2/3 area from mid an below in background changes)
  • * Make the UI non transparent, makes reading harder
  • * Make it all in one window. So input field and result area in one area. Also history should not need switching.
  • * Page up+down and arrow up+down to scroll in history while being in the console
  • * Multiple monitor variable fields
  • * Possibility to see the variable fields also during gaming (live updating) - Like sidebar with watched variable names and their values
  • * Don't get copy mode really
  • * Switch for result between formated display (nice) and compact one line code (if big result set)
  • * Check Gaia's console and Spooner debug console (from code) for inspiration
  • * Some keys to easily focus input fields
  • * (For all in one dialog) ability to tab between input fields and buttons.

The history feature is very nice.  :D

Again very promising and useful project.  :good:
« Last Edit: 24 Apr 2009, 20:25:39 by kju »

Offline Denisko-Redisko

  • Members
  • *
Re: to test simple sqf-console
« Reply #3 on: 24 Apr 2009, 23:09:44 »
One thing that I've been wrestling with lately is a bunch of scalar errors because of scope.  I know, I know, part of that is just bad/n00bish scripting. :D  But, since scalar or nil/nul returns are generally not intended, perhaps some way to catch them?  I have no idea about how to do something like that, but there you go.
Oh, nil (in the performance of bis), - a great and terrible thing. But if you get at it you can achieve Zen enlightenment :)

BIS wrote:
Quote
When undefined value is encountered in field where boolean value is expected, it is converted to false.
but it's not quite true.
If, some expression includes nil, then it will not executed. and also, in turn, returns nil.
For example, the expression:
Code: [Select]
if (nil) then {hint "1"} else {hint "2"}Both branches does not work. Because:
Code: [Select]
(if (nil)) // nil
then
({hint "1"} else {hint "2"}) // return [{hint "1"}, {hint "2"}]
// thus
nil then [{hint "1"}, {hint "2"}] // left operand of "then" == nil -- it does not work
Do not work:
Code: [Select]
hint str _myNilVarBecause:
Code: [Select]
1) _myNilVar // return nil
2) str nil // return nil
3) hint nil // right operand of "hint" == nil -- it does not work
The first level of protection - it isNil command
Code: [Select]
isNil "_myNilVar" // return trueif you want to display:
Code: [Select]
hint format ["% 1", nil]It do work, because ([ "% 1", nil]) return array (not nil).
This can be useful to use:
Code: [Select]
expression call {
     hint "will work if: (expression != nil)"
}
So,
1) Check variables using isNil
2) Remember what variables may be nil, and take this into account.

and yes, if you write in console something like:
Code: [Select]
someVar = 1
this will lead to error. should write
Code: [Select]
someVar = 1; something
or
someVar = 1; nil

Perhaps in the future, I remove this nasty flaw
--------------------


@Kju

Thanks, I'll take this note  :)
Quote
* Switch for result between formated display (nice) and compact one line code (if big result set)
you mean auto-switching?

Quote
* Multiple monitor variable fields
* Possibility to see the variable fields also during gaming (live updating) - Like sidebar with watched variable names and their values

This was planned, but I didn't develop it.
Try this code:
Code: [Select]
((findDisplay 46) displayCtrl 1) ctrlSetStructuredText parseText "qwe<br />qwe<br />qwe<br />qwe<br />qwe"
« Last Edit: 24 Apr 2009, 23:42:45 by Denisko-Redisko »
sorry for my english

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: to test simple sqf-console
« Reply #4 on: 25 Apr 2009, 00:17:26 »
Quote
you mean auto-switching?

Well I was more thinking of a button or key action.  :)

Offline i0n0s

  • Moderator
  • *****
Re: to test simple sqf-console
« Reply #5 on: 25 Apr 2009, 01:23:09 »
Can you add more pictures, especially of the "digestible format"?

Offline Denisko-Redisko

  • Members
  • *
Re: to test simple sqf-console
« Reply #6 on: 25 Apr 2009, 09:07:55 »
Can you add more pictures, especially of the "digestible format"?
Yes, of course  :)

PS.
To do the same demo as the fifth screen, you need to add to description.ext the following class:
Code: [Select]
class RscSqfCalcDemo (
     htmlfile = "someDemo.html";
);

and to write someDemo.html. The format is the same as that of help.en.html (sqf-links)

sorry for my english

Offline i0n0s

  • Moderator
  • *****
Re: to test simple sqf-console
« Reply #7 on: 25 Apr 2009, 20:21:30 »
Tested it live and it looks good.
I would recommend that you use a less transparent look.
The format is nice, but it would be useful if you add the ',' and display empty arrays in one line.
For configs, it would be nice if arrays would be split into multiples lines too.
And I would recommend to make a config-browser out of it :)

Do you want to add a parser for code too? So parsing at ';', '{' and '}'? Would be nice.
And if the preprocessor code exists, you could parse at the #line x.

Finally: Will you make your parser public so others can use it?

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: to test simple sqf-console
« Reply #8 on: 25 Apr 2009, 21:33:06 »
Jonas is speaking of this Config-Explorer by HeliJunkie
http://www.armaholic.com/page.php?id=2208

HeliJunkie should be still around. Try to contact him by mail.  :good:

Offline Denisko-Redisko

  • Members
  • *
Re: to test simple sqf-console
« Reply #9 on: 26 Apr 2009, 10:15:59 »
Tested it live and it looks good.
I would recommend that you use a less transparent look.
The format is nice, but it would be useful if you add the ',' and display empty arrays in one line.
For configs, it would be nice if arrays would be split into multiples lines too.
And I would recommend to make a config-browser out of it :)
Thanx. :)
I take note of your wishes, but more likely I am completely rewrite the code. This will not be very fast.
Quote
Do you want to add a parser for code too? So parsing at ';', '{' and '}'? Would be nice.
And if the preprocessor code exists, you could parse at the #line x.
It would be extremely interesting to look to its implementation at sqf, though just as interesting to write it himself. Regarding the preprocessor. We can give input preprocessor does not file, a string? I'm not sure what you mean.

Quote
Finally: Will you make your parser public so others can use it?
Sure. (It's friendly than "Yes of course"?  :)) That's all for fun. MIT license.
PS.
I'm not quite sure what parser is being discussed. The parser takes the input that a plain-text, and gives to output tree (or graph) structure. I do not use any of parsers in the classic sense. If you are interested in bypassing the config tree, look at this attach.

-------------
@ kju

Oh, happiness, the topic is open again. Relax guys. All you need to good tree-traversal (like a config or array) is:
Code: [Select]
walk = function (node) (
     if (node is subtree) (
         node call walk
     ) else (
         print node
     )
)

Every IT-guy knows about it. But they do not. So compare the code doesn't make sense.
Excuse me, if I misread the situation.
PS.
If I'm like a bull in a china shop, tell me.   :)
I still learn to understand and speak.  :)

@ kju
Sorry, seems, I didn't get what you meant. If someone needs help, I'm happy to help. My mail DenVdmj@gmail.com

==========================================

Ok, I corrected the display of the commas in arrays. Arrays in config is now displayed with an indent. it looks like this:


Slightly increased size of the window, reduced transparency. The color of the window can be customized. Create a file:
X: \ Documents and Settings \ User \ Docs \ ArmA Other Profiles \ ArmaNick \ scripts \ SQFCalculator \ settings
with follows lines:

_titleBG = [.1, .1, .12, .8]; // title ground color
_groundBG = [.1, .1, .12, .8]; // ground color
_myHistory = [                  // extend history
     "units player"
];

I tried to add hot keys, but was faced with the fact that it is impossible to programmatically change the current tab. While switching windows works:
alt +1 - text input box
alt +2 - Result
alt +3 - Copy
alt +4 - History
alt +5 - Demo
alt +6 - Help
alt + left - switch to left window
alt + right - switch to right window

But without changing buttons of tabs all these can not be used.
I will think how to overcome it.

Added an example of the use of demo-mode. You can do simple demo for the your libraries, functions, or just ideas.
« Last Edit: 27 Apr 2009, 18:19:52 by Denisko-Redisko »
sorry for my english

Offline i0n0s

  • Moderator
  • *****
Re: to test simple sqf-console
« Reply #10 on: 27 Apr 2009, 16:41:01 »
In the readConfigTree is the ammo.ext missing.

And I noticed that your only displaying the config elements which have changed.
So configFile >> "CfgVehicles" >> "Truck5t" don't have a TransportMagazines section displayed, since it is inherited from "Truck5tMG". Any way to change/toggle this behaviour?

Offline Denisko-Redisko

  • Members
  • *
Re: to test simple sqf-console
« Reply #11 on: 27 Apr 2009, 18:00:08 »
There was a lot of unnecessary files (this is all experimentation on the quick fix), and I'm remove them. Just delete the line (from description.ext)
#include "ammo.ext"
Sorry  :confused:

Quote
And I noticed that your only displaying the config elements which have changed.
So configFile >> "CfgVehicles" >> "Truck5t" don't have a TransportMagazines section displayed, since it is inherited from "Truck5tMG". Any way to change/toggle this behaviour?
It always has been. Nevertheless, try:
configFile >> "CfgVehicles" >> "Truck5t" >> "TransportMagazines"
Inherited properties are not necessarily included in the class directly. It can use "live links" to the parent, to save the memory, for example. But - we have what we have. So decided developers of this game.
Of course, you can to passup to the root, and collect all the properties, but it will be good for the serious config-browser, not for this simple utility.




« Last Edit: 27 Apr 2009, 21:15:18 by Denisko-Redisko »
sorry for my english

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: to test simple sqf-console
« Reply #12 on: 16 May 2009, 21:18:17 »
I just stumbled across the following little fellow. Too bad it's not working properly. Maybe it requires this one missing file that ArmA tries to load at startup...  :whistle:

Code: [Select]
_foo = (findDisplay 46) createDisplay "RscDisplayDebug";
try { return true; } finally { return false; }