Skip to main content

@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?
 

Brian Element Fri, 08/12/2016 - 07:35

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-local…

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 Tue, 08/16/2016 - 00:54

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

mohamed Tue, 08/16/2016 - 02:11

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 Tue, 08/16/2016 - 07:26

In reply to by mohamed

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 Tue, 08/16/2016 - 10:59

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 Tue, 08/16/2016 - 11:16

In reply to by mohamed

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 Tue, 08/16/2016 - 16:49

In reply to by mohamed

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 Fri, 02/10/2017 - 09:51

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