Skip to content

Instantly share code, notes, and snippets.

@xcriptus
xcriptus / FileSystem.js
Created December 9, 2012 20:34
StarUML - FileSystem
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
filesystem.FolderExists(folderName))
folder = filesystem.CreateFolder(folderName);
filesystem.CopyFolder(sourcoldername, targetfoldername);
file = filesystem.CreateTextFile(filename, true, false);
file.WriteLine("<HTML>");
file.Close();
------------------------------------------------------------------------------------
function getFileContent(/*String!*/ filename) {
var file=fileSystem.OpenTextFile(filename,/*ForReading*/ 1, /*DoNotCreate*/false) ;
var text=file.ReadAll() ;
file.Close() ;
return text ;
}
@xcriptus
xcriptus / Shell.js
Created December 9, 2012 20:40
StarUML - Shell Execution
// Execution through Shell.Application
var shell = new ActiveXObject("Shell.Application") ;
shell.ShellExecute("cmd arg1 arg2 ...")
//--- Execution through WScript
var shell = new ActiveXObject("WScript.Shell");
// Execute the command
ws.run( "notepad.exe foo.txt") ;
@xcriptus
xcriptus / ShellExec.vbs
Created December 9, 2012 20:44
StarUML - Shell Execution (VB Script)
var shell = new ActiveXObject("WScript.Shell") ;
var exec = shell.Exec("C:\\cmd arg1 arg2 arg3")
while (! exec.StdOut.AtEndOfStream) {
strLine = objExecObject.StdOut.ReadLine()
Wscript.Echo "out: " & strLine
Loop
Do Until objExecObject.StdErr.AtEndOfStream
strLine = objExecObject.StdErr.ReadLine()
@xcriptus
xcriptus / StarUML.php
Created December 9, 2012 20:50
StarUML - Execution from PHP
<H1>This page shows how PHP can connect to StarUML</H1>
<?php
$comapplication = "StarUML.StarUMLApplication" ;
$staruml = new COM($comapplication) or die ("can open COM object : $elem") ;
echo "COM object $comapplication created<br>" ;
/* shows the application */
$staruml->Visible = 1 ;
$projectManager = $staruml->ProjectManager ;
// open a project for instance
$projectManager->OpenProject("C:\\metamodels\\featuremodel.uml");
@xcriptus
xcriptus / Strings.html
Created December 9, 2012 21:08
StarUML - Strings
See http://www.w3schools.com/jsref/jsref_obj_string.asp
length
Returns the length of a string
charAt()
Returns the character at the specified index
charCodeAt()
Returns the Unicode of the character at the specified index
concat()
Joins two or more strings, and returns a copy of the joined strings
@xcriptus
xcriptus / excel.js
Created December 9, 2012 22:15
StarUML - Excel
// See an example in the StarUML translator for excel
// (StarUML\modules\staruml-generator\translators\excel\ExcelTranslator.js)
var excel = new ActiveXObject("Excel.Application");
excel.visible = true ;
excelWorkbook = excel.Workbooks.Open(excelfile);
// xlNormal = -4143 (&HFFFFEFD1)
// ...
excelWorkbook.SaveAs(outputFilename, -4143, "", "", false, false);
@xcriptus
xcriptus / FileSystem.js
Created December 9, 2012 22:18
StarUML - Translator - Predefined functions
// Here comes some code that initialize some global variables
// This code is an excerpt of StarUML translators
////////////////////////////////////////////////
// createFile :
//
function createFile(path) {
notify('Creating file '+ path + '...');
return fileObject.CreateTextFile(path, true, false);
@xcriptus
xcriptus / recursive.js
Created December 9, 2012 22:23
StarUML - Translator - Recursive Traversal
// These functions allow to get a list of elements according to the
// REPEAT feature of staruml templates
// This piece of code comes from the StarUML translators
////////////////////////////////////////////////
// getAllRecursiveElements :
//
function getAllRecursiveElements(isDeep, rootElem, filterType) {
// 1.get elem's type
@xcriptus
xcriptus / Glossary.vbs
Created December 9, 2012 23:17
ExcelGlossary - VB Script
Option Explicit
Const kOpenTermChar = "{"
Const kCloseTermChar = "}"
Const kExternalTermChar = "^"
Const kQuotingChar = """"
Const kNewTermIdPrefix = "-"
Const kTermIdDelimiter = "#"