Tripredacus Posted April 27, 2007 Share Posted April 27, 2007 I haven't dealt with TRIM functions in a long time so I can't remember which of these I need. I have written a GUI that displays the total physical memory in the computer, divides it by 1,024,000 and displays as GB. On this computer it displays the physical memory as 2.04594921875 GB, but I want it to display as 2.045 GB. I searched the help file but there is no result for LTRIM or RTRIM. Obviously those are database terms... Here is the relevant code: $mem = MemGetStats() $pmem = ( $mem[1] / 1024000 ) $Label_16 = GuiCtrlCreateLabel($pmem, 130, 160) Also, right now I use a label for the GB. Is it possible to put the GB into the $pmem variable? like this: $pmem = ( $mem[1] / 1024000 & " GB" ) I do not know the syntax to put text following a operation.... Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
Developers Jos Posted April 27, 2007 Developers Share Posted April 27, 2007 (edited) Trim, LTrim and Rtrim are functions to strip the spaces at the start or end of a string. AutoIt3 = StringStripWS() which does it all. But... you want to remove the decimals i assume so just use INT(Formule).... Edited April 27, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
xcal Posted April 27, 2007 Share Posted April 27, 2007 $mem = 2.04594921875 $ret = StringFormat('%.3f', $mem) & ' GB' MsgBox(0, '', $ret) How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 27, 2007 Share Posted April 27, 2007 (edited) The functions StringTrimLeft() and StringTrimRight() are for... strings. If you want to trim a number, use Round(): $a = 2.04594921875 $b = Round($a, 3) MsgBox(64, "Round()", $a & " = " & $B) Edited April 27, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GMK Posted April 27, 2007 Share Posted April 27, 2007 How about this? $mem = MemGetStats() $pmem = ( Round ($mem[1] / 1048576, 2) & " GB") $Label_16 = GuiCtrlCreateLabel($pmem, 130, 160) Link to comment Share on other sites More sharing options...
Tripredacus Posted April 27, 2007 Author Share Posted April 27, 2007 How about this? $mem = MemGetStats() $pmem = ( Round ($mem[1] / 1048576, 2) & " GB") $Label_16 = GuiCtrlCreateLabel($pmem, 130, 160) You got the 1048576 by 1024*1024, but it should be 1024*1000? Yes this function works well, but I changed it to 3, since some computers will have less than 1GB in it. Twitter | MSFN | VGCollect Link to comment Share on other sites More sharing options...
GMK Posted April 27, 2007 Share Posted April 27, 2007 You got the 1048576 by 1024*1024, but it should be 1024*1000?Yes this function works well, but I changed it to 3, since some computers will have less than 1GB in it.Actually 1,024 MB = 1 GB Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now