nuno
New Member
Posts: 18
|
Post by nuno on Jul 15, 2007 4:56:28 GMT -5
Hi, I'm having some problems in "translating" VBscript to Brutus. I must always forget using "()" when using VBscript command examples included in help file?
About Timers how I can display only 2 numbers after seconds (for example instead of 9.324324 only put on screen 9.32). I tried "FormatNumber chrono.Time,2" but after in "graphics.SetText "graphics.SetText "Time " & displaytime, 400,540, font1, &hFFFFFFFF" it's always show full number. I tried too display other variable other than the timer itself unsucefully. I cant figure a way of format variables proprieties. Any sugestion please? Must I do some kind of string trim instead?
PS to u9 - The tutorials of GDN site unfortunly are a lot terminal oriented and don't cover much Brutus fundamentals. :/
|
|
|
Post by u9 on Jul 15, 2007 6:06:14 GMT -5
this works for me:
graphics.initialize key.initialize timers.initialize
myTimer = timers.Create() timers.Start( myTimer )
Do t = timers.AppTime( myTimer ) text = FormatNumber( t, 2 ) graphics.SetTitle text Loop until key.pressed( vk_escape ) Or key.pressed( vk_windowx )
key.terminate graphics.terminate
I didn't understand the first question about the ()...
|
|
|
Post by Guilect on Jul 15, 2007 6:59:06 GMT -5
The general rule is that any command that will be returning a value needs the "()"'s. If the command is not returning anything then you do not need the "()"'s.
|
|
nuno
New Member
Posts: 18
|
Post by nuno on Jul 15, 2007 10:41:04 GMT -5
wow u2! you type of code is a bit different from the one in timer example and yes worked well. Anyway better than that i didn't after all alter much my code. Instead of wrapping it like you proposed and I too tried to do before I did this directly "in print" and worked fine graphics.SetText "Time " & FormatNumber (chrono.Time,2), 570,520, displayfont, &hFFFFFFFF Can't understand the problems I had. Strangely the extra variables were interfering with the timer itself disabling it. Also I noticed too that doing that to time directly and not assigning another variable to get the Timer and "print it" later difer a bit in time results, so probably this way is more time accurate. About the () issue the thing is that VBscript tells in examples to put things in () but in Brutus commands works mostimes without (). Thankyou very much to both!
|
|
|
Post by u9 on Jul 15, 2007 11:36:51 GMT -5
Brutus works exactly as VBscript (i think). You need to use () to wrap input parameters to function calls that will return a value. This is also true for VBscript. If you do not use the value you cannot use (). But if you make a call you again have to use (). Don't ask me why, some bright mind over at microsoft must have cooked up that rule. I usually try and use () every where by calling all functions and procedures (subs). Here are some examples. Hopefully they show when to use ():
' The () are actually not needed as there are no input parameters to timers.Create a = timers.Create() b = timers.Create
' Value used, so we need () around the input parameter a c = timers.SplitTime( a )
' Here, the value of SplitTime is not used, but it still has an effect on the state of the timer. () are not needed here call timers.SplitTime( a ) timers.SplitTime a
' This one actually only works because there is only one input to timers.SplitTime ' and the parentheses actually are just surrounding the variable a. They are not ' wrapped around the input. If you called a function that needed two inputs then ' this would fail, so don't use this method. WARNING WARNING WARNING :) timers.SplitTime( a )
To sum up: Use () only when you are using the value returned.
|
|