Difference between revisions of "Documentation/DevGuide/ProUNO/Basic/Case Sensitivity"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (FINAL VERSION FOR L10N)
m
 
Line 11: Line 11:
  
 
Identifiers that differ in case are considered to be identical when they are used with UNO object properties, methods and struct members.
 
Identifiers that differ in case are considered to be identical when they are used with UNO object properties, methods and struct members.
 
+
<source lang="oobas">
 
   Dim ALocale As New com.sun.star.lang.Locale
 
   Dim ALocale As New com.sun.star.lang.Locale
 
   alocale.language = "en"    ' Ok
 
   alocale.language = "en"    ' Ok
 
   MsgBox aLocale.Language    ' Ok
 
   MsgBox aLocale.Language    ' Ok
 
+
</source>
 
The exceptions to this is if a Basic property is obtained through <idl>com.sun.star.container.XNameAccess</idl> as described above, its name has to be written exactly as it is in the API reference. Basic uses the name as a string parameter that is not interpreted when accessing <idl>com.sun.star.container.XNameAccess</idl> using its methods.
 
The exceptions to this is if a Basic property is obtained through <idl>com.sun.star.container.XNameAccess</idl> as described above, its name has to be written exactly as it is in the API reference. Basic uses the name as a string parameter that is not interpreted when accessing <idl>com.sun.star.container.XNameAccess</idl> using its methods.
 
+
<source lang="oobas">
 
   ' oNameAccessible is an object that supports XNameAccess
 
   ' oNameAccessible is an object that supports XNameAccess
 
    
 
    
Line 28: Line 28:
 
   x = oNameAccessible.getByName( "Value1" ) ' Ok
 
   x = oNameAccessible.getByName( "Value1" ) ' Ok
 
   y = oNameAccessible.getByName( "VaLUe2" ) ' Runtime Error, Value2 is not written correctly
 
   y = oNameAccessible.getByName( "VaLUe2" ) ' Runtime Error, Value2 is not written correctly
 
+
</source>
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Professional UNO]]
 
[[Category:Documentation/Developer's Guide/Professional UNO]]

Latest revision as of 11:39, 22 October 2009



Generally Basic is case insensitive. However, this does not always apply to the communication between UNO and Basic. To avoid problems with case sensitivity write the UNO related code as if Basic was case sensitive. This facilitates the translation of a Basic program to another language, and Basic code becomes easier to read and understand. The following discusses problems that might occur.

Identifiers that differ in case are considered to be identical when they are used with UNO object properties, methods and struct members.

  Dim ALocale As New com.sun.star.lang.Locale
  alocale.language = "en"     ' Ok
  MsgBox aLocale.Language     ' Ok

The exceptions to this is if a Basic property is obtained through com.sun.star.container.XNameAccess as described above, its name has to be written exactly as it is in the API reference. Basic uses the name as a string parameter that is not interpreted when accessing com.sun.star.container.XNameAccess using its methods.

  ' oNameAccessible is an object that supports XNameAccess
 
  ' including the names "Value1", "Value2"
  x = oNameAccessible.Value1 ' Ok
  y = oNameAccessible.VaLUe2 ' Runtime Error, Value2 is not written correctly
 
  ' is the same as
 
  x = oNameAccessible.getByName( "Value1" ) ' Ok
  y = oNameAccessible.getByName( "VaLUe2" ) ' Runtime Error, Value2 is not written correctly
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages