From f0fc51ab506034db25dd325a3b3b0e123af62e98 Mon Sep 17 00:00:00 2001 From: Alain Romedenne Date: Tue, 28 Jul 2020 17:17:19 +0200 Subject: tdf131416 Basic syntax diagrams - Close, Get, Put and Open statements Change-Id: I09a89ededbf65c41a65e3d347111c9dac10cfdde Reviewed-on: https://gerrit.libreoffice.org/c/help/+/99601 Tested-by: Jenkins Reviewed-by: Olivier Hallot --- source/media/helpimg/sbasic/Close_statement.svg | 41 +++++++++++++ source/media/helpimg/sbasic/Get_statement.svg | 44 ++++++++++++++ source/media/helpimg/sbasic/Open_statement.svg | 57 ++++++++++++++++++ source/media/helpimg/sbasic/Put_statement.svg | 44 ++++++++++++++ source/media/helpimg/sbasic/access_fragment.svg | 39 +++++++++++++ source/media/helpimg/sbasic/locking_fragment.svg | 41 +++++++++++++ source/text/sbasic/shared/03020101.xhp | 43 ++++---------- source/text/sbasic/shared/03020103.xhp | 71 +++++++++++++---------- source/text/sbasic/shared/03020201.xhp | 73 +++++++++++++----------- source/text/sbasic/shared/03020204.xhp | 58 ++++++------------- 10 files changed, 378 insertions(+), 133 deletions(-) create mode 100644 source/media/helpimg/sbasic/Close_statement.svg create mode 100644 source/media/helpimg/sbasic/Get_statement.svg create mode 100644 source/media/helpimg/sbasic/Open_statement.svg create mode 100644 source/media/helpimg/sbasic/Put_statement.svg create mode 100644 source/media/helpimg/sbasic/access_fragment.svg create mode 100644 source/media/helpimg/sbasic/locking_fragment.svg (limited to 'source') diff --git a/source/media/helpimg/sbasic/Close_statement.svg b/source/media/helpimg/sbasic/Close_statement.svg new file mode 100644 index 0000000000..4a4a2135bd --- /dev/null +++ b/source/media/helpimg/sbasic/Close_statement.svg @@ -0,0 +1,41 @@ + + + + +Close + + + + + + +# +fileNum +, \ No newline at end of file diff --git a/source/media/helpimg/sbasic/Get_statement.svg b/source/media/helpimg/sbasic/Get_statement.svg new file mode 100644 index 0000000000..b2dc6d3418 --- /dev/null +++ b/source/media/helpimg/sbasic/Get_statement.svg @@ -0,0 +1,44 @@ + + + + +Get + + +# +fileNum +, + + + +filePos +recordNum +, +variable \ No newline at end of file diff --git a/source/media/helpimg/sbasic/Open_statement.svg b/source/media/helpimg/sbasic/Open_statement.svg new file mode 100644 index 0000000000..7c1e1e3572 --- /dev/null +++ b/source/media/helpimg/sbasic/Open_statement.svg @@ -0,0 +1,57 @@ + + + + +Open +pathname + +For + +Output +Input +Random +Append +Binary + + +access + + +locking +As + + +# +filenum + + + +Len= +recLen \ No newline at end of file diff --git a/source/media/helpimg/sbasic/Put_statement.svg b/source/media/helpimg/sbasic/Put_statement.svg new file mode 100644 index 0000000000..5f50458dcf --- /dev/null +++ b/source/media/helpimg/sbasic/Put_statement.svg @@ -0,0 +1,44 @@ + + + + +Put + + +# +fileNum +, + + + +filePos +recordNum +, +variable \ No newline at end of file diff --git a/source/media/helpimg/sbasic/access_fragment.svg b/source/media/helpimg/sbasic/access_fragment.svg new file mode 100644 index 0000000000..74302ec6c8 --- /dev/null +++ b/source/media/helpimg/sbasic/access_fragment.svg @@ -0,0 +1,39 @@ + + + + + + + +Access + +Read +Read Write +Write \ No newline at end of file diff --git a/source/media/helpimg/sbasic/locking_fragment.svg b/source/media/helpimg/sbasic/locking_fragment.svg new file mode 100644 index 0000000000..331f54690e --- /dev/null +++ b/source/media/helpimg/sbasic/locking_fragment.svg @@ -0,0 +1,41 @@ + + + + + + + +Share + +Lock + +Read +Read Write +Write \ No newline at end of file diff --git a/source/text/sbasic/shared/03020101.xhp b/source/text/sbasic/shared/03020101.xhp index 608027d66f..79247f40ca 100644 --- a/source/text/sbasic/shared/03020101.xhp +++ b/source/text/sbasic/shared/03020101.xhp @@ -34,44 +34,23 @@ -Close Statement +

