Digg this topic Add to my del.icio.us Submit to SlashDot  
Reply to this topicStart new topic
> [command line tool] Calculate.exe, Calculation of expressions in scripts.
nikzzzz
post Sep 13 2007, 02:24 AM
Post #1


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


Allows to calculate value of expression and to appropriate its variable. Syntax of expressions coincides with Autoit.
Syntax:
Calculate.exe "expression" TempIniFile section key

Demo:
CODE
[main]
Title=CodeBox test
Description=Running custom commands

[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2"
echo,"2*(8+1) = %Result%"

Run,%ScriptFile%,Calculate,"int(DirGetSize('c:\windows')/1024/1024)"
echo,"Size c:\windows = %Result% Mb"

Run,%ScriptFile%,Calculate,"sin(3.14159/2)"
echo,"sin(3.14159/2) = %Result%"

Set,"%Test%","OldTestString"
Run,%ScriptFile%,Calculate,"StringReplace('%Test%'#$c'Old'#$c'New')"
echo,"NewTestString = %Result%"

[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",%Result%
FileDelete,"%ProjectTemp%\calc.ini"

Attached File  Calculate.7z ( 219.32K ) Number of downloads: 21
Go to the top of the page
 
+Quote Post
psc
post Sep 13 2007, 06:40 AM
Post #2


Guru
***

Group: .script developer
Posts: 3,740
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


QUOTE (nikzzzz @ Sep 13 2007, 04:24 AM) *
Allows to calculate value of expression and to appropriate its variable.

A great tool which makes WinBuilder scripting much more easy. (IMG:http://www.boot-land.net/forums/style_emoticons/default/thumbup.gif)
Compare the new BootSDI version with the previous one!

Peter

Small change suggestion:
Make a separate %ProjectDir%\Tools\calculate.Script.
So not every script using calculate.exe has this to have attache.
Go to the top of the page
 
+Quote Post
nikzzzz
post Sep 13 2007, 08:35 AM
Post #3


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


QUOTE (psc @ Sep 13 2007, 06:40 AM) *
Small change suggestion:
Make a separate %ProjectDir%\Tools\calculate.Script.
So not every script using calculate.exe has this to have attache.

I have faced such problem how to return the calculated value?
Such design does not work:
CODE
[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2",%Result%
echo,"2*(8+1) = %Result%"
[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",#2

Whether there is a decision?
Go to the top of the page
 
+Quote Post
psc
post Sep 13 2007, 08:46 AM
Post #4


Guru
***

Group: .script developer
Posts: 3,740
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


QUOTE (nikzzzz @ Sep 13 2007, 10:35 AM) *
I have faced such problem how to return the calculated value?
Such design does not work:
CODE
[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2",%Result%
echo,"2*(8+1) = %Result%"
[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",#2

Whether there is a decision?

But this works:
CODE
[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2",#2,#3,#4,#5,#6,#7,#9
echo,"2*(8+1) = #9"
[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",#9


Peter
Go to the top of the page
 
+Quote Post
nikzzzz
post Sep 13 2007, 09:00 AM
Post #5


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


QUOTE (psc @ Sep 13 2007, 08:46 AM) *
But this works:
CODE
[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2",#2,#3,#4,#5,#6,#7,#9
echo,"2*(8+1) = #9"
[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",#9


Peter


But how to appropriate this value of a variable %Result%?
Set, "%Result %", #9 - does not work.
Go to the top of the page
 
+Quote Post
psc
post Sep 13 2007, 09:11 AM
Post #6


Guru
***

Group: .script developer
Posts: 3,740
Joined: 14-July 06
From: Korschenbroich, Germany
Member No.: 3


Germany


QUOTE (nikzzzz @ Sep 13 2007, 11:00 AM) *
But how to appropriate this value of a variable %Result%?
Set, "%Result %", #9 - does not work.

Define %result% as Variable.
This works:
CODE
[Variables]
%result%=???
[process]
Run,%ScriptFile%,Calculate,"2*(8+1)-2",#2,#3,#4,#5,#6,#7,#9
Set,%Result%,#9
echo,%result%
[Calculate]
ShellExecute,Hide,"%Tools%\calculate.exe","#$q#1#$q #$q%ProjectTemp%\calc.ini#$q Calc Result"
IniRead,"%ProjectTemp%\calc.ini","Calc","Result",#9


Peter
Go to the top of the page
 
+Quote Post
nikzzzz
post Sep 13 2007, 09:19 AM
Post #7


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


QUOTE (psc @ Sep 13 2007, 09:11 AM) *
Define %result% as Variable.

(IMG:http://www.boot-land.net/forums/style_emoticons/default/frusty.gif)
Many thanks!
Go to the top of the page
 
+Quote Post
nikzzzz
post Sep 13 2007, 07:47 PM
Post #8


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


Calculate.script

Demo:
CODE
[main]
Title=CodeBox test
Description=Running custom commands

[variables]
%Result%=?
%DirSize%=?
%Sin%=?
%Test%=?

[process]
Run,"%ProjectDir%\Tools\Calculate.script",Calculate,"Result=2*(8+1)-2"
echo,2*(8+1)-2 = %result%

Run,%ProjectDir%\Tools\Calculate.script,Calculate,"DirSize=int(DirGetSize('c:\windows')/1024/1024)"
echo,"Size c:\windows = %DirSize% Mb"

Run,%ProjectDir%\Tools\Calculate.script,Calculate,"Sin=sin(3.14159/2)"
echo,"sin(3.14159/2) = %Sin%"

Set,"%Test%","OldTestString"
Run,%ProjectDir%\Tools\Calculate.script,Calculate,"Result=StringReplace('%Test%'#$c'Old'#$c'New')"
echo,"OldTestString = %Test%"
echo,"NewTestString = %Result%"


Attached File  Calculate.7z ( 224.45K ) Number of downloads: 15
Go to the top of the page
 
+Quote Post
pedrole15
post Sep 14 2007, 12:46 AM
Post #9


Advanced Member
***

Group: .script developer
Posts: 251
Joined: 18-August 06
Member No.: 183


France


Hi, nikzzzz
(IMG:http://www.boot-land.net/forums/style_emoticons/default/thumbup.gif)
It is not necessairy to declare variable %Result%=?
Look here
Go to the top of the page
 
+Quote Post
nikzzzz
post Sep 25 2007, 12:59 PM
Post #10


Advanced Member
***

Group: .script developer
Posts: 74
Joined: 10-October 06
Member No.: 711


Russia


New version.
Fix erors Long path.
Attached File  Calculate.7z ( 220.2K ) Number of downloads: 13

Attached File  sCalculate.7z ( 220.29K ) Number of downloads: 13
Go to the top of the page
 
+Quote Post
« Next Oldest · Development · Next Newest »
 

Fast ReplyReply to this topicStart new topic

Members Who Viewed Topic Today ()

 

Display Mode: Standard · Switch to: Linear+ · Switch to: Outline

Track this topic · Email this topic · Print this topic · Subscribe to this forum

RSS Lo-Fi Version Time is now: 4th February 2008 - 10:25 PM

MKPortal ©2003-2006 mkportal.it