Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: leonhardtk on March 29, 2022, 02:50:15 am
-
I'm new to EA and the JScript; However, In the middle of creating a JScript to add an element to the selected diagram. To this end, I've been successful sofar in modifying a sample script to behave the way I'm expecting it to (granted, with much "google searching!). However, I'm running into a problem that even the 'all-knowing' Google has not been a help on. The problem is an unrecognized method. Therefore I have two questions (The answer to the first will answer the second):
1. Where is a comprehensive list of JScript methods available within Sparx EA?
2. I'm trying to pad a string variable. Namely with My-Variable.rpad(20) or MyVariable.padEnd(20). Needless to say, both of these fail.
My immediate need is to pad several variables, but can't find the correct method to use; however, a list of all available methods should answer this and possible future questions on EA compatible methods.
I appreciate any assistance on this.
-
JScript is JScript, there is no specific EA variant, so you can look at the generic documentation: https://docs.microsoft.com/en-us/previous-versions//hbxc2t98(v=vs.85)?redirectedfrom=MSDN (https://docs.microsoft.com/en-us/previous-versions//hbxc2t98(v=vs.85)?redirectedfrom=MSDN)
With regards to padding, I think you are looking for this documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
I quickly tried it myself, and indeed, it doesn't work, as the (X) in the Internet Explorer columns hinted. My Google-Fu then lead my to this stackoverflow solution: https://stackoverflow.com/questions/55462108/how-to-solve-in-ie11-object-doesnt-support-property-or-method-padstart (https://stackoverflow.com/questions/55462108/how-to-solve-in-ie11-object-doesnt-support-property-or-method-padstart)
But I'm not a Jscript specialist. I mainly use VBScript for EA scripting.
You might want to consider switching to JavaScript or VBScript if you can't get the JScript basic stuff to work.
Geert
-
Thanks for the response. It appears I might need to do something different; such as some math to figure out how much spacing is required then run a loop to pad the spacing.
I'm not opposed to trying to switch to VBA, but as with JScript, I'm not familiar with either; so my original question would be the same on VBA. Is there a list of the embedded EA functions for both JScript and VBA that I attempt to translate?
I'm not a coder, but have been successful in modifying existing code; but no idea on how to tackle translating to VBA; though I see VBA does have more options for requesting input from the user.
Again, I really appreciate any assistance on this.
KSL.
-
Any type of automation uses the EA API to talk to EA.
This is documented here: https://sparxsystems.com/enterprise_architect_user_guide/15.2/automation/reference.html (https://sparxsystems.com/enterprise_architect_user_guide/15.2/automation/reference.html)
For VBScript (not VBA) you can find the language reference here: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/t0aew7h6(v=vs.84) (https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/t0aew7h6(v=vs.84))
Example script in VBScript can be found here: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library)
Geert
-
Perfect! I'll take a look.
Thanks again, I really do appreciate your assistance on this!
KSL.