Some useful Scripting Functions

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

Peke
Posts: 17502
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Some useful Scripting Functions

Post by Peke »

Here are few interesting functions.

Date to UTC Time:

Code: Select all

Function ConvertToUTC(strDate,iOffset)
On Error Resume Next
strUTC=Right(Year(strDate),2)&Pad(Month(strDate),2,"0",True) &_
 Pad(Day(strDate),2,"0",True) & Pad(Hour(strDate),2,"0",True) &_
 Pad(Minute(strDate),2,"0",True) & Pad(Second(strDate),2,"0",True)
'ConvertToUTC=DateAdd("h",strUTC,iOffSet)
ConvertToUTC=strUTC
End Function
Random Number Generator:

Code: Select all

Function GetRand(iLower,iUpper)
  Randomize
  GetRand=Int((iUpper - iLower + 1) * Rnd + iLower)
End Function
Get OS Version String:

Code: Select all

Function GetOS(strComputer)
Dim objWMI

Set objWMI=GetObject("winmgmts://" & strComputer).InstancesOf("win32_operatingsystem")

For Each OS In objWMI
  GetOS=OS.Caption
Next

End Function
Correcting String Case:

Code: Select all

Function ProperCase(strText)

strVal=UCase(Left(strText,1)) 

For x=2 To Len(strText)
    strTemp=Mid(strText,x,1)
    if Asc(strTemp) >= 65 And Asc(strTemp) <= 90 Then
        strVal=strVal & Lcase(strTemp)
    Else
        strVal=strVal & strTemp
    End If
Next

ProperCase=strVal
End Function
I've given these functions to all new and old scripters.

If you have any interesting function that you find others could use feel free to post.

WARNING: No Script Functions Requests HERE Please!
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts