Jump to content
Sign in to follow this  

Array in created text file.

Recommended Posts


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
            Return SetError(0, 0, $mem)
            Return SetError(2, 0, 0)
        Return SetError(1, 0, 0)
; 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)

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!

Share this post

Link to post
Share on other sites

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]?


Edited by saywell

Share this post

Link to post
Share on other sites

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 :)

Share this post

Link to post
Share on other sites

Plain text files have few options for formatting - spaces and tabs are the only horizontal separators, as far as I'm aware.


Share this post

Link to post
Share on other sites


Apologies for butting in. :)


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. :D

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. :P


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...