How hta Changed the Way I Deliver Builds - Part 4 - Starting an application

We've set out client and project variables, but how do we start our different packages. I say packages because I haven't worked in an office yet where we use just MicroStation and just V8i so your build and hta must be able to cater for different Bentley verticals and versions. Lets have a look at the buttons first.

Remember, this is just a basic first attempt at setting up a hta. Funny enough, I did a presentation to a group of non-Bentley users at a firm I worked for on how this build works and what I set up for the M&I group across Australia. The only criticism they could come up with was that it wasn't pretty enough, made me chuckle at the time, but once you master the basics of setting up a hta you can go to town on the html front end and come up with some great looking front ends, but that's for another time. Lets just get the basics going.

In the spsi_cad.hta file the buttons are defined by:

<table width="95%" HEIGHT="130" border="0">
<p> </p>
<tr>
<td valign="middle" bgcolor="#0099FF">
<div align="center">
<p> </p>
<p>
<input id=startv8button type="button" value="V8" name="StartV8" style="width=60px" onclick="StartV8">
<input id=startv8tfbutton type="button" value="V8TF" name="StartV8TF" style="width=60px" onclick="StartV8TF">
<input id=startv8irbutton type="button" value="V8InRoads" name="StartV8IR" style="width=80px" onclick="StartV8IR">
</p>

<p>
<input id=startxmbutton type="button" value="XM" name="StartXM" style="width=60px" onclick="StartXM">
<input id=startxmtfbutton type="button" value="XMTF" name="StartXMTF" style="width=60px" onclick="StartXMTF"> 
</p>

<p> 
<input id=startv8ibutton type="button" value="V8i" name="StartV8i" style="width=60px" onclick="StartV8i">
<input id=startv8iViewbutton type="button" value="V8iView" name="StartV8iView" style="width=60px" onclick="StartV8iView">
</p>

</div>
</tr>
</td>
</table>

I've put these in a table just so I can add come differences like a background colour etc. If you want to read a little more on html buttons, check out:

http://www.quackit.com/html/codes/html_button.cfm

It is critical that each button has unique properties for 'id', 'value' and 'name'. Realistically, you want these to relate to what the button is for. What makes the button work is the 'onclick' property. This needs to reflect the name of the vbscript sub you wish to run, in this case we have a sub to start each package:

Sub StartV8
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley2004\Program\MicroStation\config\appl\", OverwriteExisting

valReturnValue = WshShell.Run("""C:\Program Files\Bentley2004\Program\MicroStation\ustation.exe""", 0, True)
End Sub

Sub StartV8TF
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley2004\Program\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\Bentley2004\Program\MicroStation\ustation.exe"" -wc""C:\Program Files\Bentley2004\Program\TriForma\config\tflocal.cfg"""
End Sub

Sub StartV8IR
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley2004\Program\MicroStation\config\appl\", OverwriteExisting

valReturnValue = WshShell.Run("""C:\Program Files\Bentley2004\InRoads Group V8.9\bin\inroads.exe""", 0, True)
End Sub

Sub Startgeo
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley2004\Program\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\Bentley2004\Program\MicroStation\ustation.exe"" -wu""msgeo"""
End Sub

Sub StartXM
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\BentleyXM\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\BentleyXM\MicroStation\ustation.exe""",1
End Sub

Sub StartXMTF
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley2004\Program\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\BentleyXM\MicroStation\ustation.exe"" -wc""C:\Program Files\BentleyXM\TriForma\config\tflocal.cfg"""
End Sub

Sub StartV8i
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley811\MicroStation V8i\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\Bentley811\MicroStation V8i\MicroStation\ustation.exe""",1
End Sub

Sub StartV8iView
objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley811\MicroStation V8i\MicroStation\config\appl\", OverwriteExisting

WshShell.run """C:\Program Files\Bentley811\View\BentleyView.exe""",1
End Sub


We start this higher up by setting the variable objects:

Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

If you don't do this you will get errors.

The big thing to be aware of with file paths in in these subs is the different requirements for "" depending on whether the path has spaces in it. If your path has no spaces then a single set is all that is required:

"X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg"

If the path has spaces, then you MUST use triple quotes instead of single. If you use double or single then, again, you will get errors:

"""C:\Program Files\BentleyXM\MicroStation\ustation.exe"""

You can get a little more info on WshShell.run from :

http://technet.microsoft.com/en-us/library/ee156605.aspx

At the start of each sun line you will notice one more thing:

objFSO.CopyFile "X:\SPS_CAD\Standard\Bentley\MS85\Standards\data\sps_appl.cfg" , "C:\Program Files\Bentley811\MicroStation V8i\MicroStation\config\appl\", OverwriteExisting

I'll be blunt, DO NOT EDIT ANY DELIVERED CFG FILE THAT COMES INSTALLED WITH MICROSTATION OR IT'S VERTICALS. There is not need to and it is a pain to manage and bug fix if you get things wrong. The easiest way to have a cfg file picked up is to have it in the 'appl' directory as installed with each MicroStation version. You can then use this cfg file to set where you have your build by defining _USTN_SITE, no need to use ANY other location, and also pick up the version loaded. We'll go through that in the next installment, don't want to overload you yet.

More soon.

Anonymous