Formula Functions

Formula

Looking for something else?

As you write Lotusscript code, some function from the formula language may miss
you. Here they are (maybe not all of them).

At first I even rewrote some functions such as StrRight/Left[Back] as they were
not in the language reference of the R5 designer client, and then I found them

Here are some formula function and the non-obvious LS equivalents :

@Trim(Array) : FullTrim(Array)
@Trim(String) : FullTrim(String)
("A" = "B":"A") : (StrGetIndex(L,S)=Null)
@Left("ABC";"B") : STRLeft
@Right("ABC";"B"): STRRight
@LeftBack : STRLeftBack
@RightBack : STRRightBack
Option Base 0

' Released 11 APR 2000, pkannoglou@netcourrier.com

Public Function Explode (Byval Src As String, Byval Sep As String) As Variant
' Remark : article 10.8, Array functions, tip from Ulrich Krause
' his function explode does the same. I did not examine his algorithm
toroughly so it's up to you to decide which one you prefer
' See @Explode, default separator = ";"
If (Sep = "") Then Sep = ";"
Sep = Left\$ (Sep, 1)
Dim tmp() As String
Redim tmp(0)
pos% = 1
Do
nextsep% = Instr (pos%, Src, Sep)
If (nextsep% > 0) Then
tmp(Ubound (tmp)) = Mid\$ (Src, pos%, nextsep% - pos%)
Redim Preserve tmp(Ubound (tmp) + 1)
pos% = nextsep% + 1
End If
Loop Until ((nextsep% = 0) Or (pos% > Len (Src)))
tmp(Ubound (tmp)) = Mid\$ (Src, pos%, Len(Src) - pos% + 1)
Explode = tmp
End Function

Public Function Implode (Source As Variant, Byval Sep As String) As String
' Remark : Same as above
' See @Implode, default separator = ";"
If (Not (Isarray (Source))) Then
Implode = Cstr (Source)
Exit Function
End If
If (Sep = "") Then Sep = ";"
Sep = Left\$ (Sep, 1)
Forall Element In Source
Implode = Implode & Element & Sep
End Forall
If (Right\$ (Implode, 1) = Sep) Then
Implode = Left\$ (Implode, Len (Implode) - 1)
End If
End Function

Public Function ArrayRemove (Source As Variant, RemoveList As Variant) As
Variant
' ==============================
' Removes from Source any element common with RemoveList
If (Not (Isarray (Source))) Then
ArrayRemove = Source
Exit Function
End If
Dim CleanList() As Variant
Redim CleanList(0)
Forall Element In Source
If (Isnull (Arraygetindex (RemoveList, Element))) Then
CleanList(Ubound (CleanList)) = Element
Redim Preserve CleanList(Ubound (CleanList) + 1)
End If
End Forall
If (Ubound (CleanList) > 0) Then Redim Preserve CleanList(Ubound (CleanList) -
1)
' Return processed list
ArrayRemove = CleanList
End Function

Public Function ProperCase(Source As String) As String
' See @ProperCase
prevchar\$ = ""
For pos% = 1 To Len (Source)
c\$ = Mid\$ (Source\$, pos%, 1)
If ((prevchar\$ = " ") Or (prevchar\$ = ".") Or _
(prevchar\$ = "?") Or (prevchar\$ = "!") Or (pos% = 1)) Then
ProperCase = ProperCase & Ucase\$ (c\$)
Else
ProperCase = ProperCase & Lcase\$ (c\$)
End If
prevchar\$ = c\$
Next
End Function

Public Function IsMember (ESLst As Variant, Lst As Variant) As Integer
' See @IsMember
If (Not (Isarray (Lst))) Then
IsMember = False
Exit Function
End If
If (Isarray (ESLst)) Then
' ESLst is an array
Forall Element In ESLst
' If one element can't be found in Lst : False
If (Isnull (Arraygetindex (Lst, Element))) Then
IsMember = False
Exit Function
End If
End Forall
Else
' ESLst is a scalar
If (Isnull (Arraygetindex (Lst, ESLst))) Then
IsMember = False
Exit Function
End If
End If
IsMember = True
End Function

Public Function KeyWords (Source As String, KWL As Variant, Byval Sep As
String) As Variant
' See @KeyWords
' Generate separator list from Sep argument string or default
If (Sep = "") Then Sep = | ",.?!;:[](){}<>|
Dim SepList() As String
Redim SepList(Len(Sep))
For pos% = 1 To Len (Sep)
SepList(pos% - 1) = Mid\$ (Sep, pos%, 1)
Next
' Generate keyword list from list or scalar passed as KWL argument
Dim KeyWordList As Variant
If (Isarray (KWL)) Then
' KWL is an array
KeyWordList = KWL
Else
' KWL is a scalar
Redim KeyWordList(0)
KeyWordList(0) = Cstr (KWL)
End If
' Parse the Source and look for the keywords
Dim KeyWordFound() As String
Redim KeyWordFound(0)
word\$ = ""
For pos% = 1 To Len
This was last published in November 2000

Start the conversation

Send me notifications when other members comment.

SearchWindowsServer

• Windows Management Framework 5 update gives PowerShell users a fix

Microsoft answered admin requests for new features and fixed several bugs with its WMF 5.1 release, giving users a slew of ...

• Pester PowerShell unit testing ensures quality code

PowerShell jockeys can turn to the Pester unit testing framework to ensure the code they write is up to snuff.

• Microsoft software-defined networking gets baked into Windows Server

The Microsoft SDN technology that comes in the Windows Server 2016's Datacenter edition features a range of basic to nuanced ...

Search400

• iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

• SUSE Linux jumps on the open private cloud deployment train

SUSE Linux Enterprise planning private cloud deployment with OpenStack weight behind it. NVIDIA works on Linux drivers for ...

• Want one of the many Linux jobs out there? Time to go back to class

Does extended education from the Linux Foundation and others help graduates meet the demands of today’s Linux jobs? Some say yes.

• Ubuntu ARM server AMI for Amazon EC2 offers fast access in the cloud

Canonical’s Ubuntu ARM server AMI for Amazon EC2 provide open source shops with a fast ARM server for the cloud.

SearchDataCenter

• HPE-SimpliVity deal raises support, price and development questions

With HPE's buy of No. 2 SimpliVity -- the first big deal in the HCI space -- IT pros see a more robust offering, but also higher ...

• Converged infrastructure drop-off doesn't mean data center death

Traditional converged infrastructure has been supplanted by hyper-converged infrastructure and cloud computing, but it remains a ...

• New options to evolve your data backup and recovery plan

The server backup market first evolved to protect VMs, but now it's undergoing another transformation. Find out how it's evolved ...

SearchExchange

• Beware of these six Office 365 cons for IT shops accustomed to on premises

Office 365 offers many benefits, but there are plenty of cons to consider before leaping to this cloud-based productivity suite ...

• Five reasons for an Office 365 hybrid deployment

Not all organizations can go all-in on cloud. There are five reasons why a hybrid Office 365 arrangement makes sense for those ...

Admins must keep a close eye on Exchange Server to ensure it runs at peak performance. If cost is an issue, there are a number of...

SearchContentManagement

• Why SharePoint Framework could benefit business, not just developers

SharePoint Framework heralds a new, mobile-friendly, low-code era for Microsoft, which may give some organizations without .NET ...

• Using Microsoft MyAnalytics to improve workers' time management

Microsoft MyAnalytics has been hailed as the next great thing for analyzing worker productivity. But how can employees be assured...