Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: JamesM on July 29, 2020, 11:18:13 pm

Title: Automatically Change the setting of ShowForeign in Diagram Properties via VBA
Post by: JamesM on July 29, 2020, 11:18:13 pm
I'm creating a VBA script to automatically establish a standard set of diagram properties.  I am unable to find how I can set the value for ShowForeign, as it is known in t_diagram, or Show Namespace as it is displayed within the tool.  Can anyone assist with the syntax necessary to achieve this.
Title: Re: Automatically Change the setting of ShowForeign in Diagram Properties via VBA
Post by: qwerty on July 30, 2020, 01:13:15 am
t_diagram.showForeign

(from p. 13 of my Inside book)

Code: [Select]
repository.execute("UPDATE t_diagram SET showForeign = 1 WHERE diagram_id = <theId>")
Not sure about the VBA syntax. Maybe you need to omit the parentheses.

q.
Title: Re: Automatically Change the setting of ShowForeign in Diagram Properties via VBA
Post by: Geert Bellekens on August 05, 2020, 04:00:21 am
Code: [Select]
repository.execute("UPDATE t_diagram SET showForeign = 1 WHERE diagram_id = <theId>")
Not sure about the VBA syntax. Maybe you need to omit the parentheses.

In theory yes. You are only supposed to use parentheses when you are doing something with the return value.
So
Code: [Select]
a = function("parameter")is OK
Code: [Select]
function("parameter")
is not supposed to be OK, but in this case you don't get an error. It's only if you have more than one parameter the you get a syntax error.
Code: [Select]
function("parameter1", "parameter2")
This should be written as
Code: [Select]
function "parameter1", "parameter2"

(Yes I agree, that is a weird ass syntax :-X)

Geert
Title: Re: Automatically Change the setting of ShowForeign in Diagram Properties via VBA
Post by: Eve on August 05, 2020, 08:00:16 am
It's only if you have more than one parameter the you get a syntax error.
Presumably because it ends up being a parenthesized expression instead of parenthesis around the arguments.