VirtualBox

Changeset 85842 in vbox for trunk/tools


Ignore:
Timestamp:
Aug 19, 2020 9:25:14 PM (4 years ago)
Author:
vboxsync
Message:

helpers.vbs: Added StrEndsWith and StrEndsWithI. Execute SelfTest if executed directly (handy for syntax errors).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/win/vbscript/helpers.vbs

    r85840 r85842  
    869869
    870870
     871''
     872' Checks if the string ends with the given suffix (case sensitive).
     873function StrEndsWith(str, strSuffix)
     874   if len(str) >= Len(strSuffix) then
     875      StrEndsWith = (StrComp(Right(str, Len(strSuffix)), strSuffix, vbBinaryCompare) = 0)
     876   else
     877      StrEndsWith = false
     878   end if
     879end function
     880
     881
     882''
     883' Checks if the string ends with the given suffix, case insenstive edition.
     884function StrEndsWithI(str, strSuffix)
     885   if len(str) >= Len(strSuffix) then
     886      StrEndsWithI = (StrComp(Right(str, Len(strSuffix)), strSuffix, vbTextCompare) = 0)
     887   else
     888      StrEndsWithI = false
     889   end if
     890end function
     891
     892
    871893''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    872894'  Helpers: Arrays                                                                                                               '
     
    15471569end sub
    15481570
     1571'
     1572' Run the self tests if we're executed directly.
     1573'
     1574if StrEndsWithI(Wscript.ScriptFullName, "\tools\win\vbscript\helpers.vbs") then
     1575   Wscript.echo "helpers.vbs: Running self test..."
     1576   SelfTest
     1577   Wscript.echo "helpers.vbs: Self test complete."
     1578end if
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette