FeResPost Web Site                     FeResPost Online User Manual

X.G.2.3 “RubyFunctions” VBA module

One defines in “RubyFunctions” VBA module functions and subroutines that can be called from other VBA modules, or directly used as formulas in spreadsheets. For example, the function “getParameter” returns a parameter calculated from the load case name, and the parameter name:

    Function getParameter(lcName As String, paramName As String)  
        getParameter = CallMethodValue("PostProject::DbAndLoadCases", _  
            "getParameter", lcName, paramName)  
    End Function

The function “getShellVonMisesMax” calculates the maximum von Mises stress on a Group of shell elements:

    Function getShellVonMisesMax(lcName As String, method As String, _  
            groupName As String, Optional gmshFileName As String = "", _  
            Optional gmshResName As String = "") As Variant  
        getShellVonMisesMax = CallMethodValue( _  
            "PostProject::ExtractionCriteria", _  
            "getShellVonMisesMax", lcName, method, groupName, _  
            gmshFileName, gmshResName)  
    End Function

Note that the ruby methods called from VBA may also correspond to subroutines, even though the distinction between subroutines and functions do not exist in ruby. Examples, of calls to subroutines can be found in the VBA code corresponding to “LcSelector” spreadsheet. For example, one presents below the code associated to the button “ReadDbAndLoadCases” in the spreadsheet:

    Public Sub ReadDbAndLoadCases_Click()  
        On Error GoTo locError:  
    ’  
        Dim x As Variant  
        x = CallMethod("PostProject::DbAndLoadCases", _  
            "setWorkbook", ThisWorkbook)  
        x = CallMethodValue("PostProject::DbAndLoadCases", _  
            "readDbAndLoadCases", ActiveSheet.name, nbrReservedLines, _  
                LcSelect)  
        Exit Sub  
    ’  
    locError:  
        MsgBox prompt:="Something wrong happened! check standard output file.", _  
            Title:="ReadDbAndLoadCases_Click()"  
        MsgBox prompt:=CurDir, Title:=CurDir()  
    End Sub