diff options
Diffstat (limited to '')
-rw-r--r-- | helpcontent2/source/text/sbasic/shared/03020202.xhp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/shared/03020202.xhp b/helpcontent2/source/text/sbasic/shared/03020202.xhp new file mode 100644 index 000000000..b84c2dc82 --- /dev/null +++ b/helpcontent2/source/text/sbasic/shared/03020202.xhp @@ -0,0 +1,90 @@ +<?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="textsbasicshared03020202xml" indexer="include" status="PUBLISH"> + <title id="tit" xml-lang="en-US">Input# Statement</title> + <filename>/text/sbasic/shared/03020202.xhp</filename> + </topic> +</meta> + +<body> + + +<section id="input"> +<bookmark xml-lang="en-US" branch="index" id="bm_id3154908"> + <bookmark_value>Input statement</bookmark_value> +</bookmark> + + +<paragraph id="hd_id3154908" role="heading" level="1" xml-lang="en-US"><link href="text/sbasic/shared/03020202.xhp" name="Input# Statement">Input# Statement</link></paragraph> +<paragraph id="par_id3156424" role="paragraph" xml-lang="en-US">Reads data from an open sequential file.</paragraph> +</section> + +<paragraph id="hd_id3125863" role="heading" level="2" xml-lang="en-US">Syntax:</paragraph> +<paragraph id="par_id3150440" role="code" xml-lang="en-US">Input #FileNumber As Integer; var1[, var2[, var3[,...]]]</paragraph> + +<paragraph id="hd_id3146121" role="heading" level="2" xml-lang="en-US">Parameters:</paragraph> +<paragraph id="par_id3145749" role="paragraph" xml-lang="en-US"> <emph>FileNumber:</emph> Number of the file that contains the data that you want to read. The file must be opened with the Open statement using the key word INPUT.</paragraph> +<paragraph id="par_id3150011" role="paragraph" xml-lang="en-US"> <emph>var:</emph> A numeric or string variable that you assign the values read from the opened file to.</paragraph> +<paragraph id="par_id3159153" role="paragraph" xml-lang="en-US">The <emph>Input#</emph> statement reads numeric values or strings from an open file and assigns the data to one or more variables. A numeric variable is read up to the first carriage return (Asc=13), line feed (Asc=10), space, or comma. String variables are read to up to the first carriage return (Asc=13), line feed (Asc=10), or comma.</paragraph> +<paragraph id="par_id3146984" role="paragraph" xml-lang="en-US">Data and data types in the opened file must appear in the same order as the variables that are passed in the "var" parameter. If you assign non-numeric values to a numeric variable, "var" is assigned a value of "0".</paragraph> +<paragraph id="par_id3156442" role="paragraph" xml-lang="en-US">Records that are separated by commas cannot be assigned to a string variable. Quotation marks (") in the file are disregarded as well. If you want to read these characters from the file, use the <emph>Line Input#</emph> statement to read pure text files (files containing only printable characters) line by line.</paragraph> +<paragraph id="par_id3147349" role="paragraph" xml-lang="en-US">If the end of the file is reached while reading a data element, an error occurs and the process is aborted.</paragraph> + +<paragraph id="hd_id3152578" role="heading" level="2" xml-lang="en-US">Example:</paragraph> +<bascode> +<paragraph id="par_idm871097888" role="bascode" localize="false" xml-lang="en-US">Sub ExampleWorkWithAFile</paragraph> +<paragraph id="par_idm871096912" role="bascode" localize="false" xml-lang="en-US">Dim iCount As Integer</paragraph> +<paragraph id="par_idm871095952" role="bascode" localize="false" xml-lang="en-US">Dim sName As String</paragraph> +<paragraph id="par_idm871094992" role="bascode" localize="false" xml-lang="en-US">Dim sValue As Integer</paragraph> +<paragraph id="par_idm871094032" role="bascode" localize="false" xml-lang="en-US">Dim sFileName As String</paragraph> +<paragraph id="par_idm871093072" role="bascode" localize="false" xml-lang="en-US"> </paragraph> +<paragraph id="par_idm871092096" role="bascode" localize="false" xml-lang="en-US">sFileName = "c:\data.txt"</paragraph> +<paragraph id="par_idm871091120" role="bascode" localize="false" xml-lang="en-US">iCount = Freefile</paragraph> +<paragraph id="par_idm871090160" role="bascode" localize="false" xml-lang="en-US"> </paragraph> +<paragraph id="par_id4144765" role="bascode" xml-lang="en-US">' Write data ( which we will read later with Input ) to file</paragraph> +<paragraph id="par_idm871087952" role="bascode" localize="false" xml-lang="en-US">Open sFileName For Output As iCount</paragraph> +<paragraph id="par_idm871086976" role="bascode" localize="false" xml-lang="en-US">sName = "Hamburg"</paragraph> +<paragraph id="par_idm871086016" role="bascode" localize="false" xml-lang="en-US">sValue = 200</paragraph> +<paragraph id="par_idm871085056" role="bascode" localize="false" xml-lang="en-US">Write #iCount, sName, sValue</paragraph> +<paragraph id="par_idm871084080" role="bascode" localize="false" xml-lang="en-US">sName = "New York"</paragraph> +<paragraph id="par_idm871083120" role="bascode" localize="false" xml-lang="en-US">sValue = 300</paragraph> +<paragraph id="par_idm871082160" role="bascode" localize="false" xml-lang="en-US">Write #iCount, sName, sValue</paragraph> +<paragraph id="par_idm871081184" role="bascode" localize="false" xml-lang="en-US">sName = "Miami"</paragraph> +<paragraph id="par_idm871080224" role="bascode" localize="false" xml-lang="en-US">sValue = 459</paragraph> +<paragraph id="par_idm871079264" role="bascode" localize="false" xml-lang="en-US">Write #iCount, sName, sValue</paragraph> +<paragraph id="par_idm871078288" role="bascode" localize="false" xml-lang="en-US">Close #iCount</paragraph> +<paragraph id="par_idm871077328" role="bascode" localize="false" xml-lang="en-US"> </paragraph> +<paragraph id="par_idm871076400" role="bascode" localize="false" xml-lang="en-US">iCount = Freefile</paragraph> +<paragraph id="par_id4144766" role="bascode" xml-lang="en-US">' Read data file using Input</paragraph> +<paragraph id="par_idm871074192" role="bascode" localize="false" xml-lang="en-US">Open sFileName For Input As iCount</paragraph> +<paragraph id="par_idm871073216" role="bascode" localize="false" xml-lang="en-US">Input #iCount; sName, sValue</paragraph> +<paragraph id="par_idm871072240" role="bascode" localize="false" xml-lang="en-US">MsgBox sName & " " & sValue</paragraph> +<paragraph id="par_idm871071264" role="bascode" localize="false" xml-lang="en-US">Input #iCount; sName, sValue</paragraph> +<paragraph id="par_idm871070288" role="bascode" localize="false" xml-lang="en-US">MsgBox sName & " " & sValue</paragraph> +<paragraph id="par_idm871069312" role="bascode" localize="false" xml-lang="en-US">Input #iCount; sName, sValue</paragraph> +<paragraph id="par_idm871068336" role="bascode" localize="false" xml-lang="en-US">MsgBox sName & " " & sValue</paragraph> +<paragraph id="par_idm871067360" role="bascode" localize="false" xml-lang="en-US">Close #iCount</paragraph> +<paragraph id="par_idm871066400" role="bascode" localize="false" xml-lang="en-US">End Sub</paragraph> +</bascode> +</body> + +</helpdocument>
\ No newline at end of file |