comparing numbers

Good afternoon!

I'd like to know if I'm doing this right:

I have a string that gets the full name of my baseline (ie 'new baseline 10.08'), which I later apply one function to get only the numeral part.
Then I get this new  string that gets the value "10.08" and I convert it into real, to make a compare with another real to know who the highest value is.

Follow the code dxl:

 

string currentBaseLineName = name(curMod)
    Array splitedCurentBaseLineNumber = split(currentBaseLineName," ") //split my baseline name
    string currentBaseLineNumber =  getArrayString(splitedCurentBaseLineNumber, 3) //get only the numbers

real NomedoBaseline = realOf(currentBaseLineNumber) // transform the string to real
     delete splitedCurentBaseLineNumber //delete the array


if( NomedoBaseline >= NomedoAtributo ) { //compare
    ...etc...
}

 

I'm doing it right?

The problem I'm facing is because of this?

And finally, is there an easier way in which I can compare real numbers?
Because the biggest problem when comparing is the fact that int does not work because I have more numbers after the point, using string also does not work because of ASCII and the cistrcmp command  did not help me either.

 

Thanks!


braolive - Mon Jun 18 17:10:05 EDT 2018

Re: comparing numbers
Mike.Scharnow - Tue Jun 19 03:25:20 EDT 2018

From what I read, you are not working with baselines (File -> Baseline -> new), but with modules that have been copied and renamed after a specific naming convention, am I right?

 

Your input parameter "name (curMod)" will only give you the name of the module, i.e. when you have a module with the name "myReq" and you create a baseline, your module will still be called "myReq" and this module will have Baselines that you can iterate over. If you want to work with real baselines, you should first look into the section "Baselines" in the DXL manual or look into some forum posts. (note that baselines have a creation date that you probably want to use when sorting)

 

If you want your script to work with the copied modules, you should give us a sample of module names that you have in your list and one can see whether there is a flaw in your algorithm.