First off, there are no Regular Expressions (you can import them from WSH version 2, but that's not installed on our corporate build, so no joy).
Also, I'm having fun implementing basic functionality... Here are some list munging functions. Actually, they don't use VB's braindead arrays, but the "Collection" object, which is slightly less braindead, and more like a Perl list.
Function split(split_string As String, orig_string As String) As Collection
'OK not really like Perl split,
'e.g. only split on literals
Dim coll As New Collection
Dim pos
pos = 1
Dim my_string As String
my_string = orig_string
While my_string <> "" And pos <> 0
pos = InStr(1, my_string, split_string)
If pos > 0 Then
coll.Add Left(my_string, pos - 1)
my_string = mid(my_string, pos + Len(split_string))
End If
Wend
coll.Add my_string
Set split = coll
End Function
And the positively minimalist 'join' function.
Function join(jstring As String, coll As Collection) As String
Dim token As Variant
For Each token In coll
If join <> "" Then join = join & jstring
join = join & token
Next
End Function
To compare with Perl ("Make easy things easy, and hard things possible"), VBA is very good for manipulating the Excel object model and can clearly do many very difficult things easily. It just falls down in some simple things, which appear to be impossible or at least pointlessly difficult.
Not bad form (Score:3, Interesting)
In fact, it's par for the course. I can say that, because I did it, too. :)
Welcome.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Reply to This
VBA library of Perlish functions (list utilities) (Score:1)
I've created a VBA module with a number of Perllike list utilities - makeList, makeHash, split, join, push, pop, shift etc.. I was going to post the module for your interest, (if you're using VBA, or just want to laugh at the tortuous syntax) but I got this use.perl error:
osfameron
language mottoes... (Score:1)
And the following, avaliable for assignment: