Topic
  • 11 replies
  • Latest Post - ‏2013-06-07T18:34:24Z by jvogel-11
SystemAdmin
SystemAdmin
1061 Posts

Pinned topic Can we add command buttons to a definition dialog?

‏2013-01-30T21:11:30Z |
Is there a way to add command buttons with underlying scripts/VBA to a definition dialog? For example, I'd like to add a button next to a property field to calculate and update that field.
Updated on 2013-02-28T04:38:55Z at 2013-02-28T04:38:55Z by SystemAdmin
  • TerryMoriarty
    TerryMoriarty
    126 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-06T20:40:33Z  
    There used to be, but I don't know if its still valid. Haven't had time to test it recently. It's from 2004.

    Definition "Business Rule"
    {
    PROPERTY "Rule Viewer" {Edit Button TARGETPROP "Structured Statement" Macro RuleViewer.Autoexec.RuleViewer Label "Rule Viewer" }
    }

    If you try it out, let me know if it works.

    Terry
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-07T14:06:29Z  
    There used to be, but I don't know if its still valid. Haven't had time to test it recently. It's from 2004.

    Definition "Business Rule"
    {
    PROPERTY "Rule Viewer" {Edit Button TARGETPROP "Structured Statement" Macro RuleViewer.Autoexec.RuleViewer Label "Rule Viewer" }
    }

    If you try it out, let me know if it works.

    Terry
    Thank you Terry - I will give it a try.
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-20T14:17:28Z  
    There used to be, but I don't know if its still valid. Haven't had time to test it recently. It's from 2004.

    Definition "Business Rule"
    {
    PROPERTY "Rule Viewer" {Edit Button TARGETPROP "Structured Statement" Macro RuleViewer.Autoexec.RuleViewer Label "Rule Viewer" }
    }

    If you try it out, let me know if it works.

    Terry
    Terry - I get the following error dialogs:

    "...Error attempting/while running macro
    Project: Test_proj
    Module: Test
    Macro: hello
    Check the macro exists and is error free.
    The supplied argument may be bad?..."

    It is followed by another Dialog:

    "...The macro, "Test_Proj.Test.hello", failed to execute. This may be caused by:
    Wrong number of macro arguments, parameters which are type mismatched, has byref parameters which are not variant or the macro
    produced errors ..."


    The macro consists of the following - it is a function that returns a string:

    Function hello() As String

    'Return a string back to the targetprop

    hello = "Hello Test"
    'Return the answer.

    End Function


    How it is referenced in the USRPROPS:

    PROPERTY "Field to be calculated" { EDIT Text LENGTH 20}
    PROPERTY "Calculate Something" {Edit Button TARGETPROP "Field to be calculated" Macro Test_Proj.Test.hello Label "Calculate Something" }



    Any thoughts?
  • TerryMoriarty
    TerryMoriarty
    126 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-20T21:55:51Z  
    Terry - I get the following error dialogs:

    "...Error attempting/while running macro
    Project: Test_proj
    Module: Test
    Macro: hello
    Check the macro exists and is error free.
    The supplied argument may be bad?..."

    It is followed by another Dialog:

    "...The macro, "Test_Proj.Test.hello", failed to execute. This may be caused by:
    Wrong number of macro arguments, parameters which are type mismatched, has byref parameters which are not variant or the macro
    produced errors ..."


    The macro consists of the following - it is a function that returns a string:

    Function hello() As String

    'Return a string back to the targetprop

    hello = "Hello Test"
    'Return the answer.

    End Function


    How it is referenced in the USRPROPS:

    PROPERTY "Field to be calculated" { EDIT Text LENGTH 20}
    PROPERTY "Calculate Something" {Edit Button TARGETPROP "Field to be calculated" Macro Test_Proj.Test.hello Label "Calculate Something" }



    Any thoughts?
    I'll have to look at the macro that was developed for the button. This was developed by an SA person back in about 2006. It worked at that time. He is not readily available anymore. Due to other project priorities, I may not get to this for a couple of days.
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-25T10:12:46Z  
    Read manual about VALUESCRIPT.
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-26T15:58:26Z  
    Read manual about VALUESCRIPT.
    Thanks - It looks like I need to learn SA basic, though most of my heavy processing is in VBA. Are there any examples where a VBA macro (.mac) is referenced from an SA Basic (.bas) code? If I can leverage to two - it might work.
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-27T04:03:09Z  
    Thanks - It looks like I need to learn SA basic, though most of my heavy processing is in VBA. Are there any examples where a VBA macro (.mac) is referenced from an SA Basic (.bas) code? If I can leverage to two - it might work.
    Yes, of course! Without SA VB, product provides only basic possible.
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-27T17:15:15Z  
    Yes, of course! Without SA VB, product provides only basic possible.
    I am getting an error (see attached image) with this script when opening the encyclopedia while using the SA VB usr_fn.BAS file. The error seems to be concerned with the MsgBox line.
    Sub FmtHello

    Dim response

    If FmtProperty$ = "" then
    FmtProperty$ = "Hello"
    response = MsgBox(FmtProperty$)
    else
    FmtResult$ = ""
    end if

    End sub
  • SystemAdmin
    SystemAdmin
    1061 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-02-28T04:38:55Z  
    I am getting an error (see attached image) with this script when opening the encyclopedia while using the SA VB usr_fn.BAS file. The error seems to be concerned with the MsgBox line.
    Sub FmtHello

    Dim response

    If FmtProperty$ = "" then
    FmtProperty$ = "Hello"
    response = MsgBox(FmtProperty$)
    else
    FmtResult$ = ""
    end if

    End sub
    U must use extended params in MsgBox function.
    For example :
    
    SUB ErrChk ( TheErr , TheString$ ) 
    
    if ( TheErr  0 ) then e$ = TheString$ + str$(TheErr) ig = MsgBox ( e$  , SAERRORBOX$ , 1) ScrnPrintLine( e$ ) end 
    
    if END SUB
    


    As you can see, there are a lot of examples of SA VB files in System Architect folder and subfolders. Try to search something like "MsgBox" in *.bas files.
  • P_Woodworth
    P_Woodworth
    12 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-06-05T01:31:56Z  
    Terry - I get the following error dialogs:

    "...Error attempting/while running macro
    Project: Test_proj
    Module: Test
    Macro: hello
    Check the macro exists and is error free.
    The supplied argument may be bad?..."

    It is followed by another Dialog:

    "...The macro, "Test_Proj.Test.hello", failed to execute. This may be caused by:
    Wrong number of macro arguments, parameters which are type mismatched, has byref parameters which are not variant or the macro
    produced errors ..."


    The macro consists of the following - it is a function that returns a string:

    Function hello() As String

    'Return a string back to the targetprop

    hello = "Hello Test"
    'Return the answer.

    End Function


    How it is referenced in the USRPROPS:

    PROPERTY "Field to be calculated" { EDIT Text LENGTH 20}
    PROPERTY "Calculate Something" {Edit Button TARGETPROP "Field to be calculated" Macro Test_Proj.Test.hello Label "Calculate Something" }



    Any thoughts?

    Noticed this question didn't seem to be fully answered.

    The syntax for the called function is as follows:

    Public Function fnName(ByVal strPropName As String, ByVal lngDDID As long, ByVal strPrevValue As String, ByVal strValue As String, ByRef varRet As Variant) As Long

    The function must return 1 for the value placed into the varRet parameter to appear in the property on the SAEdit dialog.

  • jvogel-11
    jvogel-11
    51 Posts

    Re: Can we add command buttons to a definition dialog?

    ‏2013-06-07T18:34:24Z  

    Noticed this question didn't seem to be fully answered.

    The syntax for the called function is as follows:

    Public Function fnName(ByVal strPropName As String, ByVal lngDDID As long, ByVal strPrevValue As String, ByVal strValue As String, ByRef varRet As Variant) As Long

    The function must return 1 for the value placed into the varRet parameter to appear in the property on the SAEdit dialog.

    Thanks - I will give this a try and see what happens.