2

I wrote a DXL script that I run from a batch file, it receives a Module path, a Baseline and a View. After the batch command opens IBM Doors 9.6, the script supposed to go to the module path with the relevant view and load the Baseline entered.

My problem is that my script loads the current Baseline and not the one I entered. I can't find the currect command that loads the right Baseline.

This is my script:

mod = #MODULE#
xi_baseline = #BASELINE#
string mView = #VIEW#
Module m

int indexOf(string source, char c)
{
        int i = 0
        for (i = 0; i < length(source); i++)
        {           
                    if(source[i] == c)
                    {
                                return i
                    }
        }
        
        return -1
 }

int pos = indexOf(xi_baseline,'.')
string bsMajor = xi_baseline[0:pos - 1] "\n"
string bsMinor = xi_baseline[pos + 1:]
Baseline b = baseline(intOf(bsMajor), intOf(bsMinor), "")
m = read(mod)
load view mView

The right Baseline I need is saved in b variable, my question is what's the right command/function I need to use in order to receive that Baseline from Doors?

asaf
  • 21
  • 4

1 Answers1

1

You will need an intermediate ModName_ and a ModuleVersion. Assuming your input parameters are the full name of the module and the baseline given in the format as versionString presents it, assuming that your baselines might have suffices, your code might look like this:

Module loadBaseline (string sFullName, string sBaseline. bool shallDisplay) {
  // baselines must begin with digits <major> followed by a dot, followed by digits <minor>.
 //  If the baseline has a suffix, it is given inside brackets (<suffix>)
  Regexp reBL = regexp2 "^([0-9]+)\\.([0-9]+) ?\\(?([^)]*)\\)"

  if (!reBL sBaseline) {
    return null Module
  }

  int iMajor = intOf realOf sBaseline[match 1]
  int iMinor = intOf realOf sBaseline[match 2]
  string sSuffix = sBaseline[match 3]

  ModName_ mn = module (sFullName)
  if (null mn) {
    return null Module
  }
  Baseline b = baseline (iMajor, iMinor, sSuffix)
  ModuleVersion mv = moduleVersion (mn, b)
  Module m = load (mv, shallDisplay)
  return m
}


string sFullName = "/full/path/to/module/including/name"
string sBaseline = "1.26 (QS)"

Module m = loadBaseline (sFullName, sBaseline, true)
if (!load (m, view (mView), false)) then error "could not load view of module " sFullName

Edit2: used wrong parameters for loading the view. Script should be correct now (untested)

Mike
  • 2,098
  • 1
  • 11
  • 18
  • When I add the line: "load (m, mView, false)" I get the error: "incorrect arguments for function (load)" What should I change? – asaf Apr 18 '23 at 13:45
  • Thank you. I mixed up the parameters for the `load` command. The usage for loading a view is `bool load(Module m, View v, bool queryUnsavedChanges)`, and you get an object of type `View` by using the command `View view([Item item,] string viewName) ` I edited my answer, should be correct now. – Mike Apr 19 '23 at 14:31