<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fother_instructions</id>
	<title>EN/documentation/basic guide/other instructions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fother_instructions"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/other_instructions&amp;action=history"/>
	<updated>2026-11-11T14:00:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/other_instructions&amp;diff=15893&amp;oldid=prev</id>
		<title>Sancho: Created page with &quot;&lt;section begin=title /&gt;&lt;noinclude&gt;{{DISPLAYTITLE:&lt;/noinclude&gt;Other Instructions&lt;noinclude&gt;}}&lt;/noinclude&gt;&lt;section end=title /&gt;{{BreadCrumbL10n}}  {{Documentation/BASICGuideTOC |Sh...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/other_instructions&amp;diff=15893&amp;oldid=prev"/>
		<updated>2011-09-01T15:48:27Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Other Instructions&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}  {{Documentation/BASICGuideTOC |Sh...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;Other Instructions&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/error_handling&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/runtime_library&lt;br /&gt;
|lang=block&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&lt;br /&gt;
== '''&amp;lt;tt&amp;gt;Type...End Type&amp;lt;/tt&amp;gt;''' ==&lt;br /&gt;
&lt;br /&gt;
A ''struct'' is a collection of data fields, that can be manipulated as a single item. In older terms, you may think of a struct as a record, or part of a record.&lt;br /&gt;
&lt;br /&gt;
The [[EN/documentation/basic_guide/api_intro|API]] often uses pre-defined structs, but these are ''UNO structs'', a highly-specialized kind of struct.&lt;br /&gt;
&lt;br /&gt;
=== Definition ===&lt;br /&gt;
&lt;br /&gt;
With the &amp;lt;tt&amp;gt;Type...End Type&amp;lt;/tt&amp;gt; statements, you can define your own (non-UNO) structs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Type aMenuItem			'assign the name of the type&lt;br /&gt;
    'Define the data fields within the struct. Each&lt;br /&gt;
    ' definition looks like a Dim statement, without the &amp;quot;Dim&amp;quot;.&lt;br /&gt;
    aCommand as String		&lt;br /&gt;
    aText as String&lt;br /&gt;
End Type			'close the definition&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Instance ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Type&amp;lt;/tt&amp;gt; definition is only a pattern or template, not a set of actual variables. To make an ''instance'' of the type, actual variables that can be read and stored, use the &amp;lt;tt&amp;gt;Dim as New&amp;lt;/tt&amp;gt; statement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim maItem as New aMenuItem&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
As shown in the example below, the &amp;lt;tt&amp;gt;Type&amp;lt;/tt&amp;gt; definition may be written at the start of a module (before the first &amp;lt;tt&amp;gt;Sub&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Function&amp;lt;/tt&amp;gt;). The definition will then be available to all routines in the module.&lt;br /&gt;
&lt;br /&gt;
As of {{OOo}} Version 3.0, unlike variables, there is no way to make the definition accessible outside of the module.&lt;br /&gt;
&lt;br /&gt;
An instance of the new type ''is'' a variable, and follows the usual rules for variable scope (see [[EN/documentation/basic_guide/scope_of_variables|Scope and Life Span of Variables]]).&lt;br /&gt;
&lt;br /&gt;
An example of how to use the definition, and how to reference the fields within an instance, appears in the section on &amp;lt;tt&amp;gt;With...End With&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== '''&amp;lt;tt&amp;gt;With...End With&amp;lt;/tt&amp;gt;''' ==&lt;br /&gt;
=== Qualifiers ===&lt;br /&gt;
In general, Basic does not look inside a container, such as an &amp;lt;tt&amp;gt;Object&amp;lt;/tt&amp;gt;, to see what names might be defined there. If you want to use such a name, you must tell Basic where to look. You do that by using the name of the object as a ''qualifier''. Write it before the inner name, and separate it by a period:&lt;br /&gt;
&lt;br /&gt;
 MyObject.SomeName&lt;br /&gt;
&lt;br /&gt;
Since containers may hold other containers, you may need more than one qualifier. Write the qualifiers in order, from outer to inner:&lt;br /&gt;
&lt;br /&gt;
 OuterObject.InnerObject.FarInsideObject.SomeName&lt;br /&gt;
&lt;br /&gt;
These names may also be described as, &amp;quot;concatenated with the dot-operator ('.')&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== The &amp;lt;tt&amp;gt;With&amp;lt;/tt&amp;gt; Alternative ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;With...End With&amp;lt;/tt&amp;gt; bracketing statements provide an alternative to writing out all the qualifiers, every time - and some of the qualifiers in the API can be quite long. You specify the qualifiers in the &amp;lt;tt&amp;gt;With&amp;lt;/tt&amp;gt; statement. Until Basic encounters the &amp;lt;tt&amp;gt;End With&amp;lt;/tt&amp;gt; statement, it looks for ''partly-qualified'' names: names that begin with a period (unary dot-operator). The compiler uses the qualifiers from the &amp;lt;tt&amp;gt;With&amp;lt;/tt&amp;gt; as though they were written in front of the partly-qualified name.&lt;br /&gt;
&lt;br /&gt;
=== Example 1: A User-defined Struct ===&lt;br /&gt;
&lt;br /&gt;
This example shows how you may define and use a struct, and how to reference the items within it, both with and without &amp;lt;tt&amp;gt;With&amp;lt;/tt&amp;gt;. Either way, the names of the data fields (from the &amp;lt;tt&amp;gt;Type&amp;lt;/tt&amp;gt; definition) must be qualified by the name of the instance (from the &amp;lt;tt&amp;gt;Dim&amp;lt;/tt&amp;gt; statement).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Type aMenuItem&lt;br /&gt;
    aCommand as String&lt;br /&gt;
    aText as String&lt;br /&gt;
End Type&lt;br /&gt;
     &lt;br /&gt;
Sub Main&lt;br /&gt;
    'Create an instance of the user-defined struct.&lt;br /&gt;
    ' Note the keyword, &amp;quot;New&amp;quot;.&lt;br /&gt;
    Dim maItem as New aMenuItem&lt;br /&gt;
    With maItem&lt;br /&gt;
        .aCommand = &amp;quot;.uno:Copy&amp;quot;&lt;br /&gt;
        .aText = &amp;quot;~Copy&amp;quot;&lt;br /&gt;
    End With&lt;br /&gt;
    &lt;br /&gt;
    MsgBox     &amp;quot;Command: &amp;quot; &amp;amp; maItem.aCommand &amp;amp; Chr(13) _&lt;br /&gt;
            &amp;amp; &amp;quot;Text: &amp;quot; &amp;amp; maItem.aText&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 2: Case statement ===&lt;br /&gt;
&lt;br /&gt;
In [[EN/documentation/basic_guide/cells_and_ranges|Cells and Ranges]], the following example has the qualifiers in the &amp;lt;tt&amp;gt;Case&amp;lt;/tt&amp;gt; statements written out completely, for clarity.  You can write it more easily, this way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim Cell As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
Cell = Sheet.getCellByPosition(1,1)	'Cell &amp;quot;B2&amp;quot; (0-based!)&lt;br /&gt;
&lt;br /&gt;
Cell.Value = 1000&lt;br /&gt;
&lt;br /&gt;
With com.sun.star.table.CellContentType&lt;br /&gt;
  Select Case Cell.Type&lt;br /&gt;
    Case .EMPTY &lt;br /&gt;
      MsgBox &amp;quot;Content: Empty&amp;quot;&lt;br /&gt;
    Case .VALUE&lt;br /&gt;
      MsgBox &amp;quot;Content: Value&amp;quot;&lt;br /&gt;
    Case .TEXT&lt;br /&gt;
      MsgBox &amp;quot;Content: Text&amp;quot;&lt;br /&gt;
    Case .FORMULA&lt;br /&gt;
     MsgBox &amp;quot;Content: Formula&amp;quot;&lt;br /&gt;
  End Select&lt;br /&gt;
End With&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Notice that the &amp;lt;tt&amp;gt;With&amp;lt;/tt&amp;gt; construct must be entirely outside of the &amp;lt;tt&amp;gt;Select&amp;lt;/tt&amp;gt; construct.&lt;br /&gt;
&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>