Page 1 of 1

Bedrock delimiter

Posted: Tue Sep 19, 2023 7:47 am
by schlemiel29
I try to use bedrock functions, whenever possible. When exporting values from a cube, there is a pThousandSeparator parameter. I want to set it to nothing, because in output I don't want any formatting. Just the numbers as they are, e.g. 12345.78 or 12345,78 if I need a comma.
But if the parameter pThousandSeparator is empty, the function will insert "," by itself! I don't want to change the Bedrock code to keep it compatible, or what can I do else?

Re: Bedrock delimiter

Posted: Tue Sep 19, 2023 9:54 am
by Wim Gielis
When you think that you stumbled upon an issue, you can create a new issue in the Bedrock repository in GitHub.

Re: Bedrock delimiter

Posted: Tue Sep 19, 2023 10:30 am
by schlemiel29
OK, that may be a long term solution. My question was, if I missed a detail or if I should use the function differently, because I never think, that I was the first one, who discovered an issue. :D If it is not a bug, but it is a feature, I can live with that.
Thanks Wim!

Re: Bedrock delimiter

Posted: Tue Sep 19, 2023 10:35 am
by Wim Gielis
schlemiel29 wrote: Tue Sep 19, 2023 10:30 am OK, that may be a long term solution. My question was, if I missed a detail or if I should use the function differently, because I never think, that I was the first one, who discovered an issue. :D If it is not a bug, but it is a feature, I can live with that.
Thanks Wim!
I would advise you to look into the code of the said Bedrock process and how it handles an empty value for that parameter.

Re: Bedrock delimiter

Posted: Tue Sep 19, 2023 11:38 am
by schlemiel29
Hi Wim,
I already checked the code. It replaces an empty delimiter with a ";". That was the reason I asked, because I didn't want to change the original bedrock code.

Re: Bedrock delimiter

Posted: Wed Sep 20, 2023 4:34 pm
by lotsaram
I think if you just comment out lines 90-92 on the prolog then this should suffice.

Code: Select all

If( pThousandSeparator @= '' );
 	pThousandSeparator = ',';
EndIf;
You can raise a ER at https://github.com/cubewise-code/bedrock/issues
The check for empty paramater and inserting a default makes sense. To achieve non-formatted numeric output I would prefer pThousandSeparator=BLANK to be converted to empty as a nicer solution.

For the better solution replace this starting at #253 of prolog

Code: Select all

If ( LONG(pThousandSeparator) = cLenASCIICode );
  nValid = 0;
  nChar = 1;
  While ( nChar <= cLenASCIICode );
    If( CODE( pThousandSeparator, nChar ) >= CODE( '0', 1 ) & CODE( pThousandSeparator, nChar ) <= CODE( '9', 1 ) );
      nValid = 1;
    Else;
      nValid = 0;
      Break;
    EndIf;
    nChar = nChar + 1;
  End;
  If ( nValid<>0 );
    pThousandSeparator = CHAR(StringToNumber( pThousandSeparator ));
  Else;
    pThousandSeparator = SubSt( Trim( pThousandSeparator ), 1, 1 );
  EndIf;
EndIf;
sThousandSeparator = pThousandSeparator;
with this

Code: Select all

If ( LONG(pThousandSeparator) = cLenASCIICode );
  nValid = 0;
  nChar = 1;
  While ( nChar <= cLenASCIICode );
    If( CODE( pThousandSeparator, nChar ) >= CODE( '0', 1 ) & CODE( pThousandSeparator, nChar ) <= CODE( '9', 1 ) );
      nValid = 1;
    Else;
      nValid = 0;
      Break;
    EndIf;
    nChar = nChar + 1;
  End;
  If ( nValid<>0 );
    pThousandSeparator = CHAR(StringToNumber( pThousandSeparator ));
  Else;
    pThousandSeparator = SubSt( Trim( pThousandSeparator ), 1, 1 );
  EndIf;
  sThousandSeparator = pThousandSeparator;
ElseIf( pThousandSeparator @= 'BLANK' );
  sThousandSeparator = '';
EndIf;