Close Statement

Closes a specified file that was opened with the Open statement. -Syntax: + + + Close Statement diagram + -Close FileNumber As Integer[, FileNumber2 As Integer[,...]] +Close [[#]fileNum [, [#]fileNum2 [,...]]] -Parameters: - FileNumber: Any integer expression that specifies the number of the data channel that was opened with the Open statement. + + fileNum: Any integer expression that specifies the number of the data channel that was opened with the Open statement. -Example: - -Sub ExampleWorkWithAFile -Dim iNumber As Integer -Dim sLine As String -Dim aFile As String -Dim sMsg As String - aFile = "c:\data.txt" - sMsg = "" - iNumber = Freefile - Open aFile For Output As #iNumber - Print #iNumber, "First line of text" - Print #iNumber, "Another line of text" - Close #iNumber - iNumber = Freefile - Open aFile For Input As iNumber - While Not eof(iNumber) - Line Input #iNumber, sLine - If sLine <>"" Then - sMsg = sMsg & sLine & chr(13) - End If - Wend - Close #iNumber - MsgBox sMsg -End Sub - - + + + \ No newline at end of file diff --git a/source/text/sbasic/shared/03020103.xhp b/source/text/sbasic/shared/03020103.xhp index 14daf49553..bb605bc896 100644 --- a/source/text/sbasic/shared/03020103.xhp +++ b/source/text/sbasic/shared/03020103.xhp @@ -33,49 +33,60 @@ Open statement - -

Open Statement

+

Open Statement

Opens a data channel. + + Open Statement diagram + + + access fragment diagram + + + locking fragment diagram + -Open FileName As String [For Mode] [Access IOMode] [Protected] As [#]FileNumber As Integer [Len = DatasetLength]i37502 +Open pathname For mode [Access io] [locking] As [#]filenum [Len=recLen] - FileName: Name and path of the file to open. If you try to read a file that does not exist (Access = Read), an error message appears. If you try to write to a file that does not exist (Access = Write), a new file is created. - Mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), Binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files). - IOMode: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both). - Protected: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access). - FileNumber: Any integer expression from 0 to 511 to indicate the number of a free data channel. You can then pass commands through the data channel to access the file. The file number must be determined by the FreeFile function immediately before the Open statement. - DatasetLength: For random access files, set the length of the records.#61736 + pathname: Path and name of the file to open. If you try to read a file that does not exist (Access = Read), an error message appears. If you try to write to a file that does not exist (Access = Write), a new file is created. + mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), Binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files). + io: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both). + locking: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access). + filenum: Any integer expression from 0 to 511 to indicate the number of a free data channel. You can then pass commands through the data channel to access the file. The file number must be determined by the FreeFile function immediately before the Open statement. + recLen: For Random access files, set the length of the records.#61736 You can only modify the contents of a file that was opened with the Open statement. If you try to open a file that is already open, an error message appears. +
-Sub ExampleWorkWithAFile -Dim iNumber As Integer -Dim sLine As String -Dim aFile As String -Dim sMsg As String - aFile = "c:\data.txt" - iNumber = Freefile - Open aFile For Output As #iNumber +Sub ExampleWorkWithAFile +Dim iNumber As Integer +Dim sLine As String +Dim aFile As String +Dim sMsg As String + aFile = "c:\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber Print #iNumber, "This is a line of text" Print #iNumber, "This is another line of text" - Close #iNumber - iNumber = Freefile - Open aFile For Input As iNumber - While Not eof(iNumber) - Line Input #iNumber, sLine - If sLine <>"" Then - sMsg = sMsg & sLine & chr(13) - End If - Wend - Close #iNumber - MsgBox sMsg -End Sub + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + While Not eof(iNumber) + Line Input #iNumber, sLine + If sLine <>"" Then + sMsg = sMsg & sLine & chr(13) + End If + Wend + Close #iNumber + MsgBox sMsg +End Sub +
+ - + \ No newline at end of file diff --git a/source/text/sbasic/shared/03020201.xhp b/source/text/sbasic/shared/03020201.xhp index eb46b84dd8..b2885659d2 100644 --- a/source/text/sbasic/shared/03020201.xhp +++ b/source/text/sbasic/shared/03020201.xhp @@ -27,58 +27,67 @@ -
Get statement - -Get Statement +

Get Statement

Reads a record from a relative file, or a sequence of bytes from a binary file, into a variable.
See also: PUT Statement -Syntax: + + + Get Statement diagram + -Get [#] FileNumber As Integer, [Position], Variable +Get [#]fileNum, [recordNum|filePos], variable -Parameters: - FileNumber: Any integer expression that determines the file number. - Position: For files opened in Random mode, Position is the number of the record that you want to read. -For files opened in Binary mode, Position is the byte position in the file where the reading starts. -If Position is omitted, the current position or the current data record of the file is used. -Variable: Name of the variable to be read. With the exception of object variables, you can use any variable type. + + fileNum: Any integer expression that determines the file number. + recordNum: For files opened in Random mode, recordNum is the number of the record that you want to read. +For files opened in Binary mode, filePos is the byte position in the file where the reading starts. +If recordNum and filePos are omitted, the current position or the current data record of the file is used. + variable: Name of the variable to be read. With the exception of object variables, you can use any variable type. -Example: +
+ -Sub ExampleRandomAccess -Dim iNumber As Integer -Dim sText As Variant ' Must be a variant -Dim aFile As String - aFile = "c:\data.txt" - iNumber = Freefile - Open aFile For Random As #iNumber Len=32 +Sub ExampleRandomAccess + Dim iNumber As Integer + Dim sText As Variant ' Must be a variant + Dim aFile As String + aFile = "c:\data.txt" + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 Seek #iNumber,1 ' Position at beginning Put #iNumber,, "This is the first line of text" ' Fill line with text Put #iNumber,, "This is the second line of text" Put #iNumber,, "This is the third line of text" - Seek #iNumber,2 - Get #iNumber,,sText - Print sText - Close #iNumber - iNumber = Freefile - Open aFile For Random As #iNumber Len=32 - Get #iNumber,2,sText + Seek #iNumber,2 + Get #iNumber,,sText + Print sText + Close #iNumber + iNumber = Freefile + Open aFile For Random As #iNumber Len=32 + Get #iNumber,2,sText Put #iNumber,,"This is a new text" - Get #iNumber,1,sText - Get #iNumber,2,sText + Get #iNumber,1,sText + Get #iNumber,2,sText Put #iNumber,20,"This is the text in record 20" - Print Lof(#iNumber) - Close #iNumber -End Sub + Print Lof(#iNumber) + Close #iNumber +End Sub - +
+
+ + + +
+ + \ No newline at end of file diff --git a/source/text/sbasic/shared/03020204.xhp b/source/text/sbasic/shared/03020204.xhp index 79a276ecde..7549256374 100644 --- a/source/text/sbasic/shared/03020204.xhp +++ b/source/text/sbasic/shared/03020204.xhp @@ -26,60 +26,40 @@ - -
Put statement - -Put Statement +

Put Statement

Writes a record to a relative file or a sequence of bytes to a binary file.
See also: Get statement -Syntax: + + + Put Statement diagram + -Put [#] FileNumber As Integer, [position], Variable +Put [#]fileNum, [recordNum|filePos], variable -Parameters: - FileNumber: Any integer expression that defines the file that you want to write to. - Position: For relative files (random access files), the number of the record that you want to write. + + fileNum: Any integer expression that defines the file that you want to write to. + recordNum, filePos: For relative files (random access files), the number of the record that you want to write. For binary files (binary access), the position of the byte in the file where you want to start writing. - Variable: Name of the variable that you want to write to the file. + variable: Name of the variable that you want to write to the file. Note for relative files: If the contents of this variable does not match the length of the record that is specified in the Len clause of the Open statement, the space between the end of the newly written record and the next record is padded with existing data from the file that you are writing to. Note for binary files: The contents of the variables are written to the specified position, and the file pointer is inserted directly after the last byte. No space is left between the records. -Example: - -Sub ExampleRandomAccess -Dim iNumber As Integer -Dim sText As Variant ' Must be a variant type -Dim aFile As String - aFile = "c:\data.txt" - iNumber = Freefile - Open aFile For Random As #iNumber Len=32 - Seek #iNumber,1 ' Position To start writing - Put #iNumber,, "This is the first line of text" ' Fill line with text - Put #iNumber,, "This is the second line of text" - Put #iNumber,, "This is the third line of text" - Seek #iNumber,2 - Get #iNumber,,sText - Print sText - Close #iNumber - iNumber = Freefile - Open aFile For Random As #iNumber Len=32 - Get #iNumber,2,sText - Put #iNumber,,"This is new text" - Get #iNumber,1,sText - Get #iNumber,2,sText - Put #iNumber,20,"This is the text in record 20" - Print Lof(#iNumber) - Close #iNumber -End Sub - - + + + +
+ + + +
+ \ No newline at end of file -- cgit