Reporting : Native reporting system : Reporting system command language : FMTSCRPT subcommand
  
FMTSCRPT subcommand
Provides the ability to invoke a SABASIC script to allow formatting of the selected value.
Syntax
FIELD <name> { .. FMTSCRPT "name of routine in fmtscrpt.bas" "parameter" }
Example report script
FIELD "bind" { SOURCE PROPERTY "" TYPE MEMO FMTSCRPT "util_useThisStereoValue" "bind" }
FIELD "parameterSubstitution" { SOURCE PROPERTY "TemplateBinding-parameterSubstitution" TYPE MEMO FMTSCRPT "UML25TEMPLPARAMSUBST" "" }
With reference to the example SABASIC script below
Where the selected property is a non-reference type, the value is passed in through strRet$ and can be used if desired before strRet$ is cleared. If the property is a reference-type then strRet$ is already empty when the routine is called.
The parameter strArg$ accepted as the second parameter allows a value to be supplied from the report script similar to SQL’s SELECT 'value' behavior. Therefore the same script could trigger different behavior based on that value.
EnumerateParseDefFmtBAS allows calling of a routine from fmtscrpt.bas, which is where the following scripts are included.
Example SABASIC script
' Given id to DFX_UML251TEMPLATEPARAMETERSUBS in ddidDef& as a result of enumerating the contents of the property selected
' ddidParentDef& is the id of the item the property was selected from; where the property value being enumerated came from
' "TemplateParameterSubstitution-formal" = "The formal TemplateParameter that is associated with this TemplateParameterSubstitution."
' "TemplateParameterSubstitution-actual" = "The ParameterableElement that is the actual parameter for this TemplateParameterSubstitution."
' strRet$ is a running accumulation of what is found, of size MAXMEMO
' hdef& is global
sub UML25TEMPLPARAMSUBST(byval ddidParentDef&, byval ddidDef&, strRet$, strArg$)
       FmtRC% = OpenDefinition(ddidDef&, hdef&)

       if FmtRC% <> 0 then
              strRet$ = ""
              goto err
       end if

       tmp$ = ""
       ' only one item
       EnumerateParseDefFmtBAS(hdef&, "TemplateParameterSubstitution-formal", 1, "enumdef_addName") ' DEV_STRING
       strRet$ = strRet$ + tmp$ + " -> "
       tmp$ = ""
       ' only one item
       EnumerateParseDefFmtBAS(hdef&, "TemplateParameterSubstitution-actual", 1, "enumdef_addName") ' DEV_STRING
       strRet$ = strRet$ + tmp$ + Chr$(13) + Chr$(10)

       CloseDefinition(hdef&)

err:
end sub

sub util_useThisValue(byval ddidParentDef&, byval ddidDef&, strRet$, strArg$)
       strRet$ = strArg$
end sub

' because these «» characters don't currently import well
sub util_useThisStereoValue(byval ddidParentDef&, byval ddidDef&, strRet$, strArg$)
       strRet$ = "«" + strArg$ + "»"
end sub

' adds item name to tmp$
SUB enumdef_addName
       'tmp$ = tmp$ + Str$(itemddId&) + "," + Str$(iWhen&) + ","
       if itemddId& <> 0 and iWhen& = 2 then
              if 0 = OpenDefinition(itemddId&, hthisdef&) then
                     if hthisdef& <> 0 then
                            Name$ = String$(MAXNAME," ")
                            GetDefinitionName(hthisdef&, Name$, MAXNAME)
                            tmp$ = tmp$ + Name$

                            CloseDefinition(hthisdef&)
                     end if
              end if
       end if

END SUB

Example report script:
REPORT "Field format test - UML2-5-1 TemplateBinding"
ID 34854
{
       SETTING { DECIMALSEPARATOR "." }
       SETTING { LISTSEPARATOR "," }
       SETTING { MEASUREMENT METRIC }
       SETTING { PAGESIZE -1", 0.00 }
       SETTING { REPORTFORMAT 20 }
       REM "Works for formats 4(HTML), 20(GRID), but only the bind field works for 0(TEXT) EXCEPT when used in an Explorer Relationship Report "
       SETTING { OUTPUTFILE "C:\Users\mark.gregory\AppData\Local\Telelogic\System Architect\Temporary\saA35A.htm" }
       SETTING { EXTRACT YES EXTRACTFILE "C:\Users\mark.gregory\AppData\Local\Telelogic\System Architect\Temporary\saA35A" }
       SETTING { STYLESHEETFILE "Reports\Stylesht\HTML Tables.xsl" }
       SETTING { NAMEONLY }
       FIELD "bind" { SOURCE PROPERTY "" TYPE MEMO FMTSCRPT "util_useThisStereoValue" "bind" }
       FIELD "parameterSubstitution" { SOURCE PROPERTY "TemplateBinding-parameterSubstitution" TYPE MEMO FMTSCRPT "UML25TEMPLPARAMSUBST" "" }
       TABULAR 1
       {
              SELECT "bind", "parameterSubstitution"
              WHERE Class = Definition
              WHERE "Type Number" = 1955 REM "TemplateBinding"
       }
}
Parent topic
Reporting system command language