Welcome, Guest Wednesday 16th April 2014, 14:03:46
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: to test simple sqf-console  (Read 1280 times)
0 Members and 1 Guest are viewing this topic.
Denisko-Redisko
*
Offline Offline


« on: 24 Apr 2009, 18: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 Smiley
PS.
to call the console in the game, you must exit the menu (Esc) and press ~

* SQFCalculator.rar (16.83 KB - downloaded 71 times.)
« Last Edit: 24 Apr 2009, 18:10:42 by Denisko-Redisko » Logged

sorry for my english
Trexian
*
Offline Offline



« Reply #1 on: 24 Apr 2009, 19:21:28 »

Can't wait to test this out.  Clapping

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. Cheesy  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?)
Logged

Sic semper tyrannosauro.
kju
*
Offline Offline



WWW
« Reply #2 on: 24 Apr 2009, 19: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.  Cheesy

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

Denisko-Redisko
*
Offline Offline


« Reply #3 on: 24 Apr 2009, 22: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. Cheesy  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 Smiley

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:
if (nil) then {hint "1"} else {hint "2"}
Both branches does not work. Because:
Code:
(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:
hint str _myNilVar
Because:
Code:
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:
isNil "_myNilVar" // return true
if you want to display:
Code:
hint format ["% 1", nil]
It do work, because ([ "% 1", nil]) return array (not nil).
This can be useful to use:
Code:
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:
someVar = 1

this will lead to error. should write
Code:
someVar = 1; something
or
someVar = 1; nil

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


@Kju

Thanks, I'll take this note  Smiley
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:
((findDisplay 46) displayCtrl 1) ctrlSetStructuredText parseText "qwe<br />qwe<br />qwe<br />qwe<br />qwe"
« Last Edit: 24 Apr 2009, 22:42:45 by Denisko-Redisko » Logged

sorry for my english
kju
*
Offline Offline



WWW
« Reply #4 on: 24 Apr 2009, 23:17:26 »

Quote
you mean auto-switching?

Well I was more thinking of a button or key action.  Smiley
Logged

i0n0s
Moderator
*****
Offline Offline



« Reply #5 on: 25 Apr 2009, 00:23:09 »

Can you add more pictures, especially of the "digestible format"?
Logged
Denisko-Redisko
*
Offline Offline


« Reply #6 on: 25 Apr 2009, 08:07:55 »

Can you add more pictures, especially of the "digestible format"?
Yes, of course  Smiley

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

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

Logged

sorry for my english
i0n0s
Moderator
*****
Offline Offline



« Reply #7 on: 25 Apr 2009, 19: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 Smiley

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?
Logged
kju
*
Offline Offline



WWW
« Reply #8 on: 25 Apr 2009, 20: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
Logged

Denisko-Redisko
*
Offline Offline


« Reply #9 on: 26 Apr 2009, 09: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 Smiley
Thanx. Smiley
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"?  Smiley) 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:
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.   Smiley
I still learn to understand and speak.  Smiley

@ 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.

* SQFCalculator.rar (29.99 KB - downloaded 50 times.)
* readConfigTree.Intro(2009-04-27).01.rar (2.73 KB - downloaded 50 times.)
« Last Edit: 27 Apr 2009, 17:19:52 by Denisko-Redisko » Logged

sorry for my english
i0n0s
Moderator
*****
Offline Offline



« Reply #10 on: 27 Apr 2009, 15: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?
Logged
Denisko-Redisko
*
Offline Offline


« Reply #11 on: 27 Apr 2009, 17: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, 20:15:18 by Denisko-Redisko » Logged

sorry for my english
Worldeater
Editors Depot
Administrator
*****
Offline Offline


Suum cuique


« Reply #12 on: 16 May 2009, 20: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:
_foo = (findDisplay 46) createDisplay "RscDisplayDebug";
Logged

try { return true; } finally { return false; }
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: