Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Features/Standard-Library/File-IO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Open "C:\MyFile.txt" For Input Encoding utf_8 As #1

## Supported Encodings

See the [TextEncodingConstants module](../../tB/Modules/TextEncodingConstants/).
See the [Text Encodings table](../../tB/Core/Open#text-encodings) on the **Open** statement reference page.
1 change: 0 additions & 1 deletion docs/Miscellaneous/Documentation Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ These are modules within VBA and VBRUN:
- [Interaction](../tB/Modules/Interaction)
- [Math](../tB/Modules/Math)
- [Strings](../tB/Modules/Strings)
- [TextEncodingConstants](../tB/Modules/TextEncodingConstants)
- Internal [_HiddenModule](../tB/Modules/HiddenModule)
- VBRUN
- [AmbientProperties](../tB/Modules/AmbientProperties)
Expand Down
16 changes: 8 additions & 8 deletions docs/Reference/Categories.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Procedures:
See also:

* [Dim](../tB/Core/Dim) - allocate a scalar or array variable
* [Array](../tB/Modules/HiddenModule/Array), [Filter](../tB/Modules/Strings/Filter), [Join](../tB/Modules/Strings/Join), [Split](../tB/Modules/Strings/Split) - array helpers
* [Array](../tB/Modules/Information/Array), [Filter](../tB/Modules/Strings/Filter), [Join](../tB/Modules/Strings/Join), [Split](../tB/Modules/Strings/Split) - array helpers
* [vbaAryMove](../tB/Modules/HiddenModule/vbaAryMove), [vbaRefVarAry](../tB/Modules/HiddenModule/vbaRefVarAry) - low-level **Variant**-array helpers (see [Memory and Pointers](#memory-and-pointers))

## File I/O
Expand All @@ -137,9 +137,9 @@ Statements:
Procedures:

* [Reset](../tB/Core/Reset) - close all open disk files
* [Width](../tB/Modules/HiddenModule/Width) - set the limit for line lengths when printing
* [Input, Input$](../tB/Modules/HiddenModule/Input) - read a fixed number of characters from a sequential file
* [InputB, InputB$](../tB/Modules/HiddenModule/InputB) - read a fixed number of bytes from a sequential file
* [Width](../tB/Modules/FileSystem/Width) - set the limit for line lengths when printing
* [Input, Input$](../tB/Modules/FileSystem/Input) - read a fixed number of characters from a sequential file
* [InputB, InputB$](../tB/Modules/FileSystem/InputB) - read a fixed number of bytes from a sequential file
* [ChDir](../tB/Core/ChDir), [ChDrive](../tB/Core/ChDrive) - change the current working directory and disk drive
* [MkDir](../tB/Core/MkDir), [RmDir](../tB/Core/RmDir) - create/remove a directory on disk
* [Name](../tB/Core/Name) - rename a file or directory on disk
Expand Down Expand Up @@ -207,7 +207,7 @@ Procedures:

See also:

* [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) - return the COM-identity address of an object (see [Memory and Pointers](#memory-and-pointers))
* [ObjPtr](../tB/Modules/Information/ObjPtr) - return the COM-identity address of an object (see [Memory and Pointers](#memory-and-pointers))

## Command Line and Environment

Expand Down Expand Up @@ -387,9 +387,9 @@ See also:

Procedures:

* [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) - return the COM-identity address of an object
* [StrPtr](../tB/Modules/HiddenModule/StrPtr) - return the address of the underlying buffer of a **String**
* [VarPtr](../tB/Modules/HiddenModule/VarPtr) - return the address of a variable
* [ObjPtr](../tB/Modules/Information/ObjPtr) - return the COM-identity address of an object
* [StrPtr](../tB/Modules/Information/StrPtr) - return the address of the underlying buffer of a **String**
* [VarPtr](../tB/Modules/Information/VarPtr) - return the address of a variable
* [AllocMem](../tB/Modules/HiddenModule/AllocMem), [FreeMem](../tB/Modules/HiddenModule/FreeMem) - allocate/release native memory blocks
* [GetMem1](../tB/Modules/HiddenModule/GetMem1), [GetMem2](../tB/Modules/HiddenModule/GetMem2), [GetMem4](../tB/Modules/HiddenModule/GetMem4), [GetMem8](../tB/Modules/HiddenModule/GetMem8), [GetMemPtr](../tB/Modules/HiddenModule/GetMemPtr) - read N bytes from a memory address into a typed variable
* [PutMem1](../tB/Modules/HiddenModule/PutMem1), [PutMem2](../tB/Modules/HiddenModule/PutMem2), [PutMem4](../tB/Modules/HiddenModule/PutMem4), [PutMem8](../tB/Modules/HiddenModule/PutMem8), [PutMemPtr](../tB/Modules/HiddenModule/PutMemPtr) - write a typed value of N bytes to a memory address
Expand Down
4 changes: 2 additions & 2 deletions docs/Reference/Core/Input.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vba_attribution: true
Reads data from an open sequential file and assigns the data to variables.

> [!NOTE]
> This page documents the **Input #** *statement*. The unrelated [**Input** function](../Modules/HiddenModule/Input) reads a fixed number of characters from any open file.
> This page documents the **Input #** *statement*. The unrelated [**Input** function](../Modules/FileSystem/Input) reads a fixed number of characters from any open file.

Syntax:
> **Input** **#** *filenumber* **,** *varlist*
Expand Down Expand Up @@ -66,5 +66,5 @@ Close #1 ' Close file.
- [**Line Input #** statement](Line-Input)
- [**Write #** statement](Write)
- [**Print #** statement](Print)
- [**Input** function](../Modules/HiddenModule/Input)
- [**Input** function](../Modules/FileSystem/Input)
- [**EOF** function](../Modules/FileSystem/EOF)
91 changes: 88 additions & 3 deletions docs/Reference/Core/Open.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Open
parent: Statements
permalink: /tB/Core/Open
redirect_from:
- /tB/Modules/TextEncodingConstants
vba_attribution: true
---
# Open
Expand All @@ -25,7 +27,7 @@ Syntax:
: *optional* Keyword specifying the operations restricted on the open file by other processes: **Shared**, **Lock Read**, **Lock Write**, or **Lock Read Write**.

*encoding*
: *optional* An encoding identifier from the [**TextEncodingConstants**](../Modules/TextEncodingConstants/) module — for example **utf_8**, **utf_16**, **windows_1252_western**, or **default_system_ansi**. The IDE surfaces these constants automatically in IntelliSense after the **Encoding** keyword. Other system-supported encodings with similar identifier strings are also accepted at runtime. The **Encoding** clause applies to text-mode I/O (**Input**, **Output**, **Append**); it has no effect on **Binary** or **Random** mode files.
: *optional* An encoding identifier — for example **utf_8**, **utf_16**, **windows_1252_western**, or **default_system_ansi**. See [Text Encodings](#text-encodings) below for the full list. The **Encoding** clause applies to text-mode I/O (**Input**, **Output**, **Append**); it has no effect on **Binary** or **Random** mode files.

*filenumber*
: A valid file number in the range 1 to 511, inclusive. Use the [**FreeFile**](../Modules/FileSystem/FreeFile) function to obtain the next available file number.
Expand Down Expand Up @@ -95,14 +97,98 @@ This code example opens the file in **Binary** mode for reading; other processes
Open "TESTFILE" For Binary Access Read Lock Read As #1
```

This example reads a UTF-8 text file. The **Encoding** clause names the [TextEncodingConstants](../Modules/TextEncodingConstants/) constant for UTF-8.
This example reads a UTF-8 text file, naming the [**utf_8**](#utf_8) encoding identifier.

```tb
Open "C:\MyFile.txt" For Input Encoding utf_8 As #1
' Subsequent Line Input #, Input #, etc. interpret bytes as UTF-8.
Close #1
```

### Text Encodings

These identifier strings are accepted as the **Encoding** argument. The constants listed below name the well-known encodings; other system-supported encodings with similar identifier strings are also accepted at runtime. All members are marked **[Hidden, Restricted]** — they are omitted from general IntelliSense, but the IDE surfaces them automatically after the **Encoding** keyword.

#### Default and Unicode

| Constant | Value | Description |
|----------|-------|-------------|
| **default_system_ansi**{: #default_system_ansi } | `"default"` | The system default ANSI code page. |
| **utf_7**{: #utf_7 } | `"utf-7"` | UTF-7. |
| **utf_7_bom**{: #utf_7_bom } | `"utf-7 bom"` | UTF-7 with byte-order mark. |
| **utf_8**{: #utf_8 } | `"utf-8"` | UTF-8. |
| **utf_8_bom**{: #utf_8_bom } | `"utf-8 bom"` | UTF-8 with byte-order mark. |
| **utf_16**{: #utf_16 } | `"utf-16"` | UTF-16 (little-endian). |
| **utf_16_bom**{: #utf_16_bom } | `"utf-16 bom"` | UTF-16 with byte-order mark. |
| **us_ascii**{: #us_ascii } | `"us-ascii"` | 7-bit US-ASCII. |

#### KOI8 (Cyrillic)

| Constant | Value | Description |
|----------|-------|-------------|
| **koi8_r**{: #koi8_r } | `"koi8_r"` | KOI8-R, Russian. |
| **koi8_u**{: #koi8_u } | `"koi8_u"` | KOI8-U, Ukrainian. |

#### Big5

| Constant | Value | Description |
|----------|-------|-------------|
| **big5**{: #big5 } | `"big5"` | Big5, Traditional Chinese. |

#### ISO 8859

| Constant | Value | Description |
|----------|-------|-------------|
| **iso_8859_1_latin1**{: #iso_8859_1_latin1 } | `"iso-8859-1"` | Latin-1, Western European. |
| **iso_8859_2_latin2**{: #iso_8859_2_latin2 } | `"iso-8859-2"` | Latin-2, Central European. |
| **iso_8859_3_latin3**{: #iso_8859_3_latin3 } | `"iso-8859-3"` | Latin-3, South European (Esperanto, Maltese). |
| **iso_8859_4_latin4**{: #iso_8859_4_latin4 } | `"iso-8859-4"` | Latin-4, North European. |
| **iso_8859_5_cyrillic**{: #iso_8859_5_cyrillic } | `"iso-8859-5"` | Cyrillic. |
| **iso_8859_6_arabic**{: #iso_8859_6_arabic } | `"iso-8859-6"` | Arabic. |
| **iso_8859_7_greek**{: #iso_8859_7_greek } | `"iso-8859-7"` | Greek. |
| **iso_8859_8_hebrew**{: #iso_8859_8_hebrew } | `"iso-8859-8"` | Hebrew. |
| **iso_8859_9_latin5_turkish**{: #iso_8859_9_latin5_turkish } | `"iso-8859-9"` | Latin-5, Turkish. |
| **iso_8859_10_latin6_nordic**{: #iso_8859_10_latin6_nordic } | `"iso-8859-10"` | Latin-6, Nordic. |
| **iso_8859_11_thai**{: #iso_8859_11_thai } | `"iso-8859-11"` | Thai. |
| **iso_8859_13_latin8_baltic**{: #iso_8859_13_latin8_baltic } | `"iso-8859-13"` | Latin-7, Baltic Rim. |
| **iso_8859_14_latin8_celtic**{: #iso_8859_14_latin8_celtic } | `"iso-8859-14"` | Latin-8, Celtic. |
| **iso_8859_15_latin9_euro**{: #iso_8859_15_latin9_euro } | `"iso-8859-15"` | Latin-9, Western European with euro sign. |
| **iso_8859_16_latin10_balkan**{: #iso_8859_16_latin10_balkan } | `"iso-8859-16"` | Latin-10, South-Eastern European. |

#### Windows code pages

| Constant | Value | Description |
|----------|-------|-------------|
| **windows_1250_central_europe**{: #windows_1250_central_europe } | `"windows-1250"` | Central European. |
| **windows_1251_cyrillic**{: #windows_1251_cyrillic } | `"windows-1251"` | Cyrillic. |
| **windows_1252_western**{: #windows_1252_western } | `"windows-1252"` | Western European. |
| **windows_1253_greek**{: #windows_1253_greek } | `"windows-1253"` | Greek. |
| **windows_1254_turkish**{: #windows_1254_turkish } | `"windows-1254"` | Turkish. |
| **windows_1255_hebrew**{: #windows_1255_hebrew } | `"windows-1255"` | Hebrew. |
| **windows_1256_arabic**{: #windows_1256_arabic } | `"windows-1256"` | Arabic. |
| **windows_1257_baltic**{: #windows_1257_baltic } | `"windows-1257"` | Baltic. |
| **windows_1258_vietnamese**{: #windows_1258_vietnamese } | `"windows-1258"` | Vietnamese. |

#### IBM/OEM code pages

| Constant | Value | Description |
|----------|-------|-------------|
| **ibm_850_western_europe**{: #ibm_850_western_europe } | `"850"` | OEM Multilingual Latin-1, Western European. |
| **ibm_852_central_and_eastern_europe**{: #ibm_852_central_and_eastern_europe } | `"852"` | OEM Latin-2, Central and Eastern European. |
| **ibm_855_cyrillic**{: #ibm_855_cyrillic } | `"855"` | OEM Cyrillic (primarily pre-Unicode Russian). |
| **ibm_856_hebrew**{: #ibm_856_hebrew } | `"856"` | Hebrew. |
| **ibm_857_turkish**{: #ibm_857_turkish } | `"857"` | OEM Turkish (Latin-5). |
| **ibm_858_western_europe**{: #ibm_858_western_europe } | `"858"` | OEM Multilingual Latin-1 with euro sign. |
| **ibm_860_portuguese**{: #ibm_860_portuguese } | `"860"` | Portuguese. |
| **ibm_861_icelandic**{: #ibm_861_icelandic } | `"861"` | Icelandic. |
| **ibm_862_hebrew**{: #ibm_862_hebrew } | `"862"` | Hebrew. |
| **ibm_863_canadian**{: #ibm_863_canadian } | `"863"` | French Canadian. |
| **ibm_865_danish**{: #ibm_865_danish } | `"865"` | Nordic (Danish, Norwegian). |
| **ibm_866_cyrillic**{: #ibm_866_cyrillic } | `"866"` | Russian. |
| **ibm_869_greek**{: #ibm_869_greek } | `"869"` | Modern Greek. |
| **ibm_932_japanese**{: #ibm_932_japanese } | `"932"` | Japanese (Shift-JIS, Microsoft variant). |
| **ibm_949_korean**{: #ibm_949_korean } | `"949"` | Korean (Unified Hangul Code). |

### See Also

- [**Close** statement](Close)
Expand All @@ -114,4 +200,3 @@ Close #1
- [**Write #** statement](Write)
- [**Lock** / **Unlock** statements](Lock)
- [**FreeFile** function](../Modules/FileSystem/FreeFile)
- [**TextEncodingConstants** module](../Modules/TextEncodingConstants/)
14 changes: 7 additions & 7 deletions docs/Reference/Procedures and Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ permalink: /Reference/Procedures-and-Functions
- [Abs](../tB/Modules/Math/Abs) -- returns the absolute value of a number
- [AllocMem](../tB/Modules/HiddenModule/AllocMem) -- allocates a block of native memory and returns its address
- [AppActivate](../tB/Modules/Interaction/AppActivate) -- activates an application window
- [Array](../tB/Modules/HiddenModule/Array) -- creates a **Variant** array from a comma-separated list of values, or destructures one when used on the left of an assignment
- [Array](../tB/Modules/Information/Array) -- creates a **Variant** array from a comma-separated list of values, or destructures one when used on the left of an assignment
- [Asc, AscB, AscW](../tB/Modules/Strings/Asc) -- returns the character code of the first letter in a string
- [Atn](../tB/Modules/Math/Atn) -- returns the arctangent of a number

Expand Down Expand Up @@ -127,8 +127,8 @@ permalink: /Reference/Procedures-and-Functions
- [If](../tB/Modules/Interaction/If) -- evaluates an expression and returns one of two values, with short-circuit evaluation
- [IIf](../tB/Modules/Interaction/IIf) -- evaluates an expression and returns one of two values; both branches are always evaluated
- [IMEStatus](../tB/Modules/Information/IMEStatus) -- returns the status of the Input Method Editor
- [Input, Input$](../tB/Modules/HiddenModule/Input) -- reads a fixed number of characters from an open sequential file
- [InputB, InputB$](../tB/Modules/HiddenModule/InputB) -- reads a fixed number of bytes from an open sequential file
- [Input, Input$](../tB/Modules/FileSystem/Input) -- reads a fixed number of characters from an open sequential file
- [InputB, InputB$](../tB/Modules/FileSystem/InputB) -- reads a fixed number of bytes from an open sequential file
- [InputBox](../tB/Modules/Interaction/InputBox) -- prompts the user for a line of text and returns what was entered
- [InStr$, InStrB, InStr](../tB/Modules/Strings/InStr) -- returns the position of one string within another
- [InStrRev](../tB/Modules/Strings/InStrRev) -- returns the position of one string within another, searching from the end
Expand Down Expand Up @@ -186,7 +186,7 @@ permalink: /Reference/Procedures-and-Functions

## O

- [ObjPtr](../tB/Modules/HiddenModule/ObjPtr) -- returns the COM-identity address of an object
- [ObjPtr](../tB/Modules/Information/ObjPtr) -- returns the COM-identity address of an object
- [Oct$, Oct](../tB/Modules/Conversion/Oct) -- returns a string representing the octal value of a number

## P
Expand Down Expand Up @@ -246,7 +246,7 @@ permalink: /Reference/Procedures-and-Functions
- [StrComp](../tB/Modules/Strings/StrComp) -- compares two strings
- [StrConv](../tB/Modules/Strings/StrConv) -- converts a string to a specified format
- [String$, String](../tB/Modules/Strings/String) -- returns a string of repeating characters
- [StrPtr](../tB/Modules/HiddenModule/StrPtr) -- returns the address of the underlying buffer of a **String**
- [StrPtr](../tB/Modules/Information/StrPtr) -- returns the address of the underlying buffer of a **String**
- [StrReverse](../tB/Modules/Strings/StrReverse) -- reverses the order of characters in a string
- [Switch](../tB/Modules/Interaction/Switch) -- returns the value paired with the first **True** condition in a list of (condition, value) pairs
- [SYD](../tB/Modules/Financial/SYD) -- returns the sum-of-years' digits depreciation of an asset for a specified period
Expand All @@ -272,7 +272,7 @@ permalink: /Reference/Procedures-and-Functions

- [Val](../tB/Modules/Conversion/Val) -- parses a string into a **Double**
- [ValDec](../tB/Modules/Conversion/ValDec) -- parses a string into a **Decimal**
- [VarPtr](../tB/Modules/HiddenModule/VarPtr) -- returns the address of a variable
- [VarPtr](../tB/Modules/Information/VarPtr) -- returns the address of a variable
- [VarType](../tB/Modules/Information/VarType) -- returns the **VbVarType** enumeration value identifying a variable's subtype
- [vbaCastObj](../tB/Modules/HiddenModule/vbaCastObj) -- returns an object reinterpreted as another COM interface
- [vbaCopyBytes](../tB/Modules/HiddenModule/vbaCopyBytes) -- copies a block of bytes from one address to another
Expand All @@ -285,7 +285,7 @@ permalink: /Reference/Procedures-and-Functions

- [Weekday](../tB/Modules/DateTime/Weekday) -- returns the day of the week from a date value
- [WeekdayName](../tB/Modules/Strings/WeekdayName) -- returns the name of the specified day of the week
- [Width](../tB/Modules/HiddenModule/Width) -- sets the line width for a sequential output file
- [Width](../tB/Modules/FileSystem/Width) -- sets the line width for a sequential output file

## X

Expand Down
Loading