@Compif syntax difference in other locales

19 posts / 0 new
Last post
mohamed
Offline
Joined: 07/27/2015 - 03:45
@Compif syntax difference in other locales

Hi,
I am using @compif function in equation for appending field through idea script. This works fine in English/United states locale. When I changed locale to French, the equation is not working.
Each condition in @compif is separated by comma (,). But in French locale, it is showing that semi colon (;) has to be used for each condition.
So my code is not working in French/German locales. 
Syntax for English: @CompIf(<num> Condition1 , <any> Result1 , <num>Condition2 , <any> Result2,...)
Syntax for French: @CompIf(<num> Condition1 <any> Result1 ; <num>Condition2 ; <any> Result2;...)
See screen shots attached for equation editor in English and French locales. Ideally method syntact should be same irrespective of locale. Correct?
Is there any way to make this function working in all locales?
 

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Mohamed,

Unfortutunately the syntax changes depending on the region settings of the computer as you have found out.  As you are doing this in script there is a way around it.  You can check out my blog that talks about this problem along with a solution: http://ideascripting.com/blog/2015/08/03/how-internationalize-and-locali...

Also if you have access to the IDEA 10 passport web site there is a document on there called "Internationalization of IDEAScript Macros" that also talks about this.

Good luck with your project.

Brian

mohamed
Offline
Joined: 07/27/2015 - 03:45

Thanks Brian for quick response.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Not a problem, unfortunately it is not an easy fix.  If you were creating this as a SmartAnalyzer app there are tools to do this much eaiser.

Good luck.

Brian

mohamed
Offline
Joined: 07/27/2015 - 03:45

I am using SmartAnalyzer App SDK. Could you please share how to implement localization using that.
Thanks,
Shafeer

mohamed
Offline
Joined: 07/27/2015 - 03:45

Please ignore above request. I got it from SA SDK help.
Dim SimpleCommands As Object
Dim value As String
 
Sub Main
Set SimpleCommands = SmartContext.MacroCommands.SimpleCommands
value = SimpleCommands.ListSeparator
'Release object.
Set SimpleCommands = Nothing
End Sub

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Shafeer,

Glad that you got it working.  How are you inserting the variable into your equations?  There is a fairly simple way to do this with the SDK, I don't have the code here at work but I can look it up for you tonight when I get home from work.

Brian

mohamed
Offline
Joined: 07/27/2015 - 03:45

Hi Brian,
I am storing the list separator in a string variable (sListSeparator ) initially and use that in equation like below.
field.Equation = "@compif(Status_Code=""1""" & sListSeparator & " ""Matched""" & sListSeparator & " Status_Code=""2""" & sListSeparator & """PO without INV""" & sListSeparator & " Status_Code=""3""" & sListSeparator & """INV without PO""" & sListSeparator & "Status_Code=""4""" & sListSeparator & """Missing Data""" & sListSeparator & "1" & sListSeparator & """Missing Data"")"
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

There is actually an easier way to do this.  Once I am at my computer with the SDK I will look it up for you and post it.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Shafeer,

There is a command called ReplaceByListSep that helps for these equations.  Yours above would look like this:

Set oSC = SmartContext.MacroCommands.SimpleCommands

field.Equation = oSC.ReplaceByListSep"@compif(Status_Code=""1"" ## ""Matched"" ## Status_Code=""2"" ## ""PO without INV"" ## Status_Code=""3"" ## ""INV without PO"" ## Status_Code=""4"" ## ""Missing Data"" ## 1 ## ""Missing Data"")", "##")

The ## is used to be replaced by the list separator, you define the ## at the end of the function so it can be anything that is unique, I think in their documentation they use ## as you would not see that combination in an IDEA equation.

Brian

mohamed
Offline
Joined: 07/27/2015 - 03:45

Hi Brian,
In Vietnam locale, both the list separator and decimal separator are comma (,).
So methods like @If is failing, if we called like this
@if(1=2, 0,1)
I think it is considering 0,1 as 0.1.  So incorrect paramter error is showing in equation editor.
Is there any way to move forward?
Thanks,
Shafeer

Images: 

Pages