diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /helpcontent2/source/text/sbasic/shared/property.xhp | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'helpcontent2/source/text/sbasic/shared/property.xhp')
-rw-r--r-- | helpcontent2/source/text/sbasic/shared/property.xhp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/property.xhp b/helpcontent2/source/text/sbasic/shared/property.xhp new file mode 100644 index 000000000..7a72e417e --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/property.xhp @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<helpdocument version="1.0"> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . +--> + <meta> + <topic id="text/sbasic/shared/Property"> + <title id="Property Statement" xml-lang="en-US">Property Statement</title> + <filename>/text/sbasic/shared/property.xhp</filename> + </topic> + </meta> + <body> + <bookmark branch="index" id="N0181"> + <bookmark_value>Property statement</bookmark_value> + </bookmark> + + <h1 id="N0182"><variable id="Property_h1"><link href="text/sbasic/shared/Property.xhp" name="Property statement">Property Statement</link></variable></h1> + <paragraph role="paragraph" id="N0183">A property, also called field or attribute, characterizes a given object or piece of information. Properties can be used to control access to data. It is common use to include instructions at setting or reading time of properties. Code can vary from simple assignment to complex context dependent routines. Using <emph>Get</emph>, <emph>Let</emph> or <emph>Set</emph> accessors enforces properties' consistency when necessary.</paragraph> + <warning id="N0184">This statement requires <link href="text/sbasic/shared/compatible.xhp" name ="Option Compatible">Option Compatible</link> to be placed before the executable program code in a module. </warning> + + <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/> + <paragraph role="paragraph" id="par_id971587473488701"> + <image src="media/helpimg/sbasic/Property-Get_statement.svg" id="img_id4156296484514"><alt xml-lang="en-US" id="alt_id15152796484514">Property Get Statement diagram</alt></image> + </paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="N0185">[Private | Public] Property Get name[char | As typename]</paragraph> + <paragraph role="bascode" localize="false" id="N0185b">End Property</paragraph> + </bascode> + + <paragraph role="paragraph" id="par_id972787473488701"> + <image src="media/helpimg/sbasic/Property-Set_statement.svg" id="img_id4156296484514"><alt xml-lang="en-US" id="alt_id15152796484514">Property Set Statement diagram</alt></image> + </paragraph> + <bascode> + <paragraph role="bascode" localize="false" id="N0186">[Private | Public] Property [Let | Set] name[char] [([Optional [ByRef | ByVal]]value[char | As typename])] [As typename]</paragraph> + <paragraph role="bascode" localize="false" id="N0187">End Property</paragraph> + </bascode> + + <embed href="text/sbasic/shared/00000003.xhp#functparameters"/> + <paragraph role="paragraph" id="par_id941588582710020"> <emph>name: </emph>The property name.</paragraph> + + <paragraph id="par_id3147229" role="paragraph" xml-lang="en-US"> <emph>argument:</emph> Value to be passed to the <literal>Property</literal> setter routine.</paragraph> + <note id="par_id301588583826717"><literal>Property</literal> setters often use a single argument. Multiple arguments are equally accepted.</note> + + <embed href="text/sbasic/shared/fragments.xhp#argument"/> + <embed href="text/sbasic/shared/fragments.xhp#typename"/> + <embed href="text/sbasic/shared/fragments.xhp#char"/> + + <h2 id="N0188">Examples</h2> + <bascode> + <paragraph role="bascode" localize="false" id="N0189">Option Compatible</paragraph> + <paragraph role="bascode" localize="false" id="N0190">Sub Main</paragraph> + <paragraph role="bascode" localize="false" id="N0191"> ProductName = "Office"</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0192"> Print ProductName ' displays "%PRODUCTNAME"</paragraph> + <paragraph role="bascode" localize="false" id="N0193">End Sub</paragraph> + <paragraph role="bascode" localize="false" id="N0194"></paragraph> + <paragraph role="bascode" localize="false" id="N0195">Private _office As String</paragraph> + <paragraph role="bascode" localize="false" id="N0196">Property Get ProductName As String</paragraph> + <paragraph role="bascode" localize="false" id="N0197"> ProductName = _office</paragraph> + <paragraph role="bascode" localize="false" id="N0198">End Property</paragraph> + <paragraph role="bascode" localize="false" id="N0199">Property Let ProductName(value As String)</paragraph> + <paragraph role="bascode" localize="false" id="N0200"> _office = "Libre"& value</paragraph> + <paragraph role="bascode" localize="false" id="N0201">End Property</paragraph> + </bascode> + <tip id="N0202">In the absence of Property <emph>Let</emph> or Property <emph>Set</emph>, Property <emph>Get</emph> helps define protected information, which can not be accidently altered by a foreign module:</tip> + <bascode> + <paragraph role="bascode" localize="false" id="N0203">Option Compatible</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0204">Public Property Get PathDelimiter As String ' Read-only variable</paragraph> + <paragraph role="bascode" localize="false" id="N0205"> Static this As String</paragraph> + <paragraph role="bascode" localize="false" id="N0206"> If this = "" Then : Select Case GetGuiType()</paragraph> + <paragraph role="bascode" localize="false" id="N0207"> Case 1 : this = ";" ' Windows</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0208"> Case 4 : this = ":" ' Linux or macOS</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0209"> Case Else : Error 423 ' Property or method not defined: PathDelimiter</paragraph> + <paragraph role="bascode" localize="false" id="N0210"> End Select : End If</paragraph> + <paragraph role="bascode" localize="false" id="N0211"> PathDelimiter = this</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0212">End Property ' read-only PathDelimiter</paragraph> + <paragraph role="bascode" localize="false" id="N0213"></paragraph> + <paragraph role="bascode" localize="false" id="N0214">Sub Main</paragraph> + <paragraph role="bascode" xml-lang="en-US" id="N0215"> PathDelimiter = "a sentence" ' does nothing</paragraph> + <paragraph role="bascode" localize="false" id="N0216">End Sub</paragraph> + </bascode> + <note id="N0217">Use <emph>Let</emph> or <emph>Set</emph> when handling UNO services or class objects:</note> + <bascode> + <paragraph role="bascode" localize="false" id="N0218">Option Compatible</paragraph> + <paragraph role="bascode" localize="false" id="N0219">Sub Main</paragraph> + <paragraph role="bascode" localize="false" id="N0220"> 'Set anObject = CreateUnoService( "com.sun.star.frame.Desktop" )</paragraph> + <paragraph role="bascode" localize="false" id="N0221"> anObject = CreateUnoService( "com.sun.star.frame.Desktop" )</paragraph> + <paragraph role="bascode" localize="false" id="N0222"> Print anObject.SupportedServiceNames(0) ' displays "com.sun.star.frame.Frame"</paragraph> + <paragraph role="bascode" localize="false" id="N0223">End Sub</paragraph> + <paragraph role="bascode" localize="false" id="N0224"></paragraph> + <paragraph role="bascode" localize="false" id="N0225">Property Get anObject As Object</paragraph> + <paragraph role="bascode" localize="false" id="N0226"> Set anObject = _obj</paragraph> + <paragraph role="bascode" localize="false" id="N0227">End Property</paragraph> + <paragraph role="bascode" localize="false" id="N0228"></paragraph> + <paragraph role="bascode" localize="false" id="N0229">Private _obj As Object</paragraph> + <paragraph role="bascode" localize="false" id="N0230"></paragraph> + <paragraph role="bascode" localize="false" id="N0231">'Property Set anObject(value As Object)</paragraph> + <paragraph role="bascode" localize="false" id="N0232"> 'Set _obj = value.CurrentFrame</paragraph> + <paragraph role="bascode" localize="false" id="N0233">'End Property</paragraph> + <paragraph role="bascode" localize="false" id="N0234">Property Let anObject(value As Object)</paragraph> + <paragraph role="bascode" localize="false" id="N0235"> Set _obj = value.CurrentFrame</paragraph> + <paragraph role="bascode" localize="false" id="N0236">End Property</paragraph> + </bascode> + <section id="relatedtopics" > + <paragraph role="paragraph" id="par_id181647247913872"><link href="text/sbasic/shared/01010210.xhp" name="Subroutine basics">Subroutines basics</link></paragraph> + <embed href="text/sbasic/shared/01020300.xhp#UsingSubs_h1"/> + <embed href="text/sbasic/shared/03090406.xhp#Function_h1"/> + <embed href="text/sbasic/shared/03090409.xhp#Sub_h1"/> + <paragraph role="paragraph" id="N0237"><link href="text/sbasic/shared/03090404.xhp" name="End">End</link>, <link href="text/sbasic/shared/03090412.xhp" name="Exit">Exit</link> statements</paragraph> + <embed href="text/sbasic/shared/classmodule.xhp#classmodulestatement"/> + <embed href="text/sbasic/shared/compatible.xhp#compatiblestatement"/> + </section> + </body> +</helpdocument> |