From 82e70eb6efa88c3d21606292a042cd6978385480 Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Wed, 6 Oct 2021 16:17:39 +0200 Subject: tdf#143687 Document the "IS" Basic keyword This patch also improves related help pages about the functions IsObject and EqualUnoObjects. Change-Id: I5f16596ed057c1104d5fa2650299861741bd7b2e Reviewed-on: https://gerrit.libreoffice.org/c/help/+/123153 Tested-by: Jenkins Reviewed-by: Alain Romedenne --- source/auxiliary/sbasic.tree | 1 + source/text/sbasic/shared/03090413.xhp | 34 +++++++------- source/text/sbasic/shared/03102800.xhp | 60 +++++++++++++------------ source/text/sbasic/shared/03104600.xhp | 76 +++++++++++++++++++------------- source/text/sbasic/shared/is_keyword.xhp | 71 +++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 75 deletions(-) create mode 100644 source/text/sbasic/shared/is_keyword.xhp (limited to 'source') diff --git a/source/auxiliary/sbasic.tree b/source/auxiliary/sbasic.tree index f811d03911..73969aca11 100644 --- a/source/auxiliary/sbasic.tree +++ b/source/auxiliary/sbasic.tree @@ -194,6 +194,7 @@ Int Function IPmt Function [VBA] IRR Function [VBA] + Is Operator IsArray Function IsDate Function IsEmpty Function diff --git a/source/text/sbasic/shared/03090413.xhp b/source/text/sbasic/shared/03090413.xhp index e7c2329ea5..38c6709ae9 100644 --- a/source/text/sbasic/shared/03090413.xhp +++ b/source/text/sbasic/shared/03090413.xhp @@ -1,5 +1,5 @@ - + - - - - Type Statement - /text/sbasic/shared/03090413.xhp - - - -
- - Type statement - - Type Statement - Define non-UNO data structures. -
+ + + Type Statement + /text/sbasic/shared/03090413.xhp + + + + +
+ + Type statement + +

Type Statement

+ Define non-UNO data structures. +
A Type structure is an ordered collection of data fields, that can be manipulated as a single item. Type statement diagram @@ -66,4 +66,4 @@ CreateObject function -
\ No newline at end of file +
diff --git a/source/text/sbasic/shared/03102800.xhp b/source/text/sbasic/shared/03102800.xhp index 650992598e..4655ee47f6 100644 --- a/source/text/sbasic/shared/03102800.xhp +++ b/source/text/sbasic/shared/03102800.xhp @@ -1,4 +1,5 @@ + - + - -IsObject Function -/text/sbasic/shared/03102800.xhp - - -Sun Microsystems, Inc. - + + IsObject Function + /text/sbasic/shared/03102800.xhp + + + Sun Microsystems, Inc. + -
-IsObject function - -IsObject Function -Tests if a variable is an object, as opposed to primitive data types such as dates, numbers, texts. The function returns True if the variable is an object, otherwise it returns False. -
-Syntax: - -IsObject(var) - -Return value: -Boolean -Parameters: - -var: Any variable that you want to test. - - -The following objects return True: +
+ + IsObject function + +

IsObject Function

+ Tests if a variable is an object, as opposed to primitive data types such as dates, numbers, texts. The function returns True if the variable is an object, otherwise it returns False. +
+ This function returns True for the following object types: OLE objects or UNO objects Class module object instances @@ -53,8 +44,21 @@ %PRODUCTNAME Basic modules Data structures return True even when empty. Object defined variables return True even if uninitialized. + + + IsObject(var) + + + Boolean + + + var: The variable to be tested. + + +
- Enum statement + + Enum statement @@ -65,4 +69,4 @@ Using variables
-
\ No newline at end of file +
diff --git a/source/text/sbasic/shared/03104600.xhp b/source/text/sbasic/shared/03104600.xhp index 1339f6bc61..a3bd26262f 100644 --- a/source/text/sbasic/shared/03104600.xhp +++ b/source/text/sbasic/shared/03104600.xhp @@ -1,5 +1,5 @@ - + - - -EqualUnoObjects Function -/text/sbasic/shared/03104600.xhp - - -Sun Microsystems, Inc. - + + EqualUnoObjects Function + /text/sbasic/shared/03104600.xhp + + + Sun Microsystems, Inc. + + -
-EqualUnoObjects function - -EqualUnoObjects Function -Returns True if the two specified Basic Uno objects represent the same Uno object instance. -
- -EqualUnoObjects( oObj1, oObj2 ) - -Bool - - - ' Copy of objects -> same instance - oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) - oIntro2 = oIntrospection - print EqualUnoObjects( oIntrospection, oIntro2 ) - ' Copy of structs as value -> new instance - Dim Struct1 as new com.sun.star.beans.Property - Struct2 = Struct1 - print EqualUnoObjects( Struct1, Struct2 ) - +
+ + EqualUnoObjects function + +

EqualUnoObjects Function

+ Returns True if the two specified Basic variables represent the same Uno object instance. +
+ + + EqualUnoObjects(oObj1, oObj2) + + + oObj1, oObj2: the variables to be tested. + + Bool + + The example below returns True because both oDoc and ThisComponent are references to the same object: + + Dim oDoc as Object + oDoc = ThisComponent + MsgBox EqualUnoObjects(oDoc, ThisComponent) ' True + + The example below returns False because the assignment creates a copy of the original object. Hence Struct1 and Struct2 refer to different object instances. + + Dim Struct1 as new com.sun.star.beans.PropertyValue + Dim Struct1 Variant + a.Name = "John" + b = a + MsgBox EqualUnoObjects(Struct1, Struct2) ' False + b.Name = "Judy" + MsgBox a.Name ' John + MsgBox b.Name ' Judy + + +
+ +
diff --git a/source/text/sbasic/shared/is_keyword.xhp b/source/text/sbasic/shared/is_keyword.xhp new file mode 100644 index 0000000000..6501e237c0 --- /dev/null +++ b/source/text/sbasic/shared/is_keyword.xhp @@ -0,0 +1,71 @@ + + + + + + + Is Operator + /text/sbasic/shared/is_keyword.xhp + + + +
+ + Is Operator + +

Is Operator

+ Tests if two Basic variables refer to the same object instance. +
+ + + result = oObj1 Is oObj2 + + If oObj1 and oObj2 are references to the same object instance, the result will be True. + + The example below first defines a new type Student. Calling TestObjects creates the object oStudent1 as a new object of this type. + The assignment oStudent2 = oStudent1 actually copies the reference to the same object. Hence the result of applying the Is operator is True. + + Type Student + FirstName as String + Program as String + End Type + + Sub TestObjects + Dim oStudent1 as new Student + Dim oStudent2 as Variant + oStudent2 = oStudent1 + MsgBox Student1 Is Student2 ' True + End Sub + + The example below returns False because oStudent1 and oStudent2 are references to two different object instances, each created with the New operator. + + Sub TestObjects_v2 + Dim oStudent1 as new Student + Dim oStudent2 as new Student + MsgBox oStudent1 Is oStudent2 ' False + End Sub + + +
+ + + +
+ +
-- cgit