drorshem Posted March 1, 2011 Share Posted March 1, 2011 Hi, I am kind of new here, and have created already some tools that helped me a lot during the day. However, I am having tough time getting this one right. I have the following: $file = FileOpen(@TempDir & "\sysinfo.txt", 1) ; Operation System FileWrite($file, "Operation System - " & @TAB & @OSVersion & @CRLF) ; Physical Memory Installed FileWrite($file, "Physical Memory Installed - " & @TAB & Round(GetMem() / 1024 ^2, 0) & " MB" & @CRLF) Func GetMem($srv = "localhost") Local $mem, $colItems, $colItem, $ping, $x $ping = Ping($srv) If $ping Then $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $srv & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select Capacity from Win32_PhysicalMemory", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $mem += $objItem.Capacity Next Return SetError(0, 0, $mem) Else Return SetError(2, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc ; Internet Explorer version Local $ieVersion = FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe") FileWrite($file, "IE version - " & @TAB & $ieVersion & @CRLF) ; Firefox version Local $ffVersion = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox', 'CurrentVersion') FileWrite($file, "Firefox version - " & $ffVersion & @CRLF) FileClose($file) Which gives me the following text file: Operation System - WIN_7 Physical Memory Installed - 2048 MB IE version - 8.0.7600.16722 Firefox version - 3.6.13 (en-US) But I want it to be array like this: Operation System WIN_7 Physical Memory Installed 2048 MB IE version 8.0.7600.16722 Firefox version 3.6.13 (en-US) I've tried several ways offered here, but could get it right yet. How can I do it ? Thanks for the help! - Love it here! Link to comment Share on other sites More sharing options...
saywell Posted March 1, 2011 Share Posted March 1, 2011 (edited) You'd need to look at the lengths of the first bit, pick the longest, plus a few spaces, then pad the others out with the required number of spaces. Or, just guess the number of @TAB s you'd need based on typical results. Does it need to be a txt file? Could you write it in html, in the form of a table [with or without visible cell boundaries]? William Edited March 1, 2011 by saywell Link to comment Share on other sites More sharing options...
drorshem Posted March 1, 2011 Author Share Posted March 1, 2011 I would rather it to be a text file. I've already managed to do this in HTML / XLS & CSV. But not yet in txt file. Hope you can help Link to comment Share on other sites More sharing options...
saywell Posted March 1, 2011 Share Posted March 1, 2011 Plain text files have few options for formatting - spaces and tabs are the only horizontal separators, as far as I'm aware. William Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2011 Moderators Share Posted March 1, 2011 saywell,Apologies for butting in. drorshem,Two possibilities here depending on the font you want to use:- 1. Use a monospaced font such as Courier New or Consolas. Count the number of characters in the first part of the line and add enough spaces to get to the value required before adding the second part of the string. This is the easier option. - 2. If you want to use a proportional font (where the characters are of different widths) it gets more complicated. My StringSize UDF (look in my sig) will give you the length of a string, so you can add spaces to the end of your intial string in a loop until it reaches the required value. However, this can look a little scrappy as the total value is often a pixel or 2 out (even spaces have a width!) so I have found that adding a @TAB at the end can help alignment of the second column. I would provide an example, but I am a bit busy at the moment. Give it a try yourself and come back if you run into problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
drorshem Posted March 1, 2011 Author Share Posted March 1, 2011 The @TAB was just a try, you can replace it with a space or anything that will help getting this in the right alignment with the rest of the lines. I hope I got my self clear on this matter. Thanks again. 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