Troubleshooting Script Conversion

When you open a .xsp script in the new Scripting window, Aurora will convert it into a new .vb script. The Aurora converter should successfully create a new .vb script without any errors most of the time, however, manual changes may sometimes be necessary. If you run into errors after converting your script to the new .vb format, here are some common issues and their solutions. 

  1. The scripting conversion from a .xsp file to a .vb file should automatically add certain Import statements to the script. If an error occurs, make sure these Import statements are added to your script:

    Imports System
    Imports Microsoft.VisualBasic
    Imports AURORAServer
    Imports AuroraServer.Options
    Imports EnergyExemplar.Aurora.ParameterSets.Parameters


    The line “Imports AURORAServer” is necessary for every .vb script to run. The other four import statements are commonly used for scripting functions, which is why they are added when converting scripts. 

  2. The scripting converter should automatically add a new class around the functions in your script. The default class name is “AuroraScript”, however, the class name can be changed to anything. If there was an error during the conversion, make sure you add a class around all of the functions in your script, otherwise you will see an error saying the “Statement is not valid in a namespace”.

  3. The AC and ADS objects now must be declared in your script before you can use them. The converter should add these lines to your script, but in case it does not, make sure the AC and ADS objects are declared with these two lines:

    Shared AC As ComApplication = VB_RemoteAPI.InitializeAC()
    Shared ADS As ComDataSet = VB_RemoteAPI.InitializeADS()


    They must be declared inside of the class, but outside of a Sub or Function to access them everywhere in the class. 

  4. Any Sub, Function, or variable declared outside of a function needs to have the “Shared” keyword added to it.  The converter should do this for you, but if issues arise, you will see this error message, “Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class”, telling you to mark a Sub, Function, or variable as “Shared”.  In the example below, the line “Dim x As Integer” needs to be changed to “Shared Dim x As Integer”. 

  5. If you see the error message, “’Function Name’ is not declared, it may be inaccessible due to its protection level,” you will have to import the namespace for the function. You can always find the namespace of the function by hovering over it.  For the example below, for the function “CurDir” to work, the line “Imports Microsoft.VisualBasic.FileSystem” or “Imports Microsoft.VisualBasic” must added to the top of the script. 

  6. If there is an error message setting, the ADS.DataSetType or ADS.ProjectTableType that says "DataType or ProjectDSTableType is not declared", make sure to add "ComDataSet" before "DataType" or ProjectDSTableType" to fix it.

  7. If you use Excel in your script, make sure “Imports Microsoft.Office.Interop” is included in your script, otherwise you will see the error message, “Type Excel is not defined”. 

  8. Some of the syntax in your script might change moving from a .xsp script to a .vb script, which may require manual changes. Some examples are included below.

    1. If you see the error, “Number of indices is less than the number of dimensions of the indexed array”, that usually means you should delete parentheses when you are referencing an array.  For ADS.FindRowsInTable, in the .vb syntax, the parenthesis after “cn” and “cv” need to be deleted for the script to run correctly.    




      If parentheses were added when accessing a property or function on an array, such as Length, remove the parenthesis for the script to run properly. 

    2. In the example below, “ChDir projPath”, which changed the current directory to the projPath, was valid syntax for a .xsp script, but for the .vb script, the correct syntax is “ChDir(projPath)”. 



      For the function Substring, in .xsp, it was valid to declare the starting index parameter, include a comma, and leave the second parameter empty. This meant that the substring would start at the first index and continue to the end of the string.  In .vb, the correct syntax for this is to just declare the starting index, without the comma.  If the comma is included, the .vb syntax expects a second parameter.

Scripting

Troubleshooting Script Conversion


For further assistance, please contact Aurora Support.

Copyright© 1997-2024 Energy Exemplar LLC. All rights reserved.