summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/shared/enum.xhp
blob: 79e6057bda77050b0a1440d82b48f761bf4ad242 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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/.
    *
     -->
    <meta>
        <topic id="org.LibreOffice.Help.Enum" indexer="include" status="PUBLISH">
            <title id="tit" xml-lang="en-US">Enum Statement</title>
            <filename>/text/sbasic/shared/enum.xhp</filename>
        </topic>
    </meta>
    <body>
    <bookmark branch="index" xml-lang="en-US" id="N0001">
        <bookmark_value>Enum statement</bookmark_value>
        <bookmark_value>constant groups</bookmark_value>
        <bookmark_value>enumerations</bookmark_value>
    </bookmark>
    <section id="enumheading">
        <h1 id="hd_id221543446540070"><link href="text/sbasic/shared/enum.xhp">Enum Statement [VBA]</link></h1>
        <paragraph role="paragraph" id="N0003">Define enumerations or non UNO constant groups. An enumeration is a value list that facilitates programming and eases code logic review.</paragraph>
    </section>
    <embed href="text/sbasic/shared/00000003.xhp#vbasupport"/>
    <embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
    <paragraph role="image" id="par_id831588865616326">
       <image src="media/helpimg/sbasic/Enum_statement.svg" id="img_id651588865616326"><alt id="alt_id281588865616326">Enum syntax</alt></image>
    </paragraph>
    <bascode>
       <paragraph role="bascode" id="par_id931543441922328" localize="false">Enum list_name<br/></paragraph>
       <paragraph role="bascode" id="par_id771543441931669" localize="false">    &apos; Object Statement block</paragraph>
       <paragraph role="bascode" id="par_id21543441938004"  localize="false">End Enum &apos; list_name</paragraph>
    </bascode>
    <h2 id="N0006">Parameters:</h2>
    <paragraph role="paragraph" id="N0007">Within a given enumeration, fit together values that logically relate to one another.</paragraph>
    <embed href="text/sbasic/shared/00000003.xhp#functexample"/>
    <bascode>
       <paragraph role="bascode" id="N0008" localize="false">Option VBASupport 1<br/></paragraph>
       <paragraph role="bascode" id="N0018" localize="false">Private Enum _WindowManager</paragraph>
       <paragraph role="bascode" id="N0019" localize="false">    W1ND0WS = 1 &apos; Windows</paragraph>
       <paragraph role="bascode" id="N0020" localize="false">    OS2PM = 2 &apos; OS/2 Presentation Manager</paragraph>
       <paragraph role="bascode" id="N0021" localize="false">    MACINTOSH = 3 &apos; Macintosh</paragraph>
       <paragraph role="bascode" id="N0022" localize="false">    MOTIF = 4 &apos; Motif Window Manager / Unix-like</paragraph>
       <paragraph role="bascode" id="N0023" localize="false">    OPENLOOK = 5 &apos; Open Look / Unix-like</paragraph>
       <paragraph role="bascode" id="N0024" localize="false">End Enum</paragraph>
       <paragraph role="bascode" id="N0027" localize="false">Public Function WindowManager() As Object</paragraph>
       <paragraph role="bascode" id="N0028" localize="false">    WindowManager = _WindowManager</paragraph>
       <paragraph role="bascode" id="N0029" localize="false">End Function &apos; &lt;library&gt;.&lt;module&gt;.WindowManager.XXX</paragraph>
    </bascode>
    <note  id="N0030">Enumerated values are rendered to <emph>Long</emph> datatype. Basic functions are public accessors to enumerations. Enumeration names and value names must be unique within a library and across modules.</note>

    <h2 id="N0036">Usage:</h2>
    <paragraph role="paragraph" id="N0037">Display WindowManager grouped constant values:</paragraph>
    <bascode>
       <paragraph role="bascode" id="N0038" localize="false">Dim winMgr As Object : winMgr = &lt;library&gt;.&lt;module&gt;.WindowManager</paragraph>
       <paragraph role="bascode" id="N0039" localize="false">With winMgr</paragraph>
       <paragraph role="bascode" id="N0040" localize="false">    Print .MACINTOSH, .MOTIF, .OPENLOOK, .OS2PM, .W1ND0WS</paragraph>
       <paragraph role="bascode" id="N0041" localize="false">End With</paragraph>
    </bascode>
    <tip id="par_id731573636687662">Enumerations can be extended to other data types using <link href="text/sbasic/shared/03090413.xhp">Type statement</link> definitions. <link href="text/sbasic/guide/basic_2_python.xhp">Calling Python Scripts from Basic</link> illustrates that mechanism.</tip>
    <section id="relatedtopics" >
        <paragraph role="paragraph" id="N0051"><link href="text/sbasic/shared/03100700.xhp">Const</link> statement, <link href="text/sbasic/shared/01020100.xhp">constants</link></paragraph>
        <paragraph role="paragraph" id="N0053"><link href="text/sbasic/shared/03103350.xhp">Option VBASupport</link> statement</paragraph>
        <paragraph role="paragraph" id="N0061"><link href="text/sbasic/shared/03090411.xhp">With</link> statement</paragraph>
    </section>
</body>
</helpdocument>