Jump to content

Format Text or Mask Display.


ARPFre
 Share

Go to solution Solved by Nine,

Recommended Posts

Good afternoon everyone.
Sorry for any errors, I'm using Google Translate.

The example of the posted script is very simple, as I am in the testing and learning phase.

I would like to know if it is possible to create "mask" or "format" a text.

Example: I'm doing a WMI Query where the result is:

Windows Install Date: 20201123104757.000000-180
Total Memory: 8201288

I wanted it to be shown more accessible to users:

Windows Install Date: 2020/11/23 10:47
Total Memory: 8 GB

TestNumbers.au3

Link to comment
Share on other sites

  • Solution

Here :

$InstallDate = "20201123104757.000000-180"
$TotalMemory = 8201288

MsgBox(0,"", StringRegExpReplace($InstallDate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2}).*", "$1/$2/$3 $4:$5"))
MsgBox(0,"", GetNum($TotalMemory))

Func GetNum($iNum)
  Local $aSig = ["K", "M", "G", "T"]
  For $i = 0 to UBound($aSig) - 2
    If $iNum < 1000 Then Return $iNum & $aSig[$i]
    $iNum = Floor($iNum/1000)
  Next
  Return $iNum & $aSig[$i]
EndFunc

When you post code, use the method shown in the link

Edited by Nine
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...