From ff39701b0e841035089929ab7811c7431ab9b39b Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Thu, 15 Nov 2012 11:10:24 +0100 Subject: format Basic code examples --- source/text/sbasic/shared/01020100.xhp | 124 ++++++++++++++++++++++++--------- source/text/sbasic/shared/01020300.xhp | 91 +++++++++++++++--------- source/text/sbasic/shared/03010101.xhp | 18 +++-- source/text/sbasic/shared/03010102.xhp | 18 +++-- source/text/sbasic/shared/03010103.xhp | 23 +++--- source/text/sbasic/shared/03010201.xhp | 16 +++-- source/text/sbasic/shared/03010301.xhp | 22 +++--- source/text/sbasic/shared/03010302.xhp | 22 +++--- source/text/sbasic/shared/03010303.xhp | 22 +++--- source/text/sbasic/shared/03010304.xhp | 20 +++--- source/text/sbasic/shared/03010305.xhp | 22 +++--- source/text/sbasic/shared/03020101.xhp | 52 +++++++------- source/text/sbasic/shared/03020102.xhp | 52 +++++++------- source/text/sbasic/shared/03020103.xhp | 50 +++++++------ source/text/sbasic/shared/03020104.xhp | 56 ++++++++------- source/text/sbasic/shared/03020201.xhp | 56 ++++++++------- source/text/sbasic/shared/03020202.xhp | 12 ++-- source/text/sbasic/shared/03020203.xhp | 50 +++++++------ source/text/sbasic/shared/03020204.xhp | 56 ++++++++------- source/text/sbasic/shared/03020205.xhp | 32 +++++---- source/text/sbasic/shared/03020301.xhp | 50 +++++++------ source/text/sbasic/shared/03020302.xhp | 4 +- source/text/sbasic/shared/03020304.xhp | 4 +- source/text/sbasic/shared/03020305.xhp | 4 +- source/text/sbasic/shared/03020401.xhp | 24 ++++--- source/text/sbasic/shared/03020402.xhp | 12 ++-- source/text/sbasic/shared/03020403.xhp | 24 ++++--- source/text/sbasic/shared/03020404.xhp | 42 ++++++----- source/text/sbasic/shared/03020405.xhp | 30 ++++---- source/text/sbasic/shared/03020406.xhp | 12 ++-- source/text/sbasic/shared/03020407.xhp | 12 ++-- source/text/sbasic/shared/03020408.xhp | 12 ++-- source/text/sbasic/shared/03020409.xhp | 32 +++++---- source/text/sbasic/shared/03020410.xhp | 12 ++-- source/text/sbasic/shared/03020411.xhp | 91 ++++++++++++------------ source/text/sbasic/shared/03020412.xhp | 28 ++++---- source/text/sbasic/shared/03020413.xhp | 20 +++--- source/text/sbasic/shared/03020414.xhp | 32 +++++---- source/text/sbasic/shared/03020415.xhp | 16 +++-- source/text/sbasic/shared/03030101.xhp | 4 +- source/text/sbasic/shared/03030102.xhp | 4 +- source/text/sbasic/shared/03030103.xhp | 4 +- source/text/sbasic/shared/03030104.xhp | 4 +- source/text/sbasic/shared/03030105.xhp | 4 +- source/text/sbasic/shared/03030106.xhp | 4 +- source/text/sbasic/shared/03030107.xhp | 12 ++-- source/text/sbasic/shared/03030108.xhp | 4 +- source/text/sbasic/shared/03030110.xhp | 12 ++-- source/text/sbasic/shared/03030120.xhp | 12 ++-- source/text/sbasic/shared/03030130.xhp | 12 ++-- source/text/sbasic/shared/03030201.xhp | 4 +- source/text/sbasic/shared/03030202.xhp | 4 +- source/text/sbasic/shared/03030203.xhp | 12 ++-- source/text/sbasic/shared/03030204.xhp | 12 ++-- source/text/sbasic/shared/03030205.xhp | 20 +++--- source/text/sbasic/shared/03030206.xhp | 34 +++++---- source/text/sbasic/shared/03030301.xhp | 12 ++-- source/text/sbasic/shared/03030302.xhp | 12 ++-- source/text/sbasic/shared/03030303.xhp | 26 ++++--- source/text/sbasic/shared/03050100.xhp | 32 +++++---- source/text/sbasic/shared/03050200.xhp | 4 +- source/text/sbasic/shared/03050300.xhp | 4 +- source/text/sbasic/shared/03050500.xhp | 56 ++++++++------- source/text/sbasic/shared/03060100.xhp | 26 ++++--- source/text/sbasic/shared/03060200.xhp | 26 ++++--- source/text/sbasic/shared/03060300.xhp | 26 ++++--- source/text/sbasic/shared/03060400.xhp | 24 ++++--- source/text/sbasic/shared/03060500.xhp | 26 ++++--- source/text/sbasic/shared/03060600.xhp | 26 ++++--- source/text/sbasic/shared/03070100.xhp | 27 ++++--- source/text/sbasic/shared/03070200.xhp | 27 ++++--- source/text/sbasic/shared/03070300.xhp | 27 ++++--- source/text/sbasic/shared/03070400.xhp | 27 ++++--- source/text/sbasic/shared/03070500.xhp | 14 ++-- source/text/sbasic/shared/03070600.xhp | 22 +++--- source/text/sbasic/shared/03080101.xhp | 26 ++++--- source/text/sbasic/shared/03080102.xhp | 24 ++++--- source/text/sbasic/shared/03080103.xhp | 26 ++++--- source/text/sbasic/shared/03080104.xhp | 26 ++++--- source/text/sbasic/shared/03080201.xhp | 20 +++--- source/text/sbasic/shared/03080202.xhp | 20 +++--- source/text/sbasic/shared/03080301.xhp | 34 +++++---- source/text/sbasic/shared/03080302.xhp | 34 +++++---- source/text/sbasic/shared/03080401.xhp | 16 +++-- source/text/sbasic/shared/03080501.xhp | 16 +++-- source/text/sbasic/shared/03080502.xhp | 16 +++-- source/text/sbasic/shared/03080601.xhp | 20 +++--- source/text/sbasic/shared/03080701.xhp | 16 +++-- source/text/sbasic/shared/03080801.xhp | 42 ++++++----- source/text/sbasic/shared/03080802.xhp | 12 ++-- source/text/sbasic/shared/03090101.xhp | 39 ++++++----- source/text/sbasic/shared/03090102.xhp | 34 +++++---- source/text/sbasic/shared/03090103.xhp | 4 +- source/text/sbasic/shared/03090201.xhp | 26 +++---- source/text/sbasic/shared/03090202.xhp | 70 ++++++++++--------- source/text/sbasic/shared/03090203.xhp | 28 ++++---- source/text/sbasic/shared/03090301.xhp | 40 ++++++----- source/text/sbasic/shared/03090302.xhp | 4 +- source/text/sbasic/shared/03090303.xhp | 46 ++++++------ source/text/sbasic/shared/03090401.xhp | 4 +- source/text/sbasic/shared/03090402.xhp | 23 +++--- source/text/sbasic/shared/03090403.xhp | 20 +++--- source/text/sbasic/shared/03090404.xhp | 34 +++++---- source/text/sbasic/shared/03090405.xhp | 20 +++--- source/text/sbasic/shared/03090406.xhp | 49 +++++++------ source/text/sbasic/shared/03090407.xhp | 18 +++-- source/text/sbasic/shared/03090408.xhp | 18 +++-- source/text/sbasic/shared/03090409.xhp | 16 +++-- source/text/sbasic/shared/03090410.xhp | 23 +++--- source/text/sbasic/shared/03090411.xhp | 4 +- source/text/sbasic/shared/03090412.xhp | 53 +++++++------- source/text/sbasic/shared/03100050.xhp | 4 +- source/text/sbasic/shared/03100060.xhp | 4 +- source/text/sbasic/shared/03100070.xhp | 4 +- source/text/sbasic/shared/03100080.xhp | 4 +- source/text/sbasic/shared/03100100.xhp | 28 ++++---- source/text/sbasic/shared/03100300.xhp | 14 ++-- source/text/sbasic/shared/03100400.xhp | 12 ++-- source/text/sbasic/shared/03100500.xhp | 16 +++-- source/text/sbasic/shared/03100600.xhp | 16 +++-- source/text/sbasic/shared/03100700.xhp | 18 +++-- source/text/sbasic/shared/03100900.xhp | 18 +++-- source/text/sbasic/shared/03101000.xhp | 24 ++++--- source/text/sbasic/shared/03101100.xhp | 28 ++++---- source/text/sbasic/shared/03101110.xhp | 4 +- source/text/sbasic/shared/03101120.xhp | 30 ++++---- source/text/sbasic/shared/03101130.xhp | 30 ++++---- source/text/sbasic/shared/03101140.xhp | 30 ++++---- source/text/sbasic/shared/03101300.xhp | 28 ++++---- source/text/sbasic/shared/03101400.xhp | 28 ++++---- source/text/sbasic/shared/03101500.xhp | 28 ++++---- source/text/sbasic/shared/03101600.xhp | 28 ++++---- source/text/sbasic/shared/03101700.xhp | 4 +- source/text/sbasic/shared/03102000.xhp | 30 ++++---- source/text/sbasic/shared/03102100.xhp | 55 ++++++++------- source/text/sbasic/shared/03102101.xhp | 30 ++++---- source/text/sbasic/shared/03102200.xhp | 14 ++-- source/text/sbasic/shared/03102300.xhp | 20 +++--- source/text/sbasic/shared/03102400.xhp | 16 +++-- source/text/sbasic/shared/03102450.xhp | 4 +- source/text/sbasic/shared/03102600.xhp | 14 ++-- source/text/sbasic/shared/03102700.xhp | 20 +++--- source/text/sbasic/shared/03102800.xhp | 4 +- source/text/sbasic/shared/03102900.xhp | 31 +++++---- source/text/sbasic/shared/03103000.xhp | 31 +++++---- source/text/sbasic/shared/03103100.xhp | 16 +++-- source/text/sbasic/shared/03103200.xhp | 16 +++-- source/text/sbasic/shared/03103300.xhp | 22 +++--- source/text/sbasic/shared/03103400.xhp | 16 +++-- source/text/sbasic/shared/03103450.xhp | 16 +++-- source/text/sbasic/shared/03103500.xhp | 43 +++++++----- source/text/sbasic/shared/03103600.xhp | 34 +++++---- source/text/sbasic/shared/03103700.xhp | 16 +++-- source/text/sbasic/shared/03103800.xhp | 4 +- source/text/sbasic/shared/03103900.xhp | 4 +- source/text/sbasic/shared/03104000.xhp | 4 +- source/text/sbasic/shared/03104100.xhp | 4 +- source/text/sbasic/shared/03104200.xhp | 6 +- source/text/sbasic/shared/03104300.xhp | 6 +- source/text/sbasic/shared/03104400.xhp | 4 +- source/text/sbasic/shared/03104500.xhp | 34 +++++---- source/text/sbasic/shared/03104600.xhp | 4 +- source/text/sbasic/shared/03104700.xhp | 4 +- source/text/sbasic/shared/03110100.xhp | 30 ++++---- source/text/sbasic/shared/03120101.xhp | 16 +++-- source/text/sbasic/shared/03120102.xhp | 16 +++-- source/text/sbasic/shared/03120103.xhp | 20 +++--- source/text/sbasic/shared/03120104.xhp | 14 ++-- source/text/sbasic/shared/03120105.xhp | 4 +- source/text/sbasic/shared/03120201.xhp | 26 ++++--- source/text/sbasic/shared/03120202.xhp | 20 +++--- source/text/sbasic/shared/03120301.xhp | 16 +++-- source/text/sbasic/shared/03120302.xhp | 18 +++-- source/text/sbasic/shared/03120303.xhp | 28 ++++---- source/text/sbasic/shared/03120304.xhp | 52 +++++++------- source/text/sbasic/shared/03120305.xhp | 30 ++++---- source/text/sbasic/shared/03120306.xhp | 28 ++++---- source/text/sbasic/shared/03120307.xhp | 28 ++++---- source/text/sbasic/shared/03120308.xhp | 52 +++++++------- source/text/sbasic/shared/03120309.xhp | 30 ++++---- source/text/sbasic/shared/03120310.xhp | 14 ++-- source/text/sbasic/shared/03120311.xhp | 30 ++++---- source/text/sbasic/shared/03120312.xhp | 4 +- source/text/sbasic/shared/03120313.xhp | 4 +- source/text/sbasic/shared/03120314.xhp | 79 +++++++++++---------- source/text/sbasic/shared/03120315.xhp | 4 +- source/text/sbasic/shared/03120401.xhp | 20 +++--- source/text/sbasic/shared/03120402.xhp | 4 +- source/text/sbasic/shared/03120403.xhp | 20 +++--- source/text/sbasic/shared/03130100.xhp | 4 +- source/text/sbasic/shared/03130500.xhp | 8 ++- source/text/sbasic/shared/03130600.xhp | 4 +- source/text/sbasic/shared/03130700.xhp | 20 +++--- source/text/sbasic/shared/03130800.xhp | 18 +++-- source/text/sbasic/shared/03131000.xhp | 16 +++-- source/text/sbasic/shared/03131300.xhp | 12 ++-- source/text/sbasic/shared/03131400.xhp | 12 ++-- source/text/sbasic/shared/03131500.xhp | 4 +- source/text/sbasic/shared/03131600.xhp | 31 +++++---- source/text/sbasic/shared/03131700.xhp | 4 +- source/text/sbasic/shared/03131800.xhp | 4 +- source/text/sbasic/shared/03131900.xhp | 4 +- source/text/sbasic/shared/03132000.xhp | 63 ++++++++++------- source/text/sbasic/shared/03132100.xhp | 4 +- source/text/sbasic/shared/03132200.xhp | 22 +++--- source/text/sbasic/shared/03132300.xhp | 6 +- source/text/sbasic/shared/03132400.xhp | 23 +++--- 207 files changed, 2706 insertions(+), 1884 deletions(-) (limited to 'source') diff --git a/source/text/sbasic/shared/01020100.xhp b/source/text/sbasic/shared/01020100.xhp index 60fc9a17e7..c6cdd92fe5 100644 --- a/source/text/sbasic/shared/01020100.xhp +++ b/source/text/sbasic/shared/01020100.xhp @@ -59,7 +59,9 @@ -MyNumber=5 + +MyNumber=5 + Correct @@ -67,7 +69,9 @@ -MyNumber5=15 + +MyNumber5=15 + Correct @@ -75,7 +79,9 @@ -MyNumber_5=20 + +MyNumber_5=20 + Correct @@ -83,7 +89,9 @@ -My Number=20 + +My Number=20 + Not valid, variable with space must be enclosed in square brackets @@ -91,7 +99,9 @@ -[My Number]=12 + +[My Number]=12 + Correct @@ -99,7 +109,9 @@ -DéjàVu=25 + +DéjàVu=25 + Not valid, special characters are not allowed @@ -107,7 +119,9 @@ -5MyNumber=12 + +5MyNumber=12 + Not valid, variable may not begin with a number @@ -115,7 +129,9 @@ -Number,Mine=12 + +Number,Mine=12 + Not valid, punctuation marks are not allowed @@ -128,7 +144,9 @@
-DIM a$ + +Dim a$ + Declares the variable "a" as a String @@ -136,7 +154,9 @@ -DIM a As String + +Dim a As String + Declares the variable "a" as a String @@ -144,7 +164,9 @@ -DIM a$, b As Integer + +Dim a$, b As Integer + Declares one variable as a String and one as an Integer @@ -152,7 +174,9 @@ -DIM c As Boolean + +Dim c As Boolean + Declares c as a Boolean variable that can be TRUE or FALSE @@ -163,7 +187,9 @@
-DIM a$ + +Dim a$ + Declares "a" as a String @@ -171,7 +197,9 @@ -a="TestString" + +a="TestString" + Type-declaration missing: "a$=" @@ -181,7 +209,9 @@ Once you have declared a variable as a certain type, you cannot declare the variable under the same name again as a different type! Forcing Variable Declarations To force declaration of variables, use the following command: -OPTION EXPLICIT + +Option Explicit + The Option Explicit statement has to be the first line in the module, before the first SUB. Generally, only arrays need to be declared explicitly. All other variables are declared according to the type-declaration character, or - if omitted - as the default type Single. Variable Types $[officename] Basic supports four variable classes: @@ -205,37 +235,53 @@ Integer Variables Integer variables range from -32768 to 32767. If you assign a floating-point value to an integer variable, the decimal places are rounded to the next integer. Integer variables are rapidly calculated in procedures and are suitable for counter variables in loops. An integer variable only requires two bytes of memory. "%" is the type-declaration character. -Dim Variable% -Dim Variable As Integer + +Dim Variable% +Dim Variable As Integer + Long Integer Variables Long integer variables range from -2147483648 to 2147483647. If you assign a floating-point value to a long integer variable, the decimal places are rounded to the next integer. Long integer variables are rapidly calculated in procedures and are suitable for counter variables in loops for large values. A long integer variable requires four bytes of memory. "&" is the type-declaration character. -Dim Variable& -Dim Variable as Long + +Dim Variable& +Dim Variable As Long + Decimal Variablessee i64349 Decimal variables can take positive or negative numbers or zero. Accuracy is up to 29 digits.i85284You can use plus (+) or minus (-) signs as prefixes for decimal numbers (with or without spaces). If a decimal number is assigned to an integer variable, %PRODUCTNAME Basic rounds the figure up or down.information from "Programming Guide for BASIC" about decimal variables Single Variables Single variables can take positive or negative values ranging from 3.402823 x 10E38 to 1.401298 x 10E-45. Single variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Single variables are suitable for mathematical calculations of average precision. Calculations require more time than for Integer variables, but are faster than calculations with Double variables. A Single variable requires 4 bytes of memory. The type-declaration character is "!". -Dim Variable! -Dim Variable as Single + +Dim Variable! +Dim Variable As Single + Double Variables Double variables can take positive or negative values ranging from 1.79769313486232 x 10E308 to 4.94065645841247 x 10E-324. Double variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Double variables are suitable for precise calculations. Calculations require more time than for Single variables. A Double variable requires 8 bytes of memory. The type-declaration character is "#". -Dim Variable# -Dim Variable As Double + +Dim Variable# +Dim Variable As Double + Currency Variables Currency variables are internally stored as 64-bit numbers (8 Bytes) and displayed as a fixed-decimal number with 15 non-decimal and 4 decimal places. The values range from -922337203685477.5808 to +922337203685477.5807. Currency variables are used to calculate currency values with a high precision. The type-declaration character is "@". -Dim Variable@ -Dim Variable As Currency + +Dim Variable@ +Dim Variable As Currency + String Variables String variables can hold character strings with up to 65,535 characters. Each character is stored as the corresponding Unicode value. String variables are suitable for word processing within programs and for temporary storage of any non-printable character up to a maximum length of 64 Kbytes. The memory required for storing string variables depends on the number of characters in the variable. The type-declaration character is "$". -Dim Variable$ -Dim Variable As String + +Dim Variable$ +Dim Variable As String + Boolean Variables Boolean variables store only one of two values: TRUE or FALSE. A number 0 evaluates to FALSE, every other value evaluates to TRUE. -Dim Variable As Boolean + +Dim Variable As Boolean + Date Variables Date variables can only contain dates and time values stored in an internal format. Values assigned to Date variables with Dateserial, Datevalue, Timeserial or Timevalue are automatically converted to the internal format. Date-variables are converted to normal numbers by using the Day, Month, Year or the Hour, Minute, Second function. The internal format enables a comparison of date/time values by calculating the difference between two numbers. These variables can only be declared with the key word Date. -Dim Variable As Date + +Dim Variable As Date + Initial Variable Values As soon as the variable has been declared, it is automatically set to the "Null" value. Note the following conventions: @@ -250,7 +296,9 @@
-DIM text$(20) + +Dim Text$(20) + 21 elements numbered from 0 to 20 @@ -258,7 +306,9 @@ -DIM text$(5,4) + +Dim Text$(5,4) + 30 elements (a matrix of 6 x 5 elements) @@ -266,7 +316,9 @@ -DIM text$(5 to 25) + +Dim Text$(5 To 25) + 21 elements numbered from 5 to 25 @@ -274,7 +326,9 @@ -DIM text$(-15 to 5) + +Dim Text$(-15 To 5) + 21 elements (including 0), numbered from -15 to 5 @@ -284,6 +338,8 @@ The index range can include positive as well as negative numbers. i36558 Constants Constants have a fixed value. They are only defined once in the program and cannot be redefined later: -CONST ConstName=Expression + +Const ConstName=Expression + diff --git a/source/text/sbasic/shared/01020300.xhp b/source/text/sbasic/shared/01020300.xhp index e244cd4f98..739a1f0f1e 100644 --- a/source/text/sbasic/shared/01020300.xhp +++ b/source/text/sbasic/shared/01020300.xhp @@ -65,21 +65,27 @@ One benefit of procedures and functions is that, once you have developed a program code containing task components, you can use this code in another project. Passing Variables to Procedures (SUB) and Functions (FUNCTION) Variables can be passed to both procedures and functions. The SUB or FUNCTION must be declared to expect parameters: -SUB SubName(Parameter1 As Type, Parameter2 As Type,...) -Program code -END SUB + +Sub SubName(Parameter1 As Type, Parameter2 As Type,...) +Program code +End Sub + The SUB is called using the following syntax: -SubName(Value1, Value2,...) + +SubName(Value1, Value2,...) + The parameters passed to a SUB must fit to those specified in the SUB declaration. The same process applies to FUNCTIONS. In addition, functions always return a function result. The result of a function is defined by assigning the return value to the function name: -FUNCTION FunctionName(Parameter1 As Type, Parameter2 As Type,...) As Type -Program code - -FunctionName=Result - -End Function + +Function FunctionName(Parameter1 As Type, Parameter2 As Type,...) As Type +Program code +FunctionName=Result +End Function + The FUNCTION is called using the following syntax: -Variable=FunctionName(Parameter1, Parameter2,...) + +Variable=FunctionName(Parameter1, Parameter2,...) + You can also use the fully qualified name to call a procedure or function:
Library.Module.Macro()
For example, to call the Autotext macro from the Gimmicks library, use the following command:
@@ -88,41 +94,58 @@ Passing Variables by Value or Reference Parameters can be passed to a SUB or a FUNCTION either by reference or by value. Unless otherwise specified, a parameter is always passed by reference. That means that a SUB or a FUNCTION gets the parameter and can read and modify its value. If you want to pass a parameter by value insert the key word "ByVal" in front of the parameter when you call a SUB or FUNCTION, for example: -Result = Function(ByVal Parameter) + +Result = Function(ByVal Parameter) + In this case, the original content of the parameter will not be modified by the FUNCTION since it only gets the value and not the parameter itself. Scope of Variables A variable defined within a SUB or FUNCTION, only remains valid until the procedure is exited. This is known as a "local" variable. In many cases, you need a variable to be valid in all procedures, in every module of all libraries, or after a SUB or FUNCTION is exited. Declaring Variables Outside a SUB or FUNCTION -GLOBAL VarName As TYPENAME + +Global VarName As TYPENAME + The variable is valid as long as the $[officename] session lasts. -PUBLIC VarName As TYPENAME + +Public VarName As TYPENAME + The variable is valid in all modules. -PRIVATE VarName As TYPENAME + +Private VarName As TYPENAME + The variable is only valid in this module. -DIM VarName As TYPENAME + +Dim VarName As TYPENAME + The variable is only valid in this module. Example for private variables -Enforce private variables to be private across modules by setting CompatibilityMode(true).from i17948, see i54894REM ***** Module1 ***** -Private myText As String -Sub initMyText -myText = "Hello" -print "in module1 : ", myText -End Sub -REM ***** Module2 ***** -'Option Explicit -Sub demoBug -CompatibilityMode( true ) -initMyText -' Now returns empty string -' (or rises error for Option Explicit) -print "Now in module2 : ", myText -End Sub +Enforce private variables to be private across modules by setting CompatibilityMode(true).from i17948, see i54894 + +' ***** Module1 ***** +Private myText As String +Sub initMyText + myText = "Hello" + Print "In module1 : ", myText +End Sub + +' ***** Module2 ***** +'Option Explicit +Sub demoBug + CompatibilityMode( true ) + initMyText + ' Now returns empty string + ' (or rises error for Option Explicit) + Print "Now in module2 : ", myText +End Sub + Saving Variable Content after Exiting a SUB or FUNCTION -STATIC VarName As TYPENAME + +Static VarName As TYPENAME + The variable retains its value until the next time the FUNCTION or SUB is entered. The declaration must exist inside a SUB or a FUNCTION. Specifying the Return Value Type of a FUNCTION As with variables, include a type-declaration character after the function name, or the type indicated by "As" and the corresponding key word at the end of the parameter list to define the type of the function's return value, for example: -Function WordCount(WordText as String) as Integer - + +Function WordCount(WordText As String) As Integer + diff --git a/source/text/sbasic/shared/03010101.xhp b/source/text/sbasic/shared/03010101.xhp index ea55124c10..a636d98834 100644 --- a/source/text/sbasic/shared/03010101.xhp +++ b/source/text/sbasic/shared/03010101.xhp @@ -48,7 +48,9 @@ dedr: fixed #i30425# Displays a dialog box containing a message. Syntax: -MsgBox Text As String [,Type As Integer [,Dialogtitle As String]] (As Statement) or MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]]) (As Function) + +MsgBox Text As String [,Type As Integer [,Dialogtitle As String]] (As Statement) or MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]]) (As Function) + Parameter: Text: String expression displayed as a message in the dialog box. Line breaks can be inserted with Chr$(13). @@ -72,11 +74,13 @@ dedr: fixed #i30425# Example: -Sub ExampleMsgBox -Const sText1 = "An unexpected error occurred." -Const sText2 = "The program execution will continue, however." -Const sText3 = "Error" -MsgBox(sText1 + Chr(13) + sText2,16,sText3) -End sub + +Sub ExampleMsgBox + Const sText1 = "An unexpected error occurred." + Const sText2 = "The program execution will continue, however." + Const sText3 = "Error" + MsgBox(sText1 + Chr(13) + sText2,16,sText3) +End Sub + diff --git a/source/text/sbasic/shared/03010102.xhp b/source/text/sbasic/shared/03010102.xhp index 1fb2282ed9..788731edb4 100644 --- a/source/text/sbasic/shared/03010102.xhp +++ b/source/text/sbasic/shared/03010102.xhp @@ -47,7 +47,9 @@ Displays a dialog box containing a message and returns a value. Syntax: -MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]]) + +MsgBox (Text As String [,Type As Integer [,Dialogtitle As String]]) + Return value: Integer Parameter: @@ -86,11 +88,13 @@ Example: -Sub ExampleMsgBox -Dim sVar as Integer -sVar = MsgBox("Las Vegas") -sVar = MsgBox("Las Vegas",1) -sVar = MsgBox( "Las Vegas",256 + 16 + 2,"Dialog title") -end sub + +Sub ExampleMsgBox +Dim sVar As Integer + sVar = MsgBox("Las Vegas") + sVar = MsgBox("Las Vegas",1) + sVar = MsgBox( "Las Vegas",256 + 16 + 2,"Dialog title") +End Sub + diff --git a/source/text/sbasic/shared/03010103.xhp b/source/text/sbasic/shared/03010103.xhp index b8b33190e8..bea0ee22a9 100644 --- a/source/text/sbasic/shared/03010103.xhp +++ b/source/text/sbasic/shared/03010103.xhp @@ -47,7 +47,9 @@ Outputs the specified strings or numeric expressions to a dialog or to a file. Syntax: -Print [#FileName,] Expression1[{;|,} [Spc(Number As Integer);] [Tab(pos As Integer);] [Expression2[...]] + +Print [#FileName,] Expression1[{;|,} [Spc(Number As Integer);] [Tab(pos As Integer);] [Expression2[...]] + Parameter: FileName: Any numeric expression that contains the file number that was set by the Open statement for the respective file.see i61758 @@ -62,14 +64,15 @@ If the expression to be printed exceeds a certain length, the display will automatically wrap to the next line. You can insert the Tab function, enclosed by semicolons, between arguments to indent the output to a specific position, or you can use the Spc function to insert a specified number of spaces. Example: -Sub ExamplePrint -Print "ABC" -Print "ABC","123" -i = FreeFile() -Open "C:\Temp.txt" -"~/temp.txt" For Output As i -Print #i, "ABC" -Close #i -end Sub + +Sub ExamplePrint + Print "ABC" + Print "ABC","123" + i = FreeFile() + Open "C:\Temp.txt""~/temp.txt" For Output As i + Print #i, "ABC" + Close #i +End Sub + diff --git a/source/text/sbasic/shared/03010201.xhp b/source/text/sbasic/shared/03010201.xhp index 4444a852d6..863dfde4fb 100644 --- a/source/text/sbasic/shared/03010201.xhp +++ b/source/text/sbasic/shared/03010201.xhp @@ -48,7 +48,9 @@ The InputBox statement is a convenient method of entering text through a dialog. Confirm the input by clicking OK or pressing Return. The input is returned as the function return value. If you close the dialog with Cancel, InputBox returns a zero-length string (""). Syntax: -InputBox (Msg As String[, Title As String[, Default As String[, x_pos As Integer, y_pos As Integer]]]]) + +InputBox (Msg As String[, Title As String[, Default As String[, x_pos As Integer, y_pos As Integer]]]]) + Return value: String Parameter: @@ -64,10 +66,12 @@ y_pos: Integer expression that specifies the vertical position of the dialog. The position is an absolute coordinate and does not refer to the window of the office application.
If x_pos and y_pos are omitted, the dialog is centered on the screen. The position is specified in twips. Example: -Sub ExampleInputBox -Dim sText As String -sText = InputBox ("Please enter a phrase:","Dear User") -MsgBox ( sText , 64, "Confirmation of phrase") -End Sub + +Sub ExampleInputBox +Dim sText As String + sText = InputBox ("Please enter a phrase:","Dear User") + MsgBox ( sText , 64, "Confirmation of phrase") +End Sub + diff --git a/source/text/sbasic/shared/03010301.xhp b/source/text/sbasic/shared/03010301.xhp index cd47e2f444..fd664b9b68 100644 --- a/source/text/sbasic/shared/03010301.xhp +++ b/source/text/sbasic/shared/03010301.xhp @@ -47,7 +47,9 @@ Returns the blue component of the specified color code. Syntax: -Blue (Color As Long) + +Blue (Color As Long) + Return value: Integer Parameter: @@ -56,13 +58,15 @@ Example: -Sub ExampleColor -Dim lVar As Long -lVar = rgb(128,0,200) -MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ -"red= " & Red(lVar) & Chr(13)&_ -"green= " & Green(lVar) & Chr(13)&_ -"blue= " & Blue(lVar) & Chr(13) , 64,"colors" -End Sub + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & Red(lVar) & Chr(13)&_ + "green= " & Green(lVar) & Chr(13)&_ + "blue= " & Blue(lVar) & Chr(13) , 64,"colors" +End Sub + diff --git a/source/text/sbasic/shared/03010302.xhp b/source/text/sbasic/shared/03010302.xhp index 173a357f27..118d11d46f 100644 --- a/source/text/sbasic/shared/03010302.xhp +++ b/source/text/sbasic/shared/03010302.xhp @@ -47,7 +47,9 @@ Returns the Green component of the given color code. Syntax: -Green (Color As Long) + +Green (Color As Long) + Return value: Integer Parameter: @@ -56,13 +58,15 @@ Example: -Sub ExampleColor -Dim lVar As Long -lVar = rgb(128,0,200) -msgbox "The color " & lVar & " contains the components:" & Chr(13) &_ -"red = " & red(lVar) & Chr(13)&_ -"green = " & green(lVar) & Chr(13)&_ -"blue = " & blue(lVar) & Chr(13) , 64,"colors" -end sub + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " contains the components:" & Chr(13) &_ + "red = " & red(lVar) & Chr(13)&_ + "green = " & green(lVar) & Chr(13)&_ + "blue = " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + diff --git a/source/text/sbasic/shared/03010303.xhp b/source/text/sbasic/shared/03010303.xhp index b494ac3e87..b4c71f18ba 100644 --- a/source/text/sbasic/shared/03010303.xhp +++ b/source/text/sbasic/shared/03010303.xhp @@ -47,7 +47,9 @@ Returns the Red component of the specified color code. Syntax: -Red (ColorNumber As Long) + +Red (ColorNumber As Long) + Return value: Integer Parameter: @@ -56,13 +58,15 @@ Example: -Sub ExampleColor -Dim lVar As Long -lVar = rgb(128,0,200) -msgbox "The color " & lVar & " consists of:" & Chr(13) &_ -"red= " & red(lVar) & Chr(13)&_ -"green= " & green(lVar) & Chr(13)&_ -"blue= " & blue(lVar) & Chr(13) , 64,"colors" -end sub + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & red(lVar) & Chr(13)&_ + "green= " & green(lVar) & Chr(13)&_ + "blue= " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + diff --git a/source/text/sbasic/shared/03010304.xhp b/source/text/sbasic/shared/03010304.xhp index 92eaedf6fc..74aff384dd 100644 --- a/source/text/sbasic/shared/03010304.xhp +++ b/source/text/sbasic/shared/03010304.xhp @@ -45,7 +45,9 @@ Returns the RGB color code of the color passed as a color value through an older MS-DOS based programming system. Syntax: -QBColor (ColorNumber As Integer) + +QBColor (ColorNumber As Integer) + Return value: Long Parameter: @@ -73,12 +75,14 @@ Example: -Sub ExampleQBColor -Dim iColor As Integer -Dim sText As String -iColor = 7 -sText = "RGB= " & Red(QBColor( iColor) ) & ":" & Blue(QBColor( iColor) ) & ":" & Green(QBColor( iColor) ) -MsgBox stext,0,"Color " & iColor -End Sub + +Sub ExampleQBColor +Dim iColor As Integer +Dim sText As String + iColor = 7 + sText = "RGB= " & Red(QBColor( iColor) ) & ":" & Blue(QBColor( iColor) ) & ":" & Green(QBColor( iColor) ) + MsgBox stext,0,"Color " & iColor +End Sub + diff --git a/source/text/sbasic/shared/03010305.xhp b/source/text/sbasic/shared/03010305.xhp index 32d8275ad9..7792006c2d 100644 --- a/source/text/sbasic/shared/03010305.xhp +++ b/source/text/sbasic/shared/03010305.xhp @@ -45,7 +45,9 @@ Returns a long integer color value consisting of red, green, and blue components. Syntax: -RGB (Red, Green, Blue) + +RGB (Red, Green, Blue) + Return value: Long Parameter: @@ -58,13 +60,15 @@ Example: -Sub ExampleColor -Dim lVar As Long -lVar = rgb(128,0,200) -msgbox "The color " & lVar & " consists of:" & Chr(13) &_ -"red= " & red(lVar) & Chr(13)&_ -"green= " & green(lVar) & Chr(13)&_ -"blue= " & blue(lVar) & Chr(13) , 64,"colors" -end sub + +Sub ExampleColor +Dim lVar As Long + lVar = rgb(128,0,200) + MsgBox "The color " & lVar & " consists of:" & Chr(13) &_ + "red= " & red(lVar) & Chr(13)&_ + "green= " & green(lVar) & Chr(13)&_ + "blue= " & blue(lVar) & Chr(13) , 64,"colors" +End Sub + diff --git a/source/text/sbasic/shared/03020101.xhp b/source/text/sbasic/shared/03020101.xhp index 90ea0073a8..a76d57eb45 100644 --- a/source/text/sbasic/shared/03020101.xhp +++ b/source/text/sbasic/shared/03020101.xhp @@ -47,33 +47,37 @@ Closes a specified file that was opened with the Open statement. Syntax: -Close FileNumber As Integer[, FileNumber2 As Integer[,...]] + +Close FileNumber As Integer[, FileNumber2 As Integer[,...]] + Parameters: FileNumber: 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 + +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 + diff --git a/source/text/sbasic/shared/03020102.xhp b/source/text/sbasic/shared/03020102.xhp index 24a5371b44..1b852bd4a1 100644 --- a/source/text/sbasic/shared/03020102.xhp +++ b/source/text/sbasic/shared/03020102.xhp @@ -47,7 +47,9 @@ Returns the next available file number for opening a file. Use this function to open a file using a file number that is not already in use by a currently open file. Syntax: -FreeFile + +FreeFile + Return value: Integer Parameters: @@ -56,28 +58,30 @@ 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 + +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 + diff --git a/source/text/sbasic/shared/03020103.xhp b/source/text/sbasic/shared/03020103.xhp index f2cc3251b0..56e7fc7f2f 100644 --- a/source/text/sbasic/shared/03020103.xhp +++ b/source/text/sbasic/shared/03020103.xhp @@ -49,7 +49,9 @@ Opens a data channel. Syntax: -Open FileName As String [For Mode] [Access IOMode] [Protected] As [#]FileNumber As Integer [Len = DatasetLength]i37502 + +Open FileName As String [For Mode] [Access IOMode] [Protected] As [#]FileNumber As Integer [Len = DatasetLength]i37502 + Parameters: FileName: Name and path of the file that you wan 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. @@ -65,27 +67,29 @@ DatasetLength: 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. Example: -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 + +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 + diff --git a/source/text/sbasic/shared/03020104.xhp b/source/text/sbasic/shared/03020104.xhp index 3148bd7837..3c4a27bcec 100644 --- a/source/text/sbasic/shared/03020104.xhp +++ b/source/text/sbasic/shared/03020104.xhp @@ -47,32 +47,36 @@ Closes all open files and writes the contents of all file buffers to the harddisk. Syntax: -Reset + +Reset + Example: -Sub ExampleReset -On Error Goto ErrorHandler -Dim iNumber As Integer -Dim iCount As Integer -Dim sLine As String -Dim aFile As String -aFile = "c:\data.txt" -iNumber = Freefile -Open aFile For Output As #iNumber -Print #iNumber, "This is a new line of text" -Close #iNumber -iNumber = Freefile -Open aFile For Input As iNumber -For iCount = 1 to 5 -Line Input #iNumber, sLine -If sLine <>"" then -rem -end if -Next iCount -Close #iNumber -Exit Sub -ErrorHandler: -Reset -MsgBox "All files will be closed",0,"Error" -End Sub + +Sub ExampleReset +On Error GoTo ErrorHandler +Dim iNumber As Integer +Dim iCount As Integer +Dim sLine As String +Dim aFile As String + aFile = "c:\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a new line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + For iCount = 1 To 5 + Line Input #iNumber, sLine + If sLine <>"" Then + Rem + End If + Next iCount + Close #iNumber + Exit Sub +ErrorHandler: + Reset + MsgBox "All files will be closed",0,"Error" +End Sub + diff --git a/source/text/sbasic/shared/03020201.xhp b/source/text/sbasic/shared/03020201.xhp index abdadef468..b7e88580b3 100644 --- a/source/text/sbasic/shared/03020201.xhp +++ b/source/text/sbasic/shared/03020201.xhp @@ -48,7 +48,9 @@ See also: PUT Statement Syntax: -Get [#] FileNumber As Integer, [Position], Variable + +Get [#] FileNumber As Integer, [Position], Variable + Parameters: FileNumber: Any integer expression that determines the file number. @@ -58,30 +60,32 @@ 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. Example: -Sub ExampleRandomAccess -Dim iNumber As Integer -Dim sText As Variant REM 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 REM Position at beginning -Put #iNumber,, "This is the first line of text" REM 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 a 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 + +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 + Put #iNumber,,"This is a 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 + diff --git a/source/text/sbasic/shared/03020202.xhp b/source/text/sbasic/shared/03020202.xhp index 7f8f5c70db..e8f9cec78d 100644 --- a/source/text/sbasic/shared/03020202.xhp +++ b/source/text/sbasic/shared/03020202.xhp @@ -65,13 +65,13 @@ Dim iCount As Integer Dim sName As String Dim sValue As Integer -Dim sFileName as String +Dim sFileName As String sFileName = "c:\data.txt" iCount = Freefile ' Write data ( which we will read later with Input ) to file -Open sFileName for OutPut as iCount +Open sFileName For Output As iCount sName = "Hamburg" sValue = 200 Write #iCount, sName, sValue @@ -85,13 +85,13 @@ iCount = Freefile ' Read data file using Input -Open sFileName for Input as iCount +Open sFileName For Input As iCount Input #iCount; sName, sValue -Msgbox sName & " " & sValue +MsgBox sName & " " & sValue Input #iCount; sName, sValue -Msgbox sName & " " & sValue +MsgBox sName & " " & sValue Input #iCount; sName, sValue -Msgbox sName & " " & sValue +MsgBox sName & " " & sValue Close #iCount End Sub diff --git a/source/text/sbasic/shared/03020203.xhp b/source/text/sbasic/shared/03020203.xhp index 8c2c1cb127..2e65468e2b 100644 --- a/source/text/sbasic/shared/03020203.xhp +++ b/source/text/sbasic/shared/03020203.xhp @@ -49,7 +49,9 @@ Reads strings from a sequential file into a variable. Syntax: -Line Input #FileNumber As Integer, Var As String + +Line Input #FileNumber As Integer, Var As String + Parameters: FileNumber: Number of the file that contains the data that you want to read. The file must have been opened in advance with the Open statement using the key word INPUT. @@ -57,27 +59,29 @@ var: The name of the variable that stores the result. With the Line Input# statement, you can read strings from an open file into a variable. String variables are read line-by-line up to the first carriage return (Asc=13) or linefeed (Asc=10). Line end marks are not included in the resulting string. Example: -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 + +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 + diff --git a/source/text/sbasic/shared/03020204.xhp b/source/text/sbasic/shared/03020204.xhp index 6abfac8191..26abb1bbd1 100644 --- a/source/text/sbasic/shared/03020204.xhp +++ b/source/text/sbasic/shared/03020204.xhp @@ -48,7 +48,9 @@ See also: Get statement Syntax: -Put [#] FileNumber As Integer, [position], Variable + +Put [#] FileNumber As Integer, [position], Variable + Parameters: FileNumber: Any integer expression that defines the file that you want to write to. @@ -60,30 +62,32 @@ 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 REM 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 REM Position to start writing -Put #iNumber,, "This is the first line of text" REM 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 + +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 + diff --git a/source/text/sbasic/shared/03020205.xhp b/source/text/sbasic/shared/03020205.xhp index e211faa331..1c2c3725f0 100644 --- a/source/text/sbasic/shared/03020205.xhp +++ b/source/text/sbasic/shared/03020205.xhp @@ -49,7 +49,9 @@ Writes data to a sequential file. Syntax: -Write [#FileName], [Expressionlist]see i61248 + +Write [#FileName], [Expressionlist]see i61248 + Parameters: FileName: Any numeric expression that contains the file number that was set by the Open statement for the respective file. @@ -61,18 +63,20 @@ Each Write statement outputs a line end symbol as last entry. Numbers with decimal delimiters are converted according to the locale settings. Example: -Sub ExampleWrite -Dim iCount As Integer -Dim sValue As String -iCount = Freefile -open "C:\data.txt" for OutPut as iCount -sValue = "Hamburg" -Write #iCount,sValue,200 -sValue = "New York" -Write #iCount,sValue,300 -sValue = "Miami" -Write #iCount,sValue,450 -close #iCount -end sub + +Sub ExampleWrite +Dim iCount As Integer +Dim sValue As String + iCount = Freefile + Open "C:\data.txt" For Output As iCount + sValue = "Hamburg" + Write #iCount,sValue,200 + sValue = "New York" + Write #iCount,sValue,300 + sValue = "Miami" + Write #iCount,sValue,450 + Close #iCount +End Sub + diff --git a/source/text/sbasic/shared/03020301.xhp b/source/text/sbasic/shared/03020301.xhp index 7d688e8709..ea122bc8f5 100644 --- a/source/text/sbasic/shared/03020301.xhp +++ b/source/text/sbasic/shared/03020301.xhp @@ -47,7 +47,9 @@ Determines if the file pointer has reached the end of a file. Syntax: -Eof (intexpression As Integer) + +Eof (intexpression As Integer) + Return value: Bool Parameters: @@ -58,27 +60,29 @@ Example: -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, "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 + +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, "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 + diff --git a/source/text/sbasic/shared/03020302.xhp b/source/text/sbasic/shared/03020302.xhp index ab52b90844..1914e85e41 100644 --- a/source/text/sbasic/shared/03020302.xhp +++ b/source/text/sbasic/shared/03020302.xhp @@ -47,7 +47,9 @@ Returns the current position in an open file. Syntax: -Loc(FileNumber) + +Loc(FileNumber) + Return value: Long Parameters: diff --git a/source/text/sbasic/shared/03020304.xhp b/source/text/sbasic/shared/03020304.xhp index bdf472dc56..a1d2905deb 100644 --- a/source/text/sbasic/shared/03020304.xhp +++ b/source/text/sbasic/shared/03020304.xhp @@ -52,7 +52,9 @@ For all other files, the function returns the byte position at which the next operation is to occur. See also: Open, Seek. Syntax: -Seek (FileNumber) + +Seek (FileNumber) + Return value: Long Parameters: diff --git a/source/text/sbasic/shared/03020305.xhp b/source/text/sbasic/shared/03020305.xhp index e7a3b7f9db..2aa79535a3 100644 --- a/source/text/sbasic/shared/03020305.xhp +++ b/source/text/sbasic/shared/03020305.xhp @@ -50,7 +50,9 @@ For all other files, the Seek statement sets the byte position at which the next operation is to occur. See also: Open, Seek. Syntax: -Seek[#FileNumber], Position (As Long) + +Seek[#FileNumber], Position (As Long) + Parameters: FileNumber: The data channel number used in the Open statement. diff --git a/source/text/sbasic/shared/03020401.xhp b/source/text/sbasic/shared/03020401.xhp index 6ea00b311a..bd5be6ea17 100644 --- a/source/text/sbasic/shared/03020401.xhp +++ b/source/text/sbasic/shared/03020401.xhp @@ -52,7 +52,9 @@ This runtime statement currently does not work as documented. See this issue for more information. Syntax: -ChDir Text As String + +ChDir Text As String + Parameters: Text: Any string expression that specifies the directory path or drive. @@ -61,14 +63,16 @@ Example: -Sub ExampleChDir -Dim sDir1 as String , sDir2 as String -sDir1 = "c:\Test" -sDir2 = "d:\private" -ChDir( sDir1 ) -msgbox CurDir -ChDir( sDir2 ) -msgbox CurDir -end sub + +Sub ExampleChDir +Dim sDir1 As String , sDir2 As String + sDir1 = "c:\Test" + sDir2 = "d:\Private" + ChDir( sDir1 ) + MsgBox CurDir + ChDir( sDir2 ) + MsgBox CurDir +End Sub + diff --git a/source/text/sbasic/shared/03020402.xhp b/source/text/sbasic/shared/03020402.xhp index bdf367d13b..265a09bd97 100644 --- a/source/text/sbasic/shared/03020402.xhp +++ b/source/text/sbasic/shared/03020402.xhp @@ -50,7 +50,9 @@ Syntax: -ChDrive Text As String + +ChDrive Text As String + Parameters: Text: Any string expression that contains the drive letter of the new drive. If you want, you can use URL notation. @@ -60,8 +62,10 @@ Example: -Sub ExampleCHDrive -ChDrive "D" REM Only possible if a drive 'D' exists. -End Sub + +Sub ExampleChDrive + ChDrive "D" ' Only possible if a drive 'D' exists. +End Sub + diff --git a/source/text/sbasic/shared/03020403.xhp b/source/text/sbasic/shared/03020403.xhp index 7fc3aba96d..2aef3f180e 100644 --- a/source/text/sbasic/shared/03020403.xhp +++ b/source/text/sbasic/shared/03020403.xhp @@ -50,7 +50,9 @@ Syntax: -CurDir [(Text As String)] + +CurDir [(Text As String)] + Return value: String Parameters: @@ -64,14 +66,16 @@ Example: -Sub ExampleCurDir -Dim sDir1 as String , sDir2 as String -sDir1 = "c:\Test" -sDir2 = "d:\private" -ChDir( sDir1 ) -msgbox CurDir -ChDir( sDir2 ) -msgbox CurDir -end sub + +Sub ExampleCurDir +Dim sDir1 As String , sDir2 As String + sDir1 = "c:\Test" + sDir2 = "d:\Private" + ChDir( sDir1 ) + MsgBox CurDir + ChDir( sDir2 ) + MsgBox CurDir +End Sub + diff --git a/source/text/sbasic/shared/03020404.xhp b/source/text/sbasic/shared/03020404.xhp index 1039e79afa..c1a7eefd50 100644 --- a/source/text/sbasic/shared/03020404.xhp +++ b/source/text/sbasic/shared/03020404.xhp @@ -47,7 +47,9 @@ Returns the name of a file, a directory, or all of the files and the directories on a drive or in a directory that match the specified search path. Syntax: -Dir [(Text As String) [, Attrib As Integer]] + +Dir [(Text As String) [, Attrib As Integer]] + Return value: String Parameters: @@ -65,23 +67,25 @@ Example: -Sub ExampleDir -REM Displays all files and directories -Dim sPath As String -Dim sDir as String, sValue as String -sDir="Directories:" -sPath = CurDir -sValue = Dir$(sPath + getPathSeparator + "*",16) -Do -If sValue <> "." and sValue <> ".." Then -if (GetAttr( sPath + getPathSeparator + sValue) AND 16) >0 then -REM get the directories -sDir = sDir & chr(13) & sValue -End If -End If -sValue = Dir$ -Loop Until sValue = "" -MsgBox sDir,0,sPath -End sub + +Sub ExampleDir +' Displays all files and directories +Dim sPath As String +Dim sDir As String, sValue As String + sDir="Directories:" + sPath = CurDir + sValue = Dir$(sPath + getPathSeparator + "*",16) + Do + If sValue <> "." And sValue <> ".." Then + If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then + ' Get the directories + sDir = sDir & chr(13) & sValue + End If + End If + sValue = Dir$ + Loop Until sValue = "" + MsgBox sDir,0,sPath +End Sub + diff --git a/source/text/sbasic/shared/03020405.xhp b/source/text/sbasic/shared/03020405.xhp index 29c37a8d63..f38a3ddcbf 100644 --- a/source/text/sbasic/shared/03020405.xhp +++ b/source/text/sbasic/shared/03020405.xhp @@ -49,7 +49,9 @@ If you use a 32-Bit operating system, you cannot use the FileAttr-Function to determine the file access number. See also: Open Syntax: -FileAttr (FileNumber As Integer, Attribute As Integer) + +FileAttr (FileNumber As Integer, Attribute As Integer) + Return value: Integer Parameters: @@ -69,17 +71,19 @@ Example: -Sub ExampleFileAttr -Dim iNumber As Integer -Dim sLine As String -Dim aFile As String -aFile = "c:\data.txt" -iNumber = Freefile -Open aFile For Output As #iNumber -Print #iNumber, "This is a line of text" -MsgBox FileAttr(#iNumber, 1 ),0,"Access mode" -MsgBox FileAttr(#iNumber, 2 ),0,"File attribute" -Close #iNumber -End Sub + +Sub ExampleFileAttr +Dim iNumber As Integer +Dim sLine As String +Dim aFile As String + aFile = "c:\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + MsgBox FileAttr(#iNumber, 1 ),0,"Access mode" + MsgBox FileAttr(#iNumber, 2 ),0,"File attribute" + Close #iNumber +End Sub + diff --git a/source/text/sbasic/shared/03020406.xhp b/source/text/sbasic/shared/03020406.xhp index 19ff88ae19..65b5ac6805 100644 --- a/source/text/sbasic/shared/03020406.xhp +++ b/source/text/sbasic/shared/03020406.xhp @@ -47,7 +47,9 @@ Copies a file. Syntax: -FileCopy TextFrom As String, TextTo As String + +FileCopy TextFrom As String, TextTo As String + Parameters: TextFrom: Any string expression that specifies the name of the file that you want to copy. The expression can contain optional path and drive information. If you want, you can enter a path in URL notation. @@ -58,8 +60,10 @@ Example: -Sub ExampleFilecopy -Filecopy "c:\autoexec.bat", "c:\Temp\Autoexec.sav" -end sub + +Sub ExampleFileCopy + FileCopy "c:\autoexec.bat", "c:\Temp\Autoexec.sav" +End Sub + diff --git a/source/text/sbasic/shared/03020407.xhp b/source/text/sbasic/shared/03020407.xhp index 24ae04ddd5..338d1480f6 100644 --- a/source/text/sbasic/shared/03020407.xhp +++ b/source/text/sbasic/shared/03020407.xhp @@ -47,7 +47,9 @@ Returns a string that contains the date and the time that a file was created or last modified. Syntax: -FileDateTime (Text As String) + +FileDateTime (Text As String) + Parameters: Text: Any string expression that contains an unambiguous (no wildcards) file specification. You can also use URL notation. @@ -56,8 +58,10 @@ Example: -Sub ExampleFileDateTime -msgbox FileDateTime("C:\autoexec.bat") -end sub + +Sub ExampleFileDateTime + MsgBox FileDateTime("C:\autoexec.bat") +End Sub + diff --git a/source/text/sbasic/shared/03020408.xhp b/source/text/sbasic/shared/03020408.xhp index ca2e86c9b9..8e37f4c7cf 100644 --- a/source/text/sbasic/shared/03020408.xhp +++ b/source/text/sbasic/shared/03020408.xhp @@ -47,7 +47,9 @@ Returns the length of a file in bytes. Syntax: -FileLen (Text As String) + +FileLen (Text As String) + Return value: Long Parameters: @@ -57,8 +59,10 @@ Example: -Sub ExampleFileLen -msgbox FileLen("C:\autoexec.bat") -end sub + +Sub ExampleFileLen + MsgBox FileLen("C:\autoexec.bat") +End Sub + diff --git a/source/text/sbasic/shared/03020409.xhp b/source/text/sbasic/shared/03020409.xhp index 4c2a38bbfc..39b6eeb5fb 100644 --- a/source/text/sbasic/shared/03020409.xhp +++ b/source/text/sbasic/shared/03020409.xhp @@ -47,7 +47,9 @@ Returns a bit pattern that identifies the file type or the name of a volume or a directory. Syntax: -GetAttr (Text As String) + +GetAttr (Text As String) + Return value: Integer Parameters: @@ -65,18 +67,20 @@ 32 : File was changed since last backup (Archive bit). If you want to know if a bit of the attribute byte is set, use the following query method: Example: -Sub ExampleSetGetAttr -On Error Goto ErrorHandler REM Define target for error-handler -If Dir("C:\test",16)="" Then MkDir "C:\test" -If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav" -SetAttr "c:\test\autoexec.sav" ,0 -Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav" -SetAttr "c:\test\autoexec.sav" ,1 -print GetAttr( "c:\test\autoexec.sav" ) -end -ErrorHandler: -Print Error -end -end sub + +Sub ExampleSetGetAttr +On Error GoTo ErrorHandler ' Define target for error handler + If Dir("C:\test",16)="" Then MkDir "C:\test" + If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,0 + FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,1 + Print GetAttr( "c:\test\autoexec.sav" ) + End +ErrorHandler: + Print Error + End +End Sub + diff --git a/source/text/sbasic/shared/03020410.xhp b/source/text/sbasic/shared/03020410.xhp index 8d135b15fc..2d933aff92 100644 --- a/source/text/sbasic/shared/03020410.xhp +++ b/source/text/sbasic/shared/03020410.xhp @@ -47,7 +47,9 @@ Deletes a file from a disk. Syntax: -Kill File As String + +Kill File As String + Parameters: File: Any string expression that contains an unambiguous file specification. You can also use URL notation. @@ -55,8 +57,10 @@ Example: -sub ExampleKill -Kill "C:\datafile.dat" REM File must be created in advance -end sub + +Sub ExampleKill + Kill "C:\datafile.dat" ' File must be created in advance +End Sub + diff --git a/source/text/sbasic/shared/03020411.xhp b/source/text/sbasic/shared/03020411.xhp index 0b44caf346..86abd50ad5 100644 --- a/source/text/sbasic/shared/03020411.xhp +++ b/source/text/sbasic/shared/03020411.xhp @@ -47,7 +47,9 @@ Creates a new directory on a data medium. Syntax: -MkDir Text As String + +MkDir Text As String + Parameters: Text: Any string expression that specifies the name and path of the directory to be created. You can also use URL notation. @@ -56,47 +58,50 @@ Example: -Sub ExampleFileIO -' Example for functions of the file organization -Const sFile1 as String = "file://c|/autoexec.bat" -Const sDir1 as String = "file://c|/Temp" -Const sSubDir1 as String ="Test" -Const sFile2 as String = "Copied.tmp" -Const sFile3 as String = "Renamed.tmp" -Dim sFile as String -sFile = sDir1 + "/" + sSubDir1 -ChDir( sDir1 ) -If Dir(sSubDir1,16)="" then ' Does the directory exist ? -MkDir sSubDir1 -MsgBox sFile,0,"Create directory" -End If -sFile = sFile + "/" + sFile2 -FileCopy sFile1 , sFile -MsgBox fSysURL(CurDir()),0,"Current directory" -MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time" -MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length" -MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes" -Name sFile as sDir1 + "/" + sSubDir1 + "/" + sFile3 -' Rename in the same directory -sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3 -SetAttr( sFile, 0 ) 'Delete all attributes -MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes" -Kill sFile -RmDir sDir1 + "/" + sSubDir1 -end sub -' Converts a system path in URL -Function fSysURL( fSysFp as String ) as String -Dim iPos As String -iPos = 1 -iPos = Instr(iPos,fSysFp, getPathSeparator()) -do while iPos > 0 -mid( fSysFp, iPos , 1,"/") -iPos = Instr(iPos+1,fSysFp, getPathSeparator()) -loop -' the colon with DOS -iPos = Instr(1,fSysFp,":") -if iPos > 0 then mid( fSysFp, iPos , 1,"|") -fSysURL = "file://" & fSysFp -End Function + +Sub ExampleFileIO +' Example for functions of the file organization +Const sFile1 As String = "file://c|/autoexec.bat" +Const sDir1 As String = "file://c|/Temp" +Const sSubDir1 As String ="Test" +Const sFile2 As String = "Copied.tmp" +Const sFile3 As String = "Renamed.tmp" +Dim sFile As String + sFile = sDir1 + "/" + sSubDir1 + ChDir( sDir1 ) + If Dir(sSubDir1,16)="" Then ' Does the directory exist? + MkDir sSubDir1 + MsgBox sFile,0,"Create directory" + End If + sFile = sFile + "/" + sFile2 + FileCopy sFile1 , sFile + MsgBox fSysURL(CurDir()),0,"Current directory" + MsgBox sFile & Chr(13) & FileDateTime( sFile ),0,"Creation time" + MsgBox sFile & Chr(13)& FileLen( sFile ),0,"File length" + MsgBox sFile & Chr(13)& GetAttr( sFile ),0,"File attributes" + Name sFile As sDir1 + "/" + sSubDir1 + "/" + sFile3 + ' Rename in the same directory + sFile = sDir1 + "/" + sSubDir1 + "/" + sFile3 + SetAttr( sFile, 0 ) 'Delete all attributes + MsgBox sFile & Chr(13) & GetAttr( sFile ),0,"New file attributes" + Kill sFile + RmDir sDir1 + "/" + sSubDir1 +End Sub + +' Converts a system path in URL +Function fSysURL( fSysFp As String ) As String +Dim iPos As String + iPos = 1 + iPos = Instr(iPos,fSysFp, getPathSeparator()) + Do While iPos > 0 + Mid( fSysFp, iPos , 1,"/") + iPos = Instr(iPos+1,fSysFp, getPathSeparator()) + Loop + ' the colon with DOS + iPos = Instr(1,fSysFp,":") + If iPos > 0 Then Mid( fSysFp, iPos , 1,"|") + fSysURL = "file://" & fSysFp +End Function + diff --git a/source/text/sbasic/shared/03020412.xhp b/source/text/sbasic/shared/03020412.xhp index de02a33586..22042f9e11 100644 --- a/source/text/sbasic/shared/03020412.xhp +++ b/source/text/sbasic/shared/03020412.xhp @@ -49,21 +49,25 @@ Renames an existing file or directory. Syntax: -Name OldName As String As NewName As String + +Name OldName As String As NewName As String + Parameters: OldName, NewName: Any string expression that specifies the file name, including the path. You can also use URL notation.see #i61074 Example: -Sub ExampleReName -On Error Goto Error -Filecopy "c:\autoexec.bat", "c:\temp\autoexec.sav" -Name "c:\temp\autoexec.sav" as "c:\temp\autoexec.bat" -end -Error: -if err = 58 then -msgbox "File already exists" -end if -end -end sub + +Sub ExampleReName +On Error GoTo Error +FileCopy "c:\autoexec.bat", "c:\temp\autoexec.sav" +Name "c:\temp\autoexec.sav" As "c:\temp\autoexec.bat" +End +Error: +If err = 58 Then + MsgBox "File already exists" +End If +End +End Sub + diff --git a/source/text/sbasic/shared/03020413.xhp b/source/text/sbasic/shared/03020413.xhp index 9dbb1e0425..9a8aa9b384 100644 --- a/source/text/sbasic/shared/03020413.xhp +++ b/source/text/sbasic/shared/03020413.xhp @@ -47,7 +47,9 @@ Deletes an existing directory from a data medium. Syntax: -RmDir Text As String + +RmDir Text As String + Parameters: Text: Any string expression that specifies the name and path of the directory that you want to delete. You can also use URL notation. @@ -56,12 +58,14 @@ Example: -Sub ExampleRmDir -MkDir "C:\Test2" -ChDir "C:\test2" -msgbox Curdir -ChDir "\" -RmDir "C:\test2" -end sub + +Sub ExampleRmDir + MkDir "C:\Test2" + ChDir "C:\test2" + MsgBox Curdir + ChDir "\" + RmDir "C:\test2" +End Sub + diff --git a/source/text/sbasic/shared/03020414.xhp b/source/text/sbasic/shared/03020414.xhp index a2dbedb627..c4ab79a9d8 100644 --- a/source/text/sbasic/shared/03020414.xhp +++ b/source/text/sbasic/shared/03020414.xhp @@ -47,7 +47,9 @@ Sets the attribute information for a specified file. Syntax: -SetAttr FileName As String, Attribute As Integer + +SetAttr FileName As String, Attribute As Integer + Parameters: FileName: Name of the file, including the path, that you want to test attributes of. If you do not enter a path, SetAttr searches for the file in the current directory. You can also use URL notation. @@ -64,18 +66,20 @@ Example: -Sub ExampleSetGetAttr -On Error Goto ErrorHandler REM Define target for error-handler -If Dir("C:\test",16)="" Then MkDir "C:\test" -If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav" -SetAttr "c:\test\autoexec.sav" ,0 -Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav" -SetAttr "c:\test\autoexec.sav" ,1 -print GetAttr( "c:\test\autoexec.sav" ) -end -ErrorHandler: -Print Error -end -end sub + +Sub ExampleSetGetAttr + On Error GoTo ErrorHandler ' Define target for error handler + If Dir("C:\test",16)="" Then MkDir "C:\test" + If Dir("C:\test\autoexec.sav")="" Then FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,0 + FileCopy "c:\autoexec.bat", "c:\test\autoexec.sav" + SetAttr "c:\test\autoexec.sav" ,1 + Print GetAttr( "c:\test\autoexec.sav" ) + End +ErrorHandler: + Print Error + End +End Sub + diff --git a/source/text/sbasic/shared/03020415.xhp b/source/text/sbasic/shared/03020415.xhp index 4b1e4fd9c2..5fcef7adbf 100644 --- a/source/text/sbasic/shared/03020415.xhp +++ b/source/text/sbasic/shared/03020415.xhp @@ -47,7 +47,9 @@ Determines if a file or a directory is available on the data medium. Syntax: -FileExists(FileName As String | DirectoryName As String) + +FileExists(FileName As String | DirectoryName As String) + Return value: Bool Parameters: @@ -55,10 +57,12 @@ Example: -sub ExampleFileExists -msgbox FileExists("C:\autoexec.bat") -msgbox FileExists("file:///d|/bookmark.htm") -msgbox FileExists("file:///d|/private") -end sub + +Sub ExampleFileExists + MsgBox FileExists("C:\autoexec.bat") + MsgBox FileExists("file:///d|/bookmark.htm") + MsgBox FileExists("file:///d|/Private") +End Sub + diff --git a/source/text/sbasic/shared/03030101.xhp b/source/text/sbasic/shared/03030101.xhp index c088a10fb6..b0b850cd49 100644 --- a/source/text/sbasic/shared/03030101.xhp +++ b/source/text/sbasic/shared/03030101.xhp @@ -49,7 +49,9 @@ Returns a Date value for a specified year, month, or day. Syntax: -DateSerial (year, month, day) + +DateSerial (year, month, day) + Return value: Date Parameters: diff --git a/source/text/sbasic/shared/03030102.xhp b/source/text/sbasic/shared/03030102.xhp index 78b8e8e555..743860412c 100644 --- a/source/text/sbasic/shared/03030102.xhp +++ b/source/text/sbasic/shared/03030102.xhp @@ -49,7 +49,9 @@ Returns a date value from a date string. The date string is a complete date in a single numeric value. You can also use this serial number to determine the difference between two dates. Syntax: -DateValue [(date)] + +DateValue [(date)] + Return value: Datei66764 Parameters: diff --git a/source/text/sbasic/shared/03030103.xhp b/source/text/sbasic/shared/03030103.xhp index 38c735eedf..2a537ad2fd 100644 --- a/source/text/sbasic/shared/03030103.xhp +++ b/source/text/sbasic/shared/03030103.xhp @@ -47,7 +47,9 @@ Returns a value that represents the day of the month based on a serial date number generated by DateSerial or DateValue. Syntax: -Day (Number) + +Day (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030104.xhp b/source/text/sbasic/shared/03030104.xhp index 6addc46728..f29266df6a 100644 --- a/source/text/sbasic/shared/03030104.xhp +++ b/source/text/sbasic/shared/03030104.xhp @@ -47,7 +47,9 @@ Returns the month of a year from a serial date that is generated by the DateSerial or the DateValue function. Syntax: -Month (Number) + +Month (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030105.xhp b/source/text/sbasic/shared/03030105.xhp index 10245b3444..c7c65c05e4 100644 --- a/source/text/sbasic/shared/03030105.xhp +++ b/source/text/sbasic/shared/03030105.xhp @@ -47,7 +47,9 @@ Returns the number corresponding to the weekday represented by a serial date number that is generated by the DateSerial or the DateValue function. Syntax: -WeekDay (Number) + +WeekDay (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030106.xhp b/source/text/sbasic/shared/03030106.xhp index 544c63fdf2..0b452e30b7 100644 --- a/source/text/sbasic/shared/03030106.xhp +++ b/source/text/sbasic/shared/03030106.xhp @@ -47,7 +47,9 @@ Returns the year from a serial date number that is generated by the DateSerial or the DateValue function. Syntax: -Year (Number) + +Year (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030107.xhp b/source/text/sbasic/shared/03030107.xhp index 4ea3d4dd1c..ed4a199256 100644 --- a/source/text/sbasic/shared/03030107.xhp +++ b/source/text/sbasic/shared/03030107.xhp @@ -47,7 +47,9 @@ Returns the date in ISO format from a serial date number that is generated by the DateSerial or the DateValue function. Syntax: -CDateToIso(Number) + +CDateToIso(Number) + Return value: String Parameters: @@ -56,8 +58,10 @@ Example: -Sub ExampleCDateToIso -MsgBox "" & CDateToIso(Now) ,64,"ISO Date" -End Sub + +Sub ExampleCDateToIso + MsgBox "" & CDateToIso(Now) ,64,"ISO Date" +End Sub + diff --git a/source/text/sbasic/shared/03030108.xhp b/source/text/sbasic/shared/03030108.xhp index 3d92632be8..1598ddd4e0 100644 --- a/source/text/sbasic/shared/03030108.xhp +++ b/source/text/sbasic/shared/03030108.xhp @@ -47,7 +47,9 @@ Returns the internal date number from a string that contains a date in ISO format. Syntax: -CDateFromIso(String) + +CDateFromIso(String) + Return value: Internal date number Parameters: diff --git a/source/text/sbasic/shared/03030110.xhp b/source/text/sbasic/shared/03030110.xhp index 465e018dcf..32fae34d48 100644 --- a/source/text/sbasic/shared/03030110.xhp +++ b/source/text/sbasic/shared/03030110.xhp @@ -47,7 +47,9 @@ Adds a date interval to a given date a number of times and returns the resulting date. Syntax: -DateAdd (Add, Count, Date) + +DateAdd (Add, Count, Date) + Return value: A Variant containing a date. Parameters: @@ -148,8 +150,10 @@ Count - A numerical expression specifying how often the Add interval will be added (Count is positive) or subtracted (Count is negative). Date - A given date or the name of a Variant variable containing a date. The Add value will be added Count times to this value. Example: -Sub example_dateadd -msgbox DateAdd("m", 1, "1/31/2004") &" - "& DateAdd("m", 1, "1/31/2005") -End Sub + +Sub example_dateadd + MsgBox DateAdd("m", 1, "1/31/2004") &" - "& DateAdd("m", 1, "1/31/2005") +End Sub + diff --git a/source/text/sbasic/shared/03030120.xhp b/source/text/sbasic/shared/03030120.xhp index cdde5b22e2..208d138c95 100644 --- a/source/text/sbasic/shared/03030120.xhp +++ b/source/text/sbasic/shared/03030120.xhp @@ -47,7 +47,9 @@ Returns the number of date intervals between two given date values. Syntax: -DateDiff (Add, Date1, Date2 [, Week_start [, Year_start]]) + +DateDiff (Add, Date1, Date2 [, Week_start [, Year_start]]) + Return value: A number. Parameters: @@ -181,8 +183,10 @@ Example: -Sub example_datediff -msgbox DateDiff("d", "1/1/2005", "12/31/2005") -End Sub + +Sub example_datediff + MsgBox DateDiff("d", "1/1/2005", "12/31/2005") +End Sub + diff --git a/source/text/sbasic/shared/03030130.xhp b/source/text/sbasic/shared/03030130.xhp index 6f4177a00e..5ccc52e951 100644 --- a/source/text/sbasic/shared/03030130.xhp +++ b/source/text/sbasic/shared/03030130.xhp @@ -49,7 +49,9 @@ The DatePart function returns a specified part of a date. Syntax: -DatePart (Add, Date [, Week_start [, Year_start]]) + +DatePart (Add, Date [, Week_start [, Year_start]]) + Return value: A Variant containing a date. Parameters: @@ -60,8 +62,10 @@ Date - The date from which the result is calculated. Example: -Sub example_datepart -msgbox DatePart("ww", "12/31/2005") -End Sub + +Sub example_datepart + MsgBox DatePart("ww", "12/31/2005") +End Sub + diff --git a/source/text/sbasic/shared/03030201.xhp b/source/text/sbasic/shared/03030201.xhp index 2164fb0f6c..caad578d2a 100644 --- a/source/text/sbasic/shared/03030201.xhp +++ b/source/text/sbasic/shared/03030201.xhp @@ -45,7 +45,9 @@ Returns the hour from a time value that is generated by the TimeSerial or the TimeValue function. Syntax: - Hour (Number) + +Hour (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030202.xhp b/source/text/sbasic/shared/03030202.xhp index 3369b16cb3..d6bb9abb0a 100644 --- a/source/text/sbasic/shared/03030202.xhp +++ b/source/text/sbasic/shared/03030202.xhp @@ -45,7 +45,9 @@ Returns the minute of the hour that corresponds to the serial time value that is generated by the TimeSerial or the TimeValue function. Syntax: - Minute (Number) + +Minute (Number) + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03030203.xhp b/source/text/sbasic/shared/03030203.xhp index a487c3aad2..4c025c6521 100644 --- a/source/text/sbasic/shared/03030203.xhp +++ b/source/text/sbasic/shared/03030203.xhp @@ -47,12 +47,16 @@ Returns the current system date and time as a Date value. Syntax: -Now + +Now + Return value: Date Example: -Sub ExampleNow -msgbox "It is now " & Now -End sub + +Sub ExampleNow + MsgBox "It is now " & Now +End Sub + diff --git a/source/text/sbasic/shared/03030204.xhp b/source/text/sbasic/shared/03030204.xhp index d75415cee2..a28f97532a 100644 --- a/source/text/sbasic/shared/03030204.xhp +++ b/source/text/sbasic/shared/03030204.xhp @@ -47,7 +47,9 @@ Returns an integer that represents the seconds of the serial time number that is generated by the TimeSerial or the TimeValue function. Syntax: -Second (Number) + +Second (Number) + Return value: Integer Parameters: @@ -59,8 +61,10 @@ Example: -Sub ExampleSecond -MsgBox "The exact second of the current time is "& Second( Now ) -End sub + +Sub ExampleSecond + MsgBox "The exact second of the current time is "& Second( Now ) +End Sub + diff --git a/source/text/sbasic/shared/03030205.xhp b/source/text/sbasic/shared/03030205.xhp index cc9488b1c1..2cb360df5f 100644 --- a/source/text/sbasic/shared/03030205.xhp +++ b/source/text/sbasic/shared/03030205.xhp @@ -47,7 +47,9 @@ Calculates a serial time value for the specified hour, minute, and second parameters that are passed as numeric value. You can then use this value to calculate the difference between times. Syntax: -TimeSerial (hour, minute, second) + +TimeSerial (hour, minute, second) + Return value: Date Parameters: @@ -70,12 +72,14 @@ Example: -Sub ExampleTimeSerial -Dim dDate As Double, sDate As String -dDate = TimeSerial(8,30,15) -sDate = TimeSerial(8,30,15) -MsgBox dDate,64,"Time as a number" -MsgBox sDate,64,"Formatted time" -End Sub + +Sub ExampleTimeSerial +Dim dDate As Double, sDate As String + dDate = TimeSerial(8,30,15) + sDate = TimeSerial(8,30,15) + MsgBox dDate,64,"Time as a number" + MsgBox sDate,64,"Formatted time" +End Sub + diff --git a/source/text/sbasic/shared/03030206.xhp b/source/text/sbasic/shared/03030206.xhp index 38e122ce1b..9d5c793ed0 100644 --- a/source/text/sbasic/shared/03030206.xhp +++ b/source/text/sbasic/shared/03030206.xhp @@ -47,7 +47,9 @@ Calculates a serial time value from the specified hour, minute, and second - parameters passed as strings - that represents the time in a single numeric value. This value can be used to calculate the difference between times. Syntax: -TimeValue (Text As String) + +TimeValue (Text As String) + Return value: Date Parameters: @@ -61,19 +63,21 @@ Example: -Sub ExampleTimerValue -Dim daDT as Date -Dim a1, b1, c1, a2, b2, c2 as String -a1 = "start time" -b1 = "end time" -c1 = "total time" -a2 = "8:34" -b2 = "18:12" -daDT = TimeValue(b2) - TimeValue(a2) -c2 = a1 & ": " & a2 & chr(13) -c2 = c2 & b1 & ": " & b2 & chr(13) -c2 = c2 & c1 & ": " & trim(Str(Hour(daDT))) & ":" & trim(Str(Minute(daDT))) & ":" & trim(Str(Second(daDT))) -Msgbox c2 -end sub + +Sub ExampleTimerValue +Dim daDT As Date +Dim a1, b1, c1, a2, b2, c2 As String + a1 = "start time" + b1 = "end time" + c1 = "total time" + a2 = "8:34" + b2 = "18:12" + daDT = TimeValue(b2) - TimeValue(a2) + c2 = a1 & ": " & a2 & chr(13) + c2 = c2 & b1 & ": " & b2 & chr(13) + c2 = c2 & c1 & ": " & trim(Str(Hour(daDT))) & ":" & trim(Str(Minute(daDT))) & ":" & trim(Str(Second(daDT))) + MsgBox c2 +End Sub + diff --git a/source/text/sbasic/shared/03030301.xhp b/source/text/sbasic/shared/03030301.xhp index e2ce260e26..c2be688189 100644 --- a/source/text/sbasic/shared/03030301.xhp +++ b/source/text/sbasic/shared/03030301.xhp @@ -47,13 +47,17 @@ Returns the current system date as a string, or resets the date. The date format depends on your local system settings. Syntax: -Date ; Date = Text As String + +Date ; Date = Text As String + Parameters: Text: Only required in order to reset the system date. In this case, the string expression must correspond to the date format defined in your local settings. Example: -Sub ExampleDate -msgbox "The date is " & Date -end sub + +Sub ExampleDate + MsgBox "The date is " & Date +End Sub + diff --git a/source/text/sbasic/shared/03030302.xhp b/source/text/sbasic/shared/03030302.xhp index 6aa8ec82d0..b4f34419b1 100644 --- a/source/text/sbasic/shared/03030302.xhp +++ b/source/text/sbasic/shared/03030302.xhp @@ -47,13 +47,17 @@ This function returns the current system time as a string in the format "HH:MM:SS". Syntax: -Time + +Time + Parameters: Text: Any string expression that specifies the new time in the format "HH:MM:SS". Example: -Sub ExampleTime -MsgBox Time,0,"The time is" -end sub + +Sub ExampleTime + MsgBox Time,0,"The time is" +End Sub + diff --git a/source/text/sbasic/shared/03030303.xhp b/source/text/sbasic/shared/03030303.xhp index 1d673ef380..cdb8337bb5 100644 --- a/source/text/sbasic/shared/03030303.xhp +++ b/source/text/sbasic/shared/03030303.xhp @@ -48,19 +48,23 @@ You must first declare a variable to call the Timer function and assign it the "Long " data type, otherwise a Date value is returned. Syntax: -Timer + +Timer + Return value: Date Example: -Sub ExampleTimer -Dim lSec as long,lMin as long,lHour as long -lSec = Timer -MsgBox lSec,0,"Seconds since midnight" -lMin = lSec / 60 -lSec = lSec Mod 60 -lHour = lMin / 60 -lMin = lMin Mod 60 -MsgBox Right("00" & lHour , 2) & ":"& Right("00" & lMin , 2) & ":" & Right("00" & lSec , 2) ,0,"The time is" -end sub + +Sub ExampleTimer +Dim lSec As Long,lMin As Long,lHour As Long + lSec = Timer + MsgBox lSec,0,"Seconds since midnight" + lMin = lSec / 60 + lSec = lSec Mod 60 + lHour = lMin / 60 + lMin = lMin Mod 60 + MsgBox Right("00" & lHour , 2) & ":"& Right("00" & lMin , 2) & ":" & Right("00" & lSec , 2) ,0,"The time is" +End Sub + diff --git a/source/text/sbasic/shared/03050100.xhp b/source/text/sbasic/shared/03050100.xhp index 657da7ef59..8c090fa59c 100644 --- a/source/text/sbasic/shared/03050100.xhp +++ b/source/text/sbasic/shared/03050100.xhp @@ -48,24 +48,28 @@ dedr: fixed #i30425# Returns the line number where an error occurred during program execution. Syntax: -Erl + +Erl + Return value: Integer Parameters: The Erl function only returns a line number, and not a line label. Example: -sub ExampleError -on error goto ErrorHandler REM Set up error handler -Dim iVar as Integer -Dim sVar As String -REM Error caused by non-existent file -iVar = Freefile -Open "\file9879.txt" for Input as #iVar -Line Input #iVar, sVar -Close #iVar -exit sub -ErrorHandler: -MsgBox "Error " & err & ": " & error$ + chr(13) + "In line : " + Erl + chr(13) + Now , 16 ,"An error occurred" -end sub + +Sub ExampleError +On Error GoTo ErrorHandler ' Set up error handler +Dim iVar As Integer +Dim sVar As String +' Error caused by non-existent file + iVar = Freefile + Open "\file9879.txt" For Input As #iVar + Line Input #iVar, sVar + Close #iVar + Exit Sub +ErrorHandler: + MsgBox "Error " & err & ": " & Error$ + chr(13) + "In Line : " + Erl + chr(13) + Now , 16 ,"An error occurred" +End Sub + diff --git a/source/text/sbasic/shared/03050200.xhp b/source/text/sbasic/shared/03050200.xhp index 7a4b90f789..4dd3c7ca8f 100644 --- a/source/text/sbasic/shared/03050200.xhp +++ b/source/text/sbasic/shared/03050200.xhp @@ -47,7 +47,9 @@ Returns an error code that identifies the error that occurred during program execution. Syntax: -Err + +Err + Return value: Integer Parameters: diff --git a/source/text/sbasic/shared/03050300.xhp b/source/text/sbasic/shared/03050300.xhp index c49ea8698c..0427b4775c 100644 --- a/source/text/sbasic/shared/03050300.xhp +++ b/source/text/sbasic/shared/03050300.xhp @@ -49,7 +49,9 @@ Returns the error message that corresponds to a given error code. Syntax: -Error (Expression) + +Error (Expression) + Return value: String Parameters: diff --git a/source/text/sbasic/shared/03050500.xhp b/source/text/sbasic/shared/03050500.xhp index 77c4ef3d67..89f21c0f8c 100644 --- a/source/text/sbasic/shared/03050500.xhp +++ b/source/text/sbasic/shared/03050500.xhp @@ -44,7 +44,9 @@ Enables an error-handling routine after an error occurs, or resumes program execution. Syntax: -On {[Local] Error GoTo Labelname | GoTo 0 | Resume Next} + +On {[Local] Error GoTo Labelname | GoTo 0 | Resume Next} + Parameters: GoTo Labelname: If an error occurs, enables the error-handling routine that starts at the line "Labelname". Resume Next: If an error occurs, program execution continues with the statement that follows the statement in which the error occurred. @@ -54,30 +56,32 @@ The On Error GoTo statement is used to react to errors that occur in a macro.see i112231: The statement must be inserted at the start of a procedure (in a local error-handling routine) or at the start of a module. Example: -Sub ExampleReset -On Error Goto ErrorHandler -Dim iNumber As Integer -Dim iCount As Integer -Dim sLine As String -Dim aFile As String -aFile = "c:\data.txt" -iNumber = Freefile -Open aFile For Output As #iNumber -Print #iNumber, "This is a line of text" -Close #iNumber -iNumber = Freefile -Open aFile For Input As iNumber -For iCount = 1 to 5 -Line Input #iNumber, sLine -If sLine <>"" then -rem -end if -Next iCount -Close #iNumber -Exit Sub -ErrorHandler: -Reset -MsgBox "All files will be closed",0,"Error" -End Sub + +Sub ExampleReset +On Error GoTo ErrorHandler +Dim iNumber As Integer +Dim iCount As Integer +Dim sLine As String +Dim aFile As String + aFile = "c:\data.txt" + iNumber = Freefile + Open aFile For Output As #iNumber + Print #iNumber, "This is a line of text" + Close #iNumber + iNumber = Freefile + Open aFile For Input As iNumber + For iCount = 1 To 5 + Line Input #iNumber, sLine + If sLine <>"" Then + Rem + End If + Next iCount + Close #iNumber + Exit Sub +ErrorHandler: + Reset + MsgBox "All files will be closed",0,"Error" +End Sub + diff --git a/source/text/sbasic/shared/03060100.xhp b/source/text/sbasic/shared/03060100.xhp index d7f81d5f0c..f1193a113c 100644 --- a/source/text/sbasic/shared/03060100.xhp +++ b/source/text/sbasic/shared/03060100.xhp @@ -47,7 +47,9 @@ Logically combines two expressions. Syntax: -Result = Expression1 And Expression2 + +Result = Expression1 And Expression2 + Parameters: Result: Any numeric variable that records the result of the combination. @@ -58,15 +60,17 @@ True AND True returns True; for all other combinations the result is False. The AND operator also performs a bitwise comparison of identically positioned bits in two numeric expressions. Example: -Sub ExampleAnd -Dim A as Variant, B as Variant, C as Variant, D as Variant -Dim vVarOut as Variant -A = 10: B = 8: C = 6: D = Null -vVarOut = A > B And B > C REM returns -1 -vVarOut = B > A And B > C REM returns 0 -vVarOut = A > B And B > D REM returns 0 -vVarOut = (B > D And B > A) REM returns 0 -vVarOut = B And A REM returns 8 due to the bitwise AND combination of both arguments -End Sub + +Sub ExampleAnd +Dim A As Variant, B As Variant, C As Variant, D As Variant +Dim vVarOut As Variant + A = 10: B = 8: C = 6: D = Null + vVarOut = A > B And B > C ' returns -1 + vVarOut = B > A And B > C ' returns 0 + vVarOut = A > B And B > D ' returns 0 + vVarOut = (B > D And B > A) ' returns 0 + vVarOut = B And A ' returns 8 due to the bitwise And combination of both arguments +End Sub + diff --git a/source/text/sbasic/shared/03060200.xhp b/source/text/sbasic/shared/03060200.xhp index 2cb9ced858..a989838b0b 100644 --- a/source/text/sbasic/shared/03060200.xhp +++ b/source/text/sbasic/shared/03060200.xhp @@ -47,7 +47,9 @@ Calculates the logical equivalence of two expressions. Syntax: -Result = Expression1 Eqv Expression2 + +Result = Expression1 Eqv Expression2 + Parameters: Result: Any numeric variable that contains the result of the comparison. @@ -56,15 +58,17 @@ When testing for equivalence between Boolean expressions, the result is True if both expressions are either True or False. In a bit-wise comparison, the Eqv operator only sets the corresponding bit in the result if a bit is set in both expressions, or in neither expression. Example: -Sub ExampleEqv -Dim A as Variant, B as Variant, C as Variant, D as Variantsee #i38265 -Dim vOut as Variant -A = 10: B = 8: C = 6: D = Null -vOut = A > B Eqv B > C REM returns -1 -vOut = B > A Eqv B > C REM returns 0 -vOut = A > B Eqv B > D REM returns 0 -vOut = (B > D Eqv B > A) REM returns -1 -vOut = B Eqv A REM returns -3 -End Sub + +Sub ExampleEqv +Dim A As Variant, B As Variant, C As Variant, D As Variantsee #i38265 +Dim vOut As Variant + A = 10: B = 8: C = 6: D = Null + vOut = A > B Eqv B > C ' returns -1 + vOut = B > A Eqv B > C ' returns 0 + vOut = A > B Eqv B > D ' returns 0 + vOut = (B > D Eqv B > A) ' returns -1 + vOut = B Eqv A ' returns -3 +End Sub + diff --git a/source/text/sbasic/shared/03060300.xhp b/source/text/sbasic/shared/03060300.xhp index c891476a31..ab0e1c98e1 100644 --- a/source/text/sbasic/shared/03060300.xhp +++ b/source/text/sbasic/shared/03060300.xhp @@ -47,7 +47,9 @@ Performs a logical implication on two expressions. Syntax: -Result = Expression1 Imp Expression2 + +Result = Expression1 Imp Expression2 + Parameters: Result: Any numeric variable that contains the result of the implication. @@ -56,15 +58,17 @@ If you use the Imp operator in Boolean expressions, False is only returned if the first expression evaluates to True and the second expression to False. If you use the Imp operator in bit expressions, a bit is deleted from the result if the corresponding bit is set in the first expression and the corresponding bit is deleted in the second expression. Example: -Sub ExampleImp -Dim A as Variant, B as Variant, C as Variant, D as Variant -Dim vOut as Variant -A = 10: B = 8: C = 6: D = Null -vOut = A > B Imp B > C REM returns -1 -vOut = B > A Imp B > C REM returns -1 -vOut = A > B Imp B > D REM returns 0 -vOut = (B > D Imp B > A) REM returns -1 -vOut = B Imp A REM returns -1 -End Sub + +Sub ExampleImp +Dim A As Variant, B As Variant, C As Variant, D As Variant +Dim vOut As Variant + A = 10: B = 8: C = 6: D = Null + vOut = A > B Imp B > C ' returns -1 + vOut = B > A Imp B > C ' returns -1 + vOut = A > B Imp B > D ' returns 0 + vOut = (B > D Imp B > A) ' returns -1 + vOut = B Imp A ' returns -1 +End Sub + diff --git a/source/text/sbasic/shared/03060400.xhp b/source/text/sbasic/shared/03060400.xhp index 996cfcc457..c22e87beee 100644 --- a/source/text/sbasic/shared/03060400.xhp +++ b/source/text/sbasic/shared/03060400.xhp @@ -47,7 +47,9 @@ Negates an expression by inverting the bit values. Syntax: -Result = Not Expression + +Result = Not Expression + Parameters: Result: Any numeric variable that contains the result of the negation. @@ -56,14 +58,16 @@ When a Boolean expression is negated, the value True changes to False, and the value False changes to True. In a bitwise negation each individual bit is inverted. Example: -Sub ExampleNot -Dim vA as Variant, vB as Variant, vC as Variant, vD as Variant -Dim vOut as Variant -vA = 10: vB = 8: vC = 6: vD = Null -vOut = Not vA REM Returns -11 -vOut = Not(vC > vD) REM Returns -1 -vOut = Not(vB > vA) REM Returns -1 -vOut = Not(vA > vB) REM Returns 0 -end Sub + +Sub ExampleNot +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = Not vA ' Returns -11 + vOut = Not(vC > vD) ' Returns -1 + vOut = Not(vB > vA) ' Returns -1 + vOut = Not(vA > vB) ' Returns 0 +End Sub + diff --git a/source/text/sbasic/shared/03060500.xhp b/source/text/sbasic/shared/03060500.xhp index d0d7e83718..073dc4e3ff 100644 --- a/source/text/sbasic/shared/03060500.xhp +++ b/source/text/sbasic/shared/03060500.xhp @@ -47,7 +47,9 @@ Performs a logical OR disjunction on two expressions. Syntax: -Result = Expression1 Or Expression2 + +Result = Expression1 Or Expression2 + Parameters: Result: Any numeric variable that contains the result of the disjunction. @@ -56,15 +58,17 @@ A logical OR disjunction of two Boolean expressions returns the value True if at least one comparison expression is True. A bit-wise comparison sets a bit in the result if the corresponding bit is set in at least one of the two expressions. Example: -Sub ExampleOr -Dim vA as Variant, vB as Variant, vC as Variant, vD as Variant -Dim vOut as Variant -vA = 10: vB = 8: vC = 6: vD = Null -vOut = vA > vB Or vB > vC REM -1 -vOut = vB > vA Or vB > vC REM -1 -vOut = vA > vB Or vB > vD REM -1 -vOut = (vB > vD Or vB > vA) REM 0 -vOut = vB Or vA REM 10 -End Sub + +Sub ExampleOr +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = vA > vB Or vB > vC ' -1 + vOut = vB > vA Or vB > vC ' -1 + vOut = vA > vB Or vB > vD ' -1 + vOut = (vB > vD Or vB > vA) ' 0 + vOut = vB Or vA ' 10 +End Sub + diff --git a/source/text/sbasic/shared/03060600.xhp b/source/text/sbasic/shared/03060600.xhp index 89630ce40e..fd3ed4c6ef 100644 --- a/source/text/sbasic/shared/03060600.xhp +++ b/source/text/sbasic/shared/03060600.xhp @@ -47,7 +47,9 @@ Performs a logical Exclusive-Or combination of two expressions. Syntax: -Result = Expression1 Xor Expression2 + +Result = Expression1 Xor Expression2 + Parameters: Result: Any numeric variable that contains the result of the combination. @@ -56,15 +58,17 @@ A logical Exclusive-Or conjunction of two Boolean expressions returns the value True only if both expressions are different from each other. A bitwise Exclusive-Or conjunction returns a bit if the corresponding bit is set in only one of the two expressions. Example: -Sub ExampleXor -Dim vA as Variant, vB as Variant, vC as Variant, vD as Variant -Dim vOut as Variant -vA = 10: vB = 8: vC = 6: vD = Null -vOut = vA > vB Xor vB > vC REM returns 0 -vOut = vB > vA Xor vB > vC REM returns -1 -vOut = vA > vB Xor vB > vD REM returns -1 -vOut = (vB > vD Xor vB > vA) REM returns 0 -vOut = vB Xor vA REM returns 2 -End Sub + +Sub ExampleXor +Dim vA As Variant, vB As Variant, vC As Variant, vD As Variant +Dim vOut As Variant + vA = 10: vB = 8: vC = 6: vD = Null + vOut = vA > vB Xor vB > vC ' returns 0 + vOut = vB > vA Xor vB > vC ' returns -1 + vOut = vA > vB Xor vB > vD ' returns -1 + vOut = (vB > vD Xor vB > vA) ' returns 0 + vOut = vB Xor vA ' returns 2 +End Sub + diff --git a/source/text/sbasic/shared/03070100.xhp b/source/text/sbasic/shared/03070100.xhp index 2b3eca0877..6fe436c9bc 100644 --- a/source/text/sbasic/shared/03070100.xhp +++ b/source/text/sbasic/shared/03070100.xhp @@ -47,22 +47,27 @@ Subtracts two values. Syntax: -Result = Expression1 - Expression2 + +Result = Expression1 - Expression2 + Parameters: Result: Any numerical expression that contains the result of the subtraction. Expression1, Expression2: Any numerical expressions that you want to subtract. Example: -Sub ExampleSubtraction1 -Print 5 - 5 -End sub -Sub ExampleSubtraction2 -Dim iValue1 as Integer -Dim iValue2 as Integer -iValue1 = 5 -iValue2 = 10 -Print iValue1 - iValue2 -End Sub + +Sub ExampleSubtraction1 + Print 5 - 5 +End Sub + +Sub ExampleSubtraction2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 - iValue2 +End Sub + diff --git a/source/text/sbasic/shared/03070200.xhp b/source/text/sbasic/shared/03070200.xhp index d159319b31..e4d25a3680 100644 --- a/source/text/sbasic/shared/03070200.xhp +++ b/source/text/sbasic/shared/03070200.xhp @@ -47,22 +47,27 @@ Multiplies two values. Syntax: -Result = Expression1 * Expression2 + +Result = Expression1 * Expression2 + Parameters: Result: Any numeric expression that records the result of a multiplication. Expression1, Expression2: Any numeric expressions that you want to multiply. Example: -Sub ExampleMultiplication1 -Print 5 * 5 -End sub -Sub ExampleMultiplication2 -Dim iValue1 as Integer -Dim iValue2 as Integer -iValue1 = 5 -iValue2 = 10 -Print iValue1 * iValue2 -End Sub + +Sub ExampleMultiplication1 + Print 5 * 5 +End Sub + +Sub ExampleMultiplication2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 * iValue2 +End Sub + diff --git a/source/text/sbasic/shared/03070300.xhp b/source/text/sbasic/shared/03070300.xhp index c0cdd58fb6..c7aa6391b8 100644 --- a/source/text/sbasic/shared/03070300.xhp +++ b/source/text/sbasic/shared/03070300.xhp @@ -47,22 +47,27 @@ Adds or combines two expressions. Syntax: -Result = Expression1 + Expression2 + +Result = Expression1 + Expression2 + Parameters: Result: Any numerical expression that contains the result of the addition. Expression1, Expression2: Any numerical expressions that you want to combine or to add. Example: -Sub ExampleAddition1 -Print 5 + 5 -End sub -Sub ExampleAddition2 -Dim iValue1 as Integer -Dim iValue2 as Integer -iValue1 = 5 -iValue2 = 10 -Print iValue1 + iValue2 -End Sub + +Sub ExampleAddition1 + Print 5 + 5 +End Sub + +Sub ExampleAddition2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 + iValue2 +End Sub + diff --git a/source/text/sbasic/shared/03070400.xhp b/source/text/sbasic/shared/03070400.xhp index 187a92dc46..aee57fae7d 100644 --- a/source/text/sbasic/shared/03070400.xhp +++ b/source/text/sbasic/shared/03070400.xhp @@ -47,22 +47,27 @@ Divides two values. Syntax: -Result = Expression1 / Expression2 + +Result = Expression1 / Expression2 + Parameters: Result: Any numerical value that contains the result of the division. Expression1, Expression2: Any numerical expressions that you want to divide. Example: -Sub ExampleDivision1 -Print 5 / 5 -End sub -Sub ExampleDivision2 -Dim iValue1 as Integer -Dim iValue2 as Integer -iValue1 = 5 -iValue2 = 10 -Print iValue1 / iValue2 -End Sub + +Sub ExampleDivision1 + Print 5 / 5 +End Sub + +Sub ExampleDivision2 +Dim iValue1 As Integer +Dim iValue2 As Integer + iValue1 = 5 + iValue2 = 10 + Print iValue1 / iValue2 +End Sub + diff --git a/source/text/sbasic/shared/03070500.xhp b/source/text/sbasic/shared/03070500.xhp index 7e713b71bf..7ad5409125 100644 --- a/source/text/sbasic/shared/03070500.xhp +++ b/source/text/sbasic/shared/03070500.xhp @@ -47,7 +47,9 @@ Raises a number to a power. Syntax: -Result = Expression ^ Exponent + +Result = Expression ^ Exponent + Parameters: Result: Any numerical expression that contains the result of the number raised to a power. @@ -56,9 +58,11 @@ Exponent: The value of the power that you want to raise the expression to. Example: -Sub Example -Print ( 12.345 ^ 23 ) -Print Exp ( 23 * Log( 12.345 ) ) REM Raises by forming a logarithm -End Sub + +Sub Example + Print ( 12.345 ^ 23 ) + Print Exp ( 23 * Log( 12.345 ) ) ' Raises by forming a logarithm +End Sub + diff --git a/source/text/sbasic/shared/03070600.xhp b/source/text/sbasic/shared/03070600.xhp index 731a6e699c..0c13a8c8fa 100644 --- a/source/text/sbasic/shared/03070600.xhp +++ b/source/text/sbasic/shared/03070600.xhp @@ -47,7 +47,9 @@ Returns the integer remainder of a division. Syntax: -Result = Expression1 MOD Expression2 + +Result = Expression1 MOD Expression2 + Return value: Integer Parameters: @@ -56,13 +58,15 @@ Expression1, Expression2: Any numeric expressions that you want to divide. Example: -sub ExampleMod -print 10 mod 2.5 REM returns 0 -print 10 / 2.5 REM returns 4 -print 10 mod 5 REM returns 0 -print 10 / 5 REM returns 2 -print 5 mod 10 REM returns 5 -print 5 / 10 REM returns 0.5 -end sub + +Sub ExampleMod + Print 10 Mod 2.5 ' returns 0 + Print 10 / 2.5 ' returns 4 + Print 10 Mod 5 ' returns 0 + Print 10 / 5 ' returns 2 + Print 5 Mod 10 ' returns 5 + Print 5 / 10 ' returns 0.5 +End Sub + diff --git a/source/text/sbasic/shared/03080101.xhp b/source/text/sbasic/shared/03080101.xhp index 3961f03df0..06fe67d5d5 100644 --- a/source/text/sbasic/shared/03080101.xhp +++ b/source/text/sbasic/shared/03080101.xhp @@ -49,7 +49,9 @@ The arctangent is the inverse of the tangent function. The Atn Function returns the angle "Alpha", expressed in radians, using the tangent of this angle. The function can also return the angle "Alpha" by comparing the ratio of the length of the side that is opposite of the angle to the length of the side that is adjacent to the angle in a right-angled triangle. Atn(side opposite the angle/side adjacent to angle)= Alpha Syntax: -Atn (Number) + +Atn (Number) + Return value: Double Parameters: @@ -62,15 +64,17 @@ Example: -REM The following example calculates for a right-angled triangle -REM the angle Alpha from the tangent of the angle Alpha: -Sub ExampleATN -REM rounded Pi = 3.14159 is a predefined constant -Dim d1 As Double -Dim d2 As Double -d1 = InputBox$ ("Enter the length of the side adjacent to the angle: ","Adjacent") -d2 = InputBox$ ("Enter the length of the side opposite the angle: ","Opposite") -Print "The Alpha angle is"; (atn (d2/d1) * 180 / Pi); " degrees" -End Sub + +' The following example calculates for a right-angled triangle +' the angle Alpha from the tangent of the angle Alpha: +Sub ExampleAtn +' rounded Pi = 3.14159 Is a predefined constant +Dim d1 As Double +Dim d2 As Double + d1 = InputBox$ ("Enter the length of the side adjacent to the angle: ","Adjacent") + d2 = InputBox$ ("Enter the length of the side opposite the angle: ","Opposite") + Print "The Alpha angle is"; (atn (d2/d1) * 180 / Pi); " degrees" +End Sub + diff --git a/source/text/sbasic/shared/03080102.xhp b/source/text/sbasic/shared/03080102.xhp index 64c45466b1..46d49548c4 100644 --- a/source/text/sbasic/shared/03080102.xhp +++ b/source/text/sbasic/shared/03080102.xhp @@ -49,7 +49,9 @@ Using the angle Alpha, the Cos-Function calculates the ratio of the length of the side that is adjacent to the angle, divided by the length of the hypotenuse in a right-angled triangle. Cos(Alpha) = Adjacent/Hypotenuse Syntax: -Cos (Number) + +Cos (Number) + Return value: Double Parameters: @@ -62,14 +64,16 @@ Example: -REM The following example allows for a right-angled triangle the input of -REM secant and angle (in degrees) and calculates the length of the hypotenuse: -Sub ExampleCosinus -REM rounded Pi = 3.14159 -Dim d1 as Double, dAngle as Double -d1 = InputBox$ (""Enter the length of the adjacent side: ","Adjacent") -dAngle = InputBox$ ("Enter the angle Alpha (in degrees): ","Alpha") -Print "The length of the hypothenuse is"; (d1 / cos (dAngle * Pi / 180)) -End Sub + +' The following example allows for a right-angled triangle the input of +' secant and angle (in degrees) and calculates the length of the hypotenuse: +Sub ExampleCosinus +' rounded Pi = 3.14159 +Dim d1 As Double, dAngle As Double + d1 = InputBox$ (""Enter the length of the adjacent side: ","Adjacent") + dAngle = InputBox$ ("Enter the angle Alpha (in degrees): ","Alpha") + Print "The length of the hypothenuse is"; (d1 / cos (dAngle * Pi / 180)) +End Sub + diff --git a/source/text/sbasic/shared/03080103.xhp b/source/text/sbasic/shared/03080103.xhp index 15a0eec358..e370b23b8f 100644 --- a/source/text/sbasic/shared/03080103.xhp +++ b/source/text/sbasic/shared/03080103.xhp @@ -49,7 +49,9 @@ Using the angle Alpha, the Sin Function returns the ratio of the length of the opposite side of an angle to the length of the hypotenuse in a right-angled triangle. Sin(Alpha) = side opposite the angle/hypotenuse Syntax: -Sin (Number) + +Sin (Number) + Return value: Double Parameters: @@ -62,15 +64,17 @@ Example: -REM In this example, the following entry is possible for a right-angled triangle: -REM The side opposite the angle and the angle (in degrees) to calculate the length of the hypotenuse: -Sub ExampleSine -REM Pi = 3.1415926 is a predefined variable -Dim d1 as Double -Dim dAlpha as Double -d1 = InputBox$ ("Enter the length of the opposite side: ","Opposite Side") -dAlpha = InputBox$ ("Enter the angle Alpha (in degrees): ","Alpha") -Print "The length of the hypotenuse is"; (d1 / sin (dAlpha * Pi / 180)) -End Sub + +' In this example, the following entry is possible for a right-angled triangle: +' The side opposite the angle and the angle (in degrees) to calculate the length of the hypotenuse: +Sub ExampleSine +' Pi = 3.1415926 is a predefined variable +Dim d1 As Double +Dim dAlpha As Double + d1 = InputBox$ ("Enter the length of the opposite side: ","Opposite Side") + dAlpha = InputBox$ ("Enter the angle Alpha (in degrees): ","Alpha") + Print "The length of the hypotenuse is"; (d1 / sin (dAlpha * Pi / 180)) +End Sub + diff --git a/source/text/sbasic/shared/03080104.xhp b/source/text/sbasic/shared/03080104.xhp index 2ddf64330d..2068cbe98a 100644 --- a/source/text/sbasic/shared/03080104.xhp +++ b/source/text/sbasic/shared/03080104.xhp @@ -51,7 +51,9 @@ Using the angle Alpha, the Tan Function calculates the ratio of the length of the side opposite the angle to the length of the side adjacent to the angle in a right-angled triangle. Tan(Alpha) = side opposite the angle/side adjacent to angle Syntax: -Tan (Number) + +Tan (Number) + Return value: Double Parameters: @@ -64,15 +66,17 @@ Example: -REM In this example, the following entry is possible for a right-angled triangle: -REM The side opposite the angle and the angle (in degrees) to calculate the length of the side adjacent to the angle: -Sub ExampleTangens -REM Pi = 3.1415926 is a pre-defined variable -Dim d1 as Double -Dim dAlpha as Double -d1 = InputBox$ ("Enter the length of the side opposite the angle: ","opposite") -dAlpha = InputBox$ ("Enter the Alpha angle (in degrees): ","Alpha") -Print "the length of the side adjacent the angle is"; (d1 / tan (dAlpha * Pi / 180)) -End Sub + +' In this example, the following entry is possible for a right-angled triangle: +' The side opposite the angle and the angle (in degrees) to calculate the length of the side adjacent to the angle: +Sub ExampleTangens +' Pi = 3.1415926 is a pre-defined variable +Dim d1 As Double +Dim dAlpha As Double + d1 = InputBox$ ("Enter the length of the side opposite the angle: ","opposite") + dAlpha = InputBox$ ("Enter the Alpha angle (in degrees): ","Alpha") + Print "the length of the side adjacent the angle is"; (d1 / tan (dAlpha * Pi / 180)) +End Sub + diff --git a/source/text/sbasic/shared/03080201.xhp b/source/text/sbasic/shared/03080201.xhp index 47b1b8af17..a82013b561 100644 --- a/source/text/sbasic/shared/03080201.xhp +++ b/source/text/sbasic/shared/03080201.xhp @@ -47,7 +47,9 @@ Returns the base of the natural logarithm (e = 2.718282) raised to a power. Syntax: -Exp (Number) + +Exp (Number) + Return value: Double Parameters: @@ -56,12 +58,14 @@ Example: -Sub ExampleLogExp -Dim dValue as Double -const b1=12.345e12 -const b2=1.345e34 -dValue=Exp( Log(b1)+Log(b2) ) -MsgBox "" & dValue & chr(13) & (b1*b2) ,0,"Multiplication by logarithm" -end sub + +Sub ExampleLogExp +Dim dValue As Double + Const b1=12.345e12 +Const b2=1.345e34 + dValue=Exp( Log(b1)+Log(b2) ) + MsgBox "" & dValue & chr(13) & (b1*b2) ,0,"Multiplication by logarithm" +End Sub + diff --git a/source/text/sbasic/shared/03080202.xhp b/source/text/sbasic/shared/03080202.xhp index 1eb316b05e..44b65c6b98 100644 --- a/source/text/sbasic/shared/03080202.xhp +++ b/source/text/sbasic/shared/03080202.xhp @@ -47,7 +47,9 @@ Returns the natural logarithm of a number. Syntax: -Log (Number) + +Log (Number) + Return value: Double Parameters: @@ -59,12 +61,14 @@ Example: -Sub ExampleLogExp -Dim a as Double -Dim const b1=12.345e12 -Dim const b2=1.345e34 -a=Exp( Log(b1)+Log(b2) ) -MsgBox "" & a & chr(13) & (b1*b2) ,0,"Multiplication by logarithm function" -end sub + +Sub ExampleLogExp +Dim a As Double +Dim Const b1=12.345e12 +Dim Const b2=1.345e34 + a=Exp( Log(b1)+Log(b2) ) + MsgBox "" & a & chr(13) & (b1*b2) ,0,"Multiplication by logarithm function" +End Sub + diff --git a/source/text/sbasic/shared/03080301.xhp b/source/text/sbasic/shared/03080301.xhp index 22f62b069f..e9cbe542ca 100644 --- a/source/text/sbasic/shared/03080301.xhp +++ b/source/text/sbasic/shared/03080301.xhp @@ -43,26 +43,30 @@ Initializes the random-number generator. Syntax: -Randomize [Number] + +Randomize [Number] + Parameters: Number: Any integer value that initializes the random-number generator. Example: -Sub ExampleRandomize -Dim iVar As Integer, sText As String -Dim iSpectral(10) As Integer -Randomize 2^14-1 -For iCount = 1 To 1000 -iVar = Int((10 * Rnd) ) REM Range from 0 to 9 -iSpectral(iVar) = iSpectral(iVar) +1 -Next iCount -sText = " | " -For iCount = 0 To 9 -sText = sText & iSpectral(iCount) & " | " -Next iCount -MsgBox sText,0,"Spectral Distribution" -end sub + +Sub ExampleRandomize +Dim iVar As Integer, sText As String +Dim iSpectral(10) As Integer + Randomize 2^14-1 + For iCount = 1 To 1000 + iVar = Int((10 * Rnd) ) ' Range from 0 To 9 + iSpectral(iVar) = iSpectral(iVar) +1 + Next iCount + sText = " | " + For iCount = 0 To 9 + sText = sText & iSpectral(iCount) & " | " + Next iCount + MsgBox sText,0,"Spectral Distribution" +End Sub + diff --git a/source/text/sbasic/shared/03080302.xhp b/source/text/sbasic/shared/03080302.xhp index 92f33def84..a9c1b13ce5 100644 --- a/source/text/sbasic/shared/03080302.xhp +++ b/source/text/sbasic/shared/03080302.xhp @@ -43,7 +43,9 @@ Returns a random number between 0 and 1. Syntax: -Rnd [(Expression)] + +Rnd [(Expression)] + Return value: Double Parameters: @@ -55,19 +57,21 @@ Example: -Sub ExampleRandomSelect -Dim iVar As Integer -iVar = Int((15 * Rnd) -2) -Select Case iVar -Case 1 To 5 -Print "Number from 1 to 5" -Case 6, 7, 8 -Print "Number from 6 to 8" -Case Is > 8 And iVar < 11 -Print "Greater than 8" -Case Else -Print "Outside range 1 to 10" -End Select -end sub + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case Is > 8 And iVar < 11 + Print "Greater than 8" + Case Else + Print "Outside range 1 to 10" + End Select +End Sub + diff --git a/source/text/sbasic/shared/03080401.xhp b/source/text/sbasic/shared/03080401.xhp index 09fb2f79b9..19480b5ba1 100644 --- a/source/text/sbasic/shared/03080401.xhp +++ b/source/text/sbasic/shared/03080401.xhp @@ -47,7 +47,9 @@ Calculates the square root of a numeric expression. Syntax: -Sqr (Number) + +Sqr (Number) + Return value: Double Parameters: @@ -57,10 +59,12 @@ Example: -Sub ExampleSqr -Dim iVar As Single -iVar = 36 -Msgbox Sqr(iVar) -end sub + +Sub ExampleSqr +Dim iVar As Single + iVar = 36 + MsgBox Sqr(iVar) +End Sub + diff --git a/source/text/sbasic/shared/03080501.xhp b/source/text/sbasic/shared/03080501.xhp index 1248c4a2e1..bda0915bf7 100644 --- a/source/text/sbasic/shared/03080501.xhp +++ b/source/text/sbasic/shared/03080501.xhp @@ -47,7 +47,9 @@ Returns the integer value of a numeric expression by removing the fractional part of the number. Syntax: -Fix (Expression) + +Fix (Expression) + Return value: Double Parameters: @@ -56,10 +58,12 @@ Example: -sub ExampleFix -Print Fix(3.14159) REM returns 3. -Print Fix(0) REM returns 0. -Print Fix(-3.14159) REM returns -3. -end sub + +Sub ExampleFix + Print Fix(3.14159) ' returns 3. + Print Fix(0) ' returns 0. + Print Fix(-3.14159) ' returns -3. +End Sub + diff --git a/source/text/sbasic/shared/03080502.xhp b/source/text/sbasic/shared/03080502.xhp index a5f2933a79..1b97c9e249 100644 --- a/source/text/sbasic/shared/03080502.xhp +++ b/source/text/sbasic/shared/03080502.xhp @@ -47,7 +47,9 @@ Returns the integer portion of a number. Syntax: -Int (Number) + +Int (Number) + Return value: Double Parameters: @@ -56,10 +58,12 @@ Example: -sub ExampleINT -Print Int(3.99) REM returns the value 3 -Print Int(0) REM returns the value 0 -Print Int(-3.14159) REM returns the value -4 -end sub + +Sub ExampleInt + Print Int(3.99) ' returns the value 3 + Print Int(0) ' returns the value 0 + Print Int(-3.14159) ' returns the value -4 +End Sub + diff --git a/source/text/sbasic/shared/03080601.xhp b/source/text/sbasic/shared/03080601.xhp index 140794fdf1..a05824637d 100644 --- a/source/text/sbasic/shared/03080601.xhp +++ b/source/text/sbasic/shared/03080601.xhp @@ -47,7 +47,9 @@ Returns the absolute value of a numeric expression. Syntax: -Abs (Number) + +Abs (Number) + Return value: Double Parameters: @@ -57,12 +59,14 @@ Example: -Sub ExampleDifference -Dim siW1 As Single -Dim siW2 As Single -siW1 = Int(InputBox$ ("Please enter the first amount","Value input")) -siW2 = Int(InputBox$ ("Please enter the second amount","Value input")) -Print "The difference is "; Abs(siW1 - siW2) -End Sub + +Sub ExampleDifference +Dim siW1 As Single +Dim siW2 As Single + siW1 = Int(InputBox$ ("Please enter the first amount","Value Input")) + siW2 = Int(InputBox$ ("Please enter the second amount","Value Input")) + Print "The difference is "; Abs(siW1 - siW2) +End Sub + diff --git a/source/text/sbasic/shared/03080701.xhp b/source/text/sbasic/shared/03080701.xhp index 447ce29eac..63db346103 100644 --- a/source/text/sbasic/shared/03080701.xhp +++ b/source/text/sbasic/shared/03080701.xhp @@ -47,7 +47,9 @@ Returns an integer number between -1 and 1 that indicates if the number that is passed to the function is positive, negative, or zero. Syntax: -Sgn (Number) + +Sgn (Number) + Return value: Integer Parameters: @@ -90,10 +92,12 @@ Example: -Sub ExampleSgn -Print sgn(-10) REM returns -1 -Print sgn(0) REM returns 0 -Print sgn(10) REM returns 1 -end sub + +Sub ExampleSgn + Print sgn(-10) ' returns -1 + Print sgn(0) ' returns 0 + Print sgn(10) ' returns 1 +End Sub + diff --git a/source/text/sbasic/shared/03080801.xhp b/source/text/sbasic/shared/03080801.xhp index 7d751a1fdd..b01994e23c 100644 --- a/source/text/sbasic/shared/03080801.xhp +++ b/source/text/sbasic/shared/03080801.xhp @@ -47,7 +47,9 @@ Returns a string that represents the hexadecimal value of a number. Syntax: -Hex (Number) + +Hex (Number) + Return value: String Parameters: @@ -56,22 +58,26 @@ Example: -Sub ExampleHex -REM uses BasicFormulas in $[officename] Calc -Dim a2, b2, c2 as String -a2 = "&H3E8" -b2 = Hex2Int(a2) -MsgBox b2 -c2 = Int2Hex(b2) -MsgBox c2 -End Sub -Function Hex2Int( sHex As String ) As Long -REM Returns a Long-Integer from a hexadecimal value. -Hex2Int = clng( sHex ) -End Function -Function Int2Hex( iLong As Long) As String -REM Calculates a hexadecimal value in Integer. -Int2Hex = "&H" & Hex( iLong ) -End Function + +Sub ExampleHex +' uses BasicFormulas in $[officename] Calc +Dim a2, b2, c2 As String + a2 = "&H3E8" + b2 = Hex2Int(a2) + MsgBox b2 + c2 = Int2Hex(b2) + MsgBox c2 +End Sub + +Function Hex2Int( sHex As String ) As Long +' Returns a long integer from a hexadecimal value. + Hex2Int = clng( sHex ) +End Function + +Function Int2Hex( iLong As Long) As String +' Calculates a hexadecimal value in integer. + Int2Hex = "&H" & Hex( iLong ) +End Function + diff --git a/source/text/sbasic/shared/03080802.xhp b/source/text/sbasic/shared/03080802.xhp index 4c506bd2da..fb649e8e04 100644 --- a/source/text/sbasic/shared/03080802.xhp +++ b/source/text/sbasic/shared/03080802.xhp @@ -47,7 +47,9 @@ Returns the octal value of a number. Syntax: -Oct (Number) + +Oct (Number) + Return value: String Parameters: @@ -56,8 +58,10 @@ Example: -Sub ExampleOkt -Msgbox Oct(255) -end sub + +Sub ExampleOct + MsgBox Oct(255) +End Sub + diff --git a/source/text/sbasic/shared/03090101.xhp b/source/text/sbasic/shared/03090101.xhp index 120c3452e9..991409b81e 100644 --- a/source/text/sbasic/shared/03090101.xhp +++ b/source/text/sbasic/shared/03090101.xhp @@ -32,7 +32,7 @@ --> - + If...Then...Else Statement [Runtime] @@ -47,7 +47,10 @@ Defines one or more statement blocks that you only want to execute if a given condition is True. Syntax: -If condition=true Then Statement block [ElseIf condition=true Then] Statement block [Else] Statement block EndIf
Instead of Else If you can write ElseIf, instead of End If you can write EndIf.
+ +If condition=true Then Statement block [ElseIf condition=true Then] Statement block [Else] Statement block EndIf + +Instead of Else If you can write ElseIf, instead of End If you can write EndIf. Parameters: The If...Then statement executes program blocks depending on given conditions. When $[officename] Basic encounters an If statement, the condition is tested. If the condition is True, all subsequent statements up to the next Else or ElseIf statement are executed. If the condition is False, and an ElseIf statement follows, $[officename] Basic tests the next condition and executes the following statements if the condition is True. If False, the program continues either with the next ElseIf or Else statement. Statements following Else are executed only if none of the previously tested conditions were True. After all conditions are evaluated, and the corresponding statements executed, the program continues with the statement following EndIf. You can nest multiple If...Then statements. @@ -56,20 +59,22 @@ You can use GoTo and GoSub to jump out of an If...Then block, but not to jump into an If...Then structure. The following example enables you to enter the expiration date of a product, and determines if the expiration date has passed. Example: -Sub ExampleIfThenDate -Dim sDate as String -Dim sToday as String -sDate = InputBox("Enter the expiration date (MM.DD.YYYY)") -sDate = Right$(sDate, 4) + Mid$(sDate, 4, 2) + Left$(sDate, 2) -sToday = Date$ -sToday = Right$(sToday, 4)+ Mid$(sToday, 4, 2) + Left$(sToday, 2) -If sDate < sToday Then -MsgBox "The expiration date has passed" -ElseIf sDate > sToday Then -MsgBox "The expiration date has not yet passed" -Else -MsgBox "The expiration date is today" -End If -End Sub + +Sub ExampleIfThenDate +Dim sDate As String +Dim sToday As String + sDate = InputBox("Enter the expiration date (MM.DD.YYYY)") + sDate = Right$(sDate, 4) + Mid$(sDate, 4, 2) + Left$(sDate, 2) + sToday = Date$ + sToday = Right$(sToday, 4)+ Mid$(sToday, 4, 2) + Left$(sToday, 2) + If sDate < sToday Then + MsgBox "The expiration date has passed" + ElseIf sDate > sToday Then + MsgBox "The expiration date has not yet passed" + Else + MsgBox "The expiration date is today" + End If +End Sub +
diff --git a/source/text/sbasic/shared/03090102.xhp b/source/text/sbasic/shared/03090102.xhp index 80fdedca72..ab2bc42f86 100644 --- a/source/text/sbasic/shared/03090102.xhp +++ b/source/text/sbasic/shared/03090102.xhp @@ -48,26 +48,30 @@ Defines one or more statement blocks depending on the value of an expression. Syntax: -Select Case condition Case expression Statement Block [Case expression2 Statement Block][Case Else] Statement Block End Select + +Select Case condition Case expression Statement Block [Case expression2 Statement Block][Case Else] Statement Block End Select + Parameters: Condition: Any expression that controls if the statement block that follows the respective Case clause is executed. Expression: Any expression that is compatible with the Condition type expression. The statement block that follows the Case clause is executed if Condition matches Expression. Example: -Sub ExampleRandomSelect -Dim iVar As Integer -iVar = Int((15 * Rnd) -2) -Select Case iVar -Case 1 To 5 -Print "Number from 1 to 5" -Case 6, 7, 8 -Print "Number from 6 to 8" -Case 8 To 10 -Print "Greater than 8" -Case Else -Print "Out of range 1 to 10" -End Select -end sub + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case 8 To 10 + Print "Greater than 8" + Case Else + Print "Out of range 1 to 10" + End Select +End Sub +
diff --git a/source/text/sbasic/shared/03090103.xhp b/source/text/sbasic/shared/03090103.xhp index 4c9f803f62..330c1df056 100644 --- a/source/text/sbasic/shared/03090103.xhp +++ b/source/text/sbasic/shared/03090103.xhp @@ -47,7 +47,9 @@ Returns one of two possible function results, depending on the logical value of the evaluated expression. Syntax: -IIf (Expression, ExpressionTrue, ExpressionFalse) + +IIf (Expression, ExpressionTrue, ExpressionFalse) + Parameters: Expression: Any expression that you want to evaluate. If the expression evaluates to True, the function returns the result of ExpressionTrue, otherwise it returns the result of ExpressionFalse. diff --git a/source/text/sbasic/shared/03090201.xhp b/source/text/sbasic/shared/03090201.xhp index e3a08323c7..f4a4a8fe80 100644 --- a/source/text/sbasic/shared/03090201.xhp +++ b/source/text/sbasic/shared/03090201.xhp @@ -91,17 +91,19 @@ statements Loop... Example -Sub ExampleDoLoop -Dim sFile As String -Dim sPath As String -sPath = "c:\" -sFile = Dir$( sPath ,22) -If sFile <> "" Then -Do -MsgBox sFile -sFile = Dir$ -Loop Until sFile = "" -End If -End Sub + +Sub ExampleDoLoop +Dim sFile As String +Dim sPath As String + sPath = "c:\" + sFile = Dir$( sPath ,22) + If sFile <> "" Then + Do + MsgBox sFile + sFile = Dir$ + Loop Until sFile = "" + End If +End Sub + diff --git a/source/text/sbasic/shared/03090202.xhp b/source/text/sbasic/shared/03090202.xhp index 04131b1f1f..f3e85bd7a2 100644 --- a/source/text/sbasic/shared/03090202.xhp +++ b/source/text/sbasic/shared/03090202.xhp @@ -50,11 +50,13 @@ Repeats the statements between the For...Next block a specified number of times. Syntax: -For counter=start To end [Step step] -statement block -[Exit For] -statement block -Next [counter] + +For counter=start To end [Step step] +statement block +[Exit For] +statement block +Next [counter] + Variables: Counter: Loop counter initially assigned the value to the right of the equal sign (start). Only numeric variables are valid. The loop counter increases or decreases according to the variable Step until End is passed. @@ -78,33 +80,35 @@ Note: In nested For...Next loops, if you exit a loop unconditionally with Exit For, only one loop is exited. Example The following example uses two nested loops to sort a string array with 10 elements ( sEntry() ), that are first filled with various contents: -Sub ExampleSort -Dim sEntry(9) As String -Dim iCount As Integer -Dim iCount2 As Integer -Dim sTemp As String -sEntry(0) = "Jerry" -sEntry(1) = "Patty" -sEntry(2) = "Kurt" -sEntry(3) = "Thomas" -sEntry(4) = "Michael" -sEntry(5) = "David" -sEntry(6) = "Cathy" -sEntry(7) = "Susie" -sEntry(8) = "Edward" -sEntry(9) = "Christine" -For iCount = 0 To 9 -For iCount2 = iCount + 1 To 9 -If sEntry(iCount) > sEntry(iCount2) Then -sTemp = sEntry(iCount) -sEntry(iCount) = sEntry(iCount2) -sEntry(iCount2) = sTemp -End If -Next iCount2 -Next iCount -For iCount = 0 To 9 -Print sEntry(iCount) -Next iCount -End Sub + +Sub ExampleSort +Dim sEntry(9) As String +Dim iCount As Integer +Dim iCount2 As Integer +Dim sTemp As String + sEntry(0) = "Jerry" + sEntry(1) = "Patty" + sEntry(2) = "Kurt" + sEntry(3) = "Thomas" + sEntry(4) = "Michael" + sEntry(5) = "David" + sEntry(6) = "Cathy" + sEntry(7) = "Susie" + sEntry(8) = "Edward" + sEntry(9) = "Christine" + For iCount = 0 To 9 + For iCount2 = iCount + 1 To 9 + If sEntry(iCount) > sEntry(iCount2) Then + sTemp = sEntry(iCount) + sEntry(iCount) = sEntry(iCount2) + sEntry(iCount2) = sTemp + End If + Next iCount2 + Next iCount + For iCount = 0 To 9 + Print sEntry(iCount) + Next iCount +End Sub + diff --git a/source/text/sbasic/shared/03090203.xhp b/source/text/sbasic/shared/03090203.xhp index 92464b0c7c..fa8324ccbc 100644 --- a/source/text/sbasic/shared/03090203.xhp +++ b/source/text/sbasic/shared/03090203.xhp @@ -47,18 +47,22 @@ Unlike the Do...Loop statement, you cannot cancel a While...Wend loop with Exit. Never exit a While...Wend loop with GoTo, since this can cause a run-time error. A Do...Loop is more flexible than a While...Wend. Syntax: - While Condition [Statement] Wend + +While Condition [Statement] Wend + Example: - Sub ExampleWhileWend - Dim stext As String - Dim iRun As Integer - sText ="This is a short text" - iRun = 1 - while iRun < Len(sText) - if Mid(sText,iRun,1 )<> " " then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) ) - iRun = iRun + 1 - Wend - MsgBox sText,0,"Text encoded" - end sub + + Sub ExampleWhileWend + Dim stext As String + Dim iRun As Integer + sText ="This Is a short text" + iRun = 1 + While iRun < Len(sText) + If Mid(sText,iRun,1 )<> " " Then Mid( sText ,iRun, 1, Chr( 1 + Asc( Mid(sText,iRun,1 )) ) + iRun = iRun + 1 + Wend + MsgBox sText,0,"Text encoded" + End Sub + diff --git a/source/text/sbasic/shared/03090301.xhp b/source/text/sbasic/shared/03090301.xhp index 63bdcb0e6c..a28bc65088 100644 --- a/source/text/sbasic/shared/03090301.xhp +++ b/source/text/sbasic/shared/03090301.xhp @@ -47,7 +47,9 @@ Calls a subroutine that is indicated by a label from a subroutine or a function. The statements following the label are executed until the next Return statement. Afterwards, the program continues with the statement that follows the GoSub statement. Syntax: -see Parameters + +see Parameters + Parameters: Sub/Function statement block @@ -63,22 +65,24 @@ If the program encounters a Return statement not preceded by GoSub, $[officename] Basic returns an error message. Use Exit Sub or Exit Function to ensure that the program leaves a Sub or Function before reaching the next Return statement. The following example demonstrates the use of GoSub and Return. By executing a program section twice, the program calculates the square root of two numbers that are entered by the user. Example: -Sub ExampleGoSub -dim iInputa as Single -dim iInputb as Single -dim iInputc as Single -iInputa = Int(InputBox$ "Enter the first number: ","NumberInput")) -iInputb = Int(InputBox$ "Enter the second number: ","NumberInput")) -iInputc=iInputa -GoSub SquareRoot -Print "The square root of";iInputa;" is";iInputc -iInputc=iInputb -GoSub SquareRoot -Print "The square root of";iInputb;" is";iInputc -Exit Sub -SquareRoot: -iInputc=sqr(iInputc) -Return -End Sub + +Sub ExampleGoSub +Dim iInputa As Single +Dim iInputb As Single +Dim iInputc As Single + iInputa = Int(InputBox$ "Enter the first number: ","NumberInput")) + iInputb = Int(InputBox$ "Enter the second number: ","NumberInput")) + iInputc=iInputa + GoSub SquareRoot + Print "The square root of";iInputa;" is";iInputc + iInputc=iInputb + GoSub SquareRoot + Print "The square root of";iInputb;" is";iInputc + Exit Sub +SquareRoot: + iInputc=sqr(iInputc) + Return +End Sub + diff --git a/source/text/sbasic/shared/03090302.xhp b/source/text/sbasic/shared/03090302.xhp index f2681432c4..4f823799c9 100644 --- a/source/text/sbasic/shared/03090302.xhp +++ b/source/text/sbasic/shared/03090302.xhp @@ -49,7 +49,9 @@ Continues program execution within a Sub or Function at the procedure line indicated by a label. Syntax: -see Parameters + +see Parameters + Parameters: Sub/Function statement block diff --git a/source/text/sbasic/shared/03090303.xhp b/source/text/sbasic/shared/03090303.xhp index 18d6d2da97..0ce0e73caf 100644 --- a/source/text/sbasic/shared/03090303.xhp +++ b/source/text/sbasic/shared/03090303.xhp @@ -48,8 +48,10 @@ Branches to one of several specified lines in the program code, depending on the value of a numeric expression. Syntax: -On N GoSub Label1[, Label2[, Label3[,...]]] -On NumExpression GoTo Label1[, Label2[, Label3[,...]]] + +On N GoSub Label1[, Label2[, Label3[,...]]] +On NumExpression GoTo Label1[, Label2[, Label3[,...]]] + Parameters: NumExpression: Any numeric expression between 0 and 255 that determines which of the lines the program branches to. If NumExpression is 0, the statement is not executed. If NumExpression is greater than 0, the program jumps to the label that has a position number that corresponds to the expression (1 = First label; 2 = Second label) @@ -57,24 +59,26 @@ Label: Target line according to GoTo or GoSub structure. The GoTo or GoSub conventions are valid. Example: -Sub ExampleOnGosub -Dim iVar As Integer -Dim sVar As String -iVar = 2 -sVar ="" -On iVar GoSub Sub1, Sub2 -On iVar GoTo Line1, Line2 -Exit Sub -Sub1: -sVar =sVar & " From Sub 1 to" : Return -Sub2: -sVar =sVar & " From Sub 2 to" : Return -Line1: -sVar =sVar & " Label 1" : GoTo Ende -Line2: -sVar =sVar & " Label 2" -Ende: -MsgBox sVar,0,"On...Gosub" -End Sub + +Sub ExampleOnGosub +Dim iVar As Integer +Dim sVar As String + iVar = 2 + sVar ="" + On iVar GoSub Sub1, Sub2 + On iVar GoTo Line1, Line2 + Exit Sub +Sub1: + sVar =sVar & " From Sub 1 to" : Return +Sub2: + sVar =sVar & " From Sub 2 to" : Return +Line1: + sVar =sVar & " Label 1" : GoTo Ende +Line2: + sVar =sVar & " Label 2" +Ende: + MsgBox sVar,0,"On...GoSub" +End Sub + diff --git a/source/text/sbasic/shared/03090401.xhp b/source/text/sbasic/shared/03090401.xhp index 434cb71298..600aa2df05 100644 --- a/source/text/sbasic/shared/03090401.xhp +++ b/source/text/sbasic/shared/03090401.xhp @@ -47,7 +47,9 @@ Transfers the control of the program to a subroutine, a function, or a DLL procedure. Syntax: -[Call] Name [Parameter] + +[Call] Name [Parameter] + Parameters: Name: Name of the subroutine, the function, or the DLL that you want to call diff --git a/source/text/sbasic/shared/03090402.xhp b/source/text/sbasic/shared/03090402.xhp index 5eda3d85b1..e28081f7a7 100644 --- a/source/text/sbasic/shared/03090402.xhp +++ b/source/text/sbasic/shared/03090402.xhp @@ -47,7 +47,9 @@ Returns a selected value from a list of arguments. Syntax: -Choose (Index, Selection1[, Selection2, ... [,Selection_n]]) + +Choose (Index, Selection1[, Selection2, ... [,Selection_n]]) + Parameters: Index: A numeric expression that specifies the value to return. @@ -59,13 +61,16 @@ Example: -Sub ExampleChoose -Dim sReturn As String -sReturn = ChooseMenu(2) -Print sReturn -end sub -Function ChooseMenu(Index As Integer) -ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format") -End Function + +Sub ExampleChoose +Dim sReturn As String + sReturn = ChooseMenu(2) + Print sReturn +End Sub + +Function ChooseMenu(Index As Integer) + ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format") +End Function + diff --git a/source/text/sbasic/shared/03090403.xhp b/source/text/sbasic/shared/03090403.xhp index 26cfa055ab..bc91f018a7 100644 --- a/source/text/sbasic/shared/03090403.xhp +++ b/source/text/sbasic/shared/03090403.xhp @@ -50,7 +50,9 @@ See also: FreeLibrary Syntax: -Declare {Sub | Function} Name Lib "Libname" [Alias "Aliasname"] [Parameter] [As Type] + +Declare {Sub | Function} Name Lib "Libname" [Alias "Aliasname"] [Parameter] [As Type] + Parameters: Name: A different name than defined in the DLL, to call the subroutine from $[officename] Basic. @@ -64,12 +66,14 @@ Type: Defines the data type of the value that is returned by a function procedure. You can exclude this parameter if a type-declaration character is entered after the name. To pass a parameter to a subroutine as a value instead of as a reference, the parameter must be indicated by the keyword ByVal. Example: -Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( long ) -Sub ExampleDeclare -Dim lValue As Long -lValue = 5000 -MyMessageBeep( lValue ) -FreeLibrary("user32.dll" ) -End Sub + +Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long ) +Sub ExampleDeclare +Dim lValue As Long + lValue = 5000 + MyMessageBeep( lValue ) + FreeLibrary("user32.dll" ) +End Sub + diff --git a/source/text/sbasic/shared/03090404.xhp b/source/text/sbasic/shared/03090404.xhp index 93b9fd167b..b580a55edb 100644 --- a/source/text/sbasic/shared/03090404.xhp +++ b/source/text/sbasic/shared/03090404.xhp @@ -47,7 +47,9 @@ Ends a procedure or block. Syntax: -End, End Function, End If, End Select, End Sub + +End, End Function, End If, End Select, End Sub + Parameters: Use the End statement as follows: Statement @@ -57,19 +59,21 @@ End Select: Marks the end of a Select Case block. End Sub: Ends a Sub statement. Example: -Sub ExampleRandomSelect -Dim iVar As Integer -iVar = Int((15 * Rnd) -2) -Select Case iVar -Case 1 To 5 -Print "Number from 1 to 5" -Case 6, 7, 8 -Print "Number from 6 to 8" -Case Is > 8 And iVar < 11 -Print "Greater than 8" -Case Else -Print "Outside range 1 to 10" -End Select -end sub + +Sub ExampleRandomSelect +Dim iVar As Integer + iVar = Int((15 * Rnd) -2) + Select Case iVar + Case 1 To 5 + Print "Number from 1 to 5" + Case 6, 7, 8 + Print "Number from 6 to 8" + Case Is > 8 And iVar < 11 + Print "Greater than 8" + Case Else + Print "Outside range 1 to 10" + End Select +End Sub + diff --git a/source/text/sbasic/shared/03090405.xhp b/source/text/sbasic/shared/03090405.xhp index 56c0817ddb..5ce59411f5 100644 --- a/source/text/sbasic/shared/03090405.xhp +++ b/source/text/sbasic/shared/03090405.xhp @@ -47,7 +47,9 @@ Releases DLLs that were loaded by a Declare statement. A released DLL is automatically reloaded if one of its functions is called. See also: Declare Syntax: -FreeLibrary (LibName As String) + +FreeLibrary (LibName As String) + Parameters: LibName: String expression that specifies the name of the DLL. @@ -55,12 +57,14 @@ Example: -Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( long ) -Sub ExampleDeclare -Dim lValue As Long -lValue = 5000 -MyMessageBeep( lValue ) -FreeLibrary("user32.dll" ) -End Sub + +Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long ) +Sub ExampleDeclare +Dim lValue As Long + lValue = 5000 + MyMessageBeep( lValue ) + FreeLibrary("user32.dll" ) +End Sub + diff --git a/source/text/sbasic/shared/03090406.xhp b/source/text/sbasic/shared/03090406.xhp index c6f24dc8cf..040e9aadb5 100644 --- a/source/text/sbasic/shared/03090406.xhp +++ b/source/text/sbasic/shared/03090406.xhp @@ -63,28 +63,31 @@ Type: Type-declaration keyword. Example: -Sub ExampleExit -Dim sReturn As String -Dim sListArray(10) as String -Dim siStep as Single -For siStep = 0 to 10 REM Fill array with test data -sListArray(siStep) = chr$(siStep + 65) -msgbox sListArray(siStep) -next siStep -sReturn = LinSearch(sListArray(), "B") -Print sReturn -end sub -Function LinSearch( sList(), sItem As String ) as integer -dim iCount as Integer -REM Linsearch searches a TextArray:sList() for a TextEntry: -REM Return value is the index of the entry or 0 (Null) -for iCount=1 to Ubound( sList() ) -if sList( iCount ) = sItem then -exit for REM sItem found -end if -next iCount -if iCount = Ubound( sList() ) then iCount = 0 -LinSearch = iCount -end function + +Sub ExampleExit +Dim sReturn As String +Dim sListArray(10) As String +Dim siStep As Single + For siStep = 0 To 10 ' Fill array with test data + sListArray(siStep) = chr$(siStep + 65) + MsgBox sListArray(siStep) + Next siStep + sReturn = LinSearch(sListArray(), "B") + Print sReturn +End Sub + +Function LinSearch( sList(), sItem As String ) As Integer +Dim iCount As Integer +' Linsearch searches a TextArray:sList() for a TextEntry: +' Return value Is the index of the entry Or 0 (Null) + For iCount=1 To Ubound( sList() ) + If sList( iCount ) = sItem Then + Exit For ' sItem found + End If + Next iCount + If iCount = Ubound( sList() ) Then iCount = 0 + LinSearch = iCount +End Function + diff --git a/source/text/sbasic/shared/03090407.xhp b/source/text/sbasic/shared/03090407.xhp index a041e0fc6d..15ecf0eb53 100644 --- a/source/text/sbasic/shared/03090407.xhp +++ b/source/text/sbasic/shared/03090407.xhp @@ -50,18 +50,22 @@ Specifies that a program line is a comment. Syntax: -Rem Text + +Rem Text + Parameters: Text: Any text that serves as a comment. You can use the single quotation mark instead of the Rem keyword to indicate that the text on a line is comments. This symbol can be inserted directly to the right of the program code, followed by a comment. You can use a space followed by the underline character _ as the last two characters of a line to continue the logical line on the next line. To continue comment lines, you must enter "Option Compatible" in the same Basic module. Example: -Sub ExampleMid -DIM sVar As String -sVar = "Las Vegas" -Print Mid(sVar,3,5) REM Returns "s Veg" -REM Nothing occurs here -end sub + +Sub ExampleMid +Dim sVar As String + sVar = "Las Vegas" + Print Mid(sVar,3,5) ' Returns "s Veg" + ' Nothing occurs here +End Sub + diff --git a/source/text/sbasic/shared/03090408.xhp b/source/text/sbasic/shared/03090408.xhp index ff2f3de86a..6ef6dc1a10 100644 --- a/source/text/sbasic/shared/03090408.xhp +++ b/source/text/sbasic/shared/03090408.xhp @@ -47,13 +47,17 @@ Stops the execution of the Basic program. Syntax: -Stop + +Stop + Example: -Sub ExampleStop -Dim iVar As Single -iVar = 36 -Stop -Msgbox Sqr(iVar) -end sub + +Sub ExampleStop +Dim iVar As Single + iVar = 36 + Stop + MsgBox Sqr(iVar) +End Sub + diff --git a/source/text/sbasic/shared/03090409.xhp b/source/text/sbasic/shared/03090409.xhp index 137f6f7ed6..10a1aef480 100644 --- a/source/text/sbasic/shared/03090409.xhp +++ b/source/text/sbasic/shared/03090409.xhp @@ -47,9 +47,11 @@ Defines a subroutine. Syntax -Sub Name[(VarName1 [As Type][, VarName2 [As Type][,...]])] -statement block -End Sub + +Sub Name[(VarName1 [As Type][, VarName2 [As Type][,...]])] +statement block +End Sub + Parameters: Name: Name of the subroutine . @@ -58,8 +60,10 @@ Type: Type-declaration key word. Example: -Sub Example -REM some statements -end sub + +Sub Example + ' some statements +End Sub + diff --git a/source/text/sbasic/shared/03090410.xhp b/source/text/sbasic/shared/03090410.xhp index 9a6b0833d9..f7e1bdb377 100644 --- a/source/text/sbasic/shared/03090410.xhp +++ b/source/text/sbasic/shared/03090410.xhp @@ -47,7 +47,9 @@ Evaluates a list of arguments, consisting of an expression followed by a value. The Switch function returns a value that is associated with the expression that is passed by this function. Syntax: -Switch (Expression1, Value1[, Expression2, Value2[..., Expression_n, Value_n]]) + +Switch (Expression1, Value1[, Expression2, Value2[..., Expression_n, Value_n]]) + Parameters: The Switch function evaluates the expressions from left to right, and then returns the value that is assigned to the function expression. If expression and value are not given as a pair, a runtime error occurs. @@ -58,13 +60,16 @@ Example: -Sub ExampleSwitch -Dim sGender As String -sGender = GetGenderIndex( "John" ) -MsgBox sGender -End Sub -Function GetGenderIndex (sName As String) As String -GetGenderIndex = Switch(sName = "Jane", "female", sName = "John", "male") -End Function + +Sub ExampleSwitch +Dim sGender As String + sGender = GetGenderIndex( "John" ) + MsgBox sGender +End Sub + +Function GetGenderIndex (sName As String) As String + GetGenderIndex = Switch(sName = "Jane", "female", sName = "John", "male") +End Function + diff --git a/source/text/sbasic/shared/03090411.xhp b/source/text/sbasic/shared/03090411.xhp index 27f0d54f6f..a0bccd1d41 100644 --- a/source/text/sbasic/shared/03090411.xhp +++ b/source/text/sbasic/shared/03090411.xhp @@ -47,7 +47,9 @@ Sets an object as the default object. Unless another object name is declared, all properties and methods refer to the default object until the End With statement is reached. Syntax: -With Object Statement block End With + +With Object Statement block End With + Parameters: Use With and End With if you have several properties or methods for a single object. diff --git a/source/text/sbasic/shared/03090412.xhp b/source/text/sbasic/shared/03090412.xhp index 13557ee7c6..80d0ac3dea 100644 --- a/source/text/sbasic/shared/03090412.xhp +++ b/source/text/sbasic/shared/03090412.xhp @@ -47,7 +47,9 @@ Exits a Do...Loop, For...Next, a function, or a subroutine. Syntax: -see Parameters + +see Parameters + Parameters: Exit Do @@ -67,28 +69,31 @@ Exits the subroutine immediately. Program execution continues with the statement that follows the Sub call. The Exit statement does not define the end of a structure, and must not be confused with the End statement. Example: -Sub ExampleExit -Dim sReturn As String -Dim sListArray(10) as String -Dim siStep as Single -For siStep = 0 to 10 REM Fill array with test data -sListArray(siStep) = chr(siStep + 65) -msgbox sListArray(siStep) -next siStep -sReturn = LinSearch(sListArray(), "B") -Print sReturn -end sub -Function LinSearch( sList(), sItem As String ) as integer -dim iCount as Integer -REM LinSearch searches a TextArray:sList() for a TextEntry: -REM Returns the index of the entry or 0 ( Null) -for iCount=1 to Ubound( sList() ) -if sList( iCount ) = sItem then -Exit for REM sItem found -end if -next iCount -if iCount = Ubound( sList() ) then iCount = 0 -LinSearch = iCount -end function + +Sub ExampleExit +Dim sReturn As String +Dim sListArray(10) As String +Dim siStep As Single + For siStep = 0 To 10 ' Fill array with test data + sListArray(siStep) = chr(siStep + 65) + MsgBox sListArray(siStep) + Next siStep + sReturn = LinSearch(sListArray(), "B") + Print sReturn +End Sub + +Function LinSearch( sList(), sItem As String ) As Integer +Dim iCount As Integer +' LinSearch searches a TextArray:sList() for a TextEntry: +' Returns the index of the entry or 0 (Null) + For iCount=1 To Ubound( sList() ) + If sList( iCount ) = sItem Then + Exit For ' sItem found + End If + Next iCount + If iCount = Ubound( sList() ) Then iCount = 0 + LinSearch = iCount +End Function + diff --git a/source/text/sbasic/shared/03100050.xhp b/source/text/sbasic/shared/03100050.xhp index 553c6dd6a2..4eb9f80281 100644 --- a/source/text/sbasic/shared/03100050.xhp +++ b/source/text/sbasic/shared/03100050.xhp @@ -47,7 +47,9 @@ Converts a string expression or numeric expression to a currency expression. The locale settings are used for decimal separators and currency symbols. Syntax: -CCur(Expression) + +CCur(Expression) + Return value: Currency Parameter: diff --git a/source/text/sbasic/shared/03100060.xhp b/source/text/sbasic/shared/03100060.xhp index 2c4f6de731..31a918c01f 100644 --- a/source/text/sbasic/shared/03100060.xhp +++ b/source/text/sbasic/shared/03100060.xhp @@ -47,7 +47,9 @@ Converts a string expression or numeric expression to a decimal expression. Syntax: -CDec(Expression) + +CDec(Expression) + Return value: Decimal number. Parameter: diff --git a/source/text/sbasic/shared/03100070.xhp b/source/text/sbasic/shared/03100070.xhp index a1db6c4139..c52c1a46bb 100644 --- a/source/text/sbasic/shared/03100070.xhp +++ b/source/text/sbasic/shared/03100070.xhp @@ -47,7 +47,9 @@ Converts a string expression or numeric expression to a variant expression. Syntax: -CVar(Expression) + +CVar(Expression) + Return value: Variant. Parameter: diff --git a/source/text/sbasic/shared/03100080.xhp b/source/text/sbasic/shared/03100080.xhp index fc66d023f0..c52e307dec 100644 --- a/source/text/sbasic/shared/03100080.xhp +++ b/source/text/sbasic/shared/03100080.xhp @@ -47,7 +47,9 @@ Converts a string expression or numeric expression to a variant expression of the sub type "Error". Syntax: -CVErr(Expression) + +CVErr(Expression) + Return value: Variant. Parameter: diff --git a/source/text/sbasic/shared/03100100.xhp b/source/text/sbasic/shared/03100100.xhp index f8fd76636d..7fe32697e3 100644 --- a/source/text/sbasic/shared/03100100.xhp +++ b/source/text/sbasic/shared/03100100.xhp @@ -47,7 +47,9 @@ Converts a string comparison or numeric comparison to a Boolean expression, or converts a single numeric expression to a Boolean expression. Syntax: -CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) or CBool (Number) + +CBool (Expression1 {= | <> | < | > | <= | >=} Expression2) or CBool (Number) + Return value: Bool Parameters: @@ -59,16 +61,18 @@ Example: -Sub ExampleCBool -Dim sText As String -sText = InputBox("Please enter a short sentence:") -REM Proof if the word »and« appears in the sentence. -REM Instead of the command line -REM If Instr(Input, "and")<>0 Then... -REM the CBool function is applied as follows: -If CBool(Instr(sText, "and")) Then -MsgBox "The word »and« appears in the sentence you entered!" -EndIf -End Sub + +Sub ExampleCBool +Dim sText As String + sText = InputBox("Please enter a short sentence:") + ' Proof if the word »and« appears in the sentence. + ' Instead of the command line + ' If Instr(Input, "and")<>0 Then... + ' the CBool function is applied as follows: + If CBool(Instr(sText, "and")) Then + MsgBox "The word »and« appears in the sentence you entered!" + EndIf +End Sub + diff --git a/source/text/sbasic/shared/03100300.xhp b/source/text/sbasic/shared/03100300.xhp index 2b203d3634..250522888f 100644 --- a/source/text/sbasic/shared/03100300.xhp +++ b/source/text/sbasic/shared/03100300.xhp @@ -47,7 +47,9 @@ Converts any string or numeric expression to a date value. Syntax: -CDate (Expression) + +CDate (Expression) + Return value: Date Parameters: @@ -57,9 +59,11 @@ Example: -sub ExampleCDate -MsgBox cDate(1000.25) REM 09.26.1902 06:00:00 -MsgBox cDate(1001.26) REM 09.27.1902 06:14:24 -end sub + +Sub ExampleCDate + MsgBox cDate(1000.25) ' 09.26.1902 06:00:00 + MsgBox cDate(1001.26) ' 09.27.1902 06:14:24 +End Sub + diff --git a/source/text/sbasic/shared/03100400.xhp b/source/text/sbasic/shared/03100400.xhp index f454264895..44bc5fdb4a 100644 --- a/source/text/sbasic/shared/03100400.xhp +++ b/source/text/sbasic/shared/03100400.xhp @@ -56,10 +56,12 @@ Example: -Sub ExampleCountryConvert -Msgbox CDbl(1234.5678) -Msgbox CInt(1234.5678) -Msgbox CLng(1234.5678) -end sub + +Sub ExampleCountryConvert + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) +End Sub + diff --git a/source/text/sbasic/shared/03100500.xhp b/source/text/sbasic/shared/03100500.xhp index ce93b797cb..88e4319c19 100644 --- a/source/text/sbasic/shared/03100500.xhp +++ b/source/text/sbasic/shared/03100500.xhp @@ -47,7 +47,9 @@ Converts any string or numeric expression to an integer. Syntax: -CInt (Expression) + +CInt (Expression) + Return value: Integer Parameters: @@ -57,10 +59,12 @@ Example: -Sub ExampleCountryConvert -Msgbox CDbl(1234.5678) -Msgbox CInt(1234.5678) -Msgbox CLng(1234.5678) -end sub + +Sub ExampleCountryConvert + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) +End Sub + diff --git a/source/text/sbasic/shared/03100600.xhp b/source/text/sbasic/shared/03100600.xhp index 335ff9e8f3..64e7240898 100644 --- a/source/text/sbasic/shared/03100600.xhp +++ b/source/text/sbasic/shared/03100600.xhp @@ -47,7 +47,9 @@ Converts any string or numeric expression to a long integer. Syntax: -CLng (Expression) + +CLng (Expression) + Return value: Long Parameters: @@ -57,10 +59,12 @@ Example: -Sub ExampleCountryConvert -Msgbox CDbl(1234.5678) -Msgbox CInt(1234.5678) -Msgbox CLng(1234.5678) -end sub + +Sub ExampleCountryConvert + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) +End Sub + diff --git a/source/text/sbasic/shared/03100700.xhp b/source/text/sbasic/shared/03100700.xhp index e5c70dc0ff..0830bca4a3 100644 --- a/source/text/sbasic/shared/03100700.xhp +++ b/source/text/sbasic/shared/03100700.xhp @@ -47,7 +47,9 @@ Defines a string as a constant. Syntax: -Const Text = Expression + +Const Text = Expression + Parameters: Text: Any constant name that follows the standard variable naming conventions. @@ -55,11 +57,13 @@ CONST ConstName=Expression The type of expression is irrelevant. If a program is started, $[officename] Basic converts the program code internally so that each time a constant is used, the defined expression replaces it. Example: -Sub ExampleConst -Const iVar = 1964 -Msgbox iVar -Const sVar = "Program", dVar As Double = 1.00 -Msgbox sVar & " " & dVar -end sub + +Sub ExampleConst + Const iVar = 1964 + MsgBox iVar + Const sVar = "Program", dVar As Double = 1.00 + MsgBox sVar & " " & dVar +End Sub + diff --git a/source/text/sbasic/shared/03100900.xhp b/source/text/sbasic/shared/03100900.xhp index 399c343a66..0ca7bac05d 100644 --- a/source/text/sbasic/shared/03100900.xhp +++ b/source/text/sbasic/shared/03100900.xhp @@ -47,7 +47,9 @@ Converts any string or numeric expression to data type Single. Syntax: -CSng (Expression) + +CSng (Expression) + Return value: Single Parameters: @@ -56,11 +58,13 @@ Example: -Sub ExampleCSNG -Msgbox CDbl(1234.5678) -Msgbox CInt(1234.5678) -Msgbox CLng(1234.5678) -Msgbox CSng(1234.5678) -end sub + +Sub ExampleCSNG + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) + MsgBox CSng(1234.5678) +End Sub + diff --git a/source/text/sbasic/shared/03101000.xhp b/source/text/sbasic/shared/03101000.xhp index 2526f059e6..908e0e9c72 100644 --- a/source/text/sbasic/shared/03101000.xhp +++ b/source/text/sbasic/shared/03101000.xhp @@ -47,7 +47,9 @@ Converts any numeric expression to a string expression. Syntax: -CStr (Expression) + +CStr (Expression) + Return value: String Parameters: @@ -101,14 +103,16 @@ Example: -Sub ExampleCSTR -Dim sVar As String -Msgbox CDbl(1234.5678) -Msgbox CInt(1234.5678) -Msgbox CLng(1234.5678) -Msgbox CSng(1234.5678) -sVar = CStr(1234.5678) -MsgBox sVar -end sub + +Sub ExampleCSTR +Dim sVar As String + MsgBox CDbl(1234.5678) + MsgBox CInt(1234.5678) + MsgBox CLng(1234.5678) + MsgBox CSng(1234.5678) + sVar = CStr(1234.5678) + MsgBox sVar +End Sub + diff --git a/source/text/sbasic/shared/03101100.xhp b/source/text/sbasic/shared/03101100.xhp index 7cd0976459..0a9667ad9d 100644 --- a/source/text/sbasic/shared/03101100.xhp +++ b/source/text/sbasic/shared/03101100.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefBool statement sets the default data type for variables, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set the default data type for. @@ -58,16 +60,18 @@ DefBool: Boolean Example: -REM Prefix definition for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefBool -bOK=TRUE REM bOK is an implicit Boolean variable -end sub + +' Prefix definition for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefBool + bOK=TRUE ' bOK is an implicit boolean variable +End Sub + diff --git a/source/text/sbasic/shared/03101110.xhp b/source/text/sbasic/shared/03101110.xhp index 6c120bd862..dae62bf773 100644 --- a/source/text/sbasic/shared/03101110.xhp +++ b/source/text/sbasic/shared/03101110.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefCur statement sets the default variable type, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. diff --git a/source/text/sbasic/shared/03101120.xhp b/source/text/sbasic/shared/03101120.xhp index 5477e07623..bc4b83abae 100644 --- a/source/text/sbasic/shared/03101120.xhp +++ b/source/text/sbasic/shared/03101120.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefErr statement sets the default variable type, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. @@ -58,17 +60,19 @@ DefErr: Error Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -DefErr e -Sub ExampleDefErr -eErr=Error REM eErr is an implicit error variable -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +DefErr e +Sub ExampleDefErr + eErr=Error ' eErr is an implicit error variable +End Sub + diff --git a/source/text/sbasic/shared/03101130.xhp b/source/text/sbasic/shared/03101130.xhp index be99de3a82..508e32274d 100644 --- a/source/text/sbasic/shared/03101130.xhp +++ b/source/text/sbasic/shared/03101130.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefSng statement sets the default variable type, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. @@ -58,17 +60,19 @@ DefSng: Single Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -DefSng s -Sub ExampleDefSng -sSng=Single REM sSng is an implicit single variable -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +DefSng s +Sub ExampleDefSng + sSng=Single ' sSng is an implicit single variable +End Sub + diff --git a/source/text/sbasic/shared/03101140.xhp b/source/text/sbasic/shared/03101140.xhp index 5654e043bf..c05267f53b 100644 --- a/source/text/sbasic/shared/03101140.xhp +++ b/source/text/sbasic/shared/03101140.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefStr statement sets the default variable type, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. @@ -58,17 +60,19 @@ DefStr: String Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -DefStr s -Sub ExampleDefStr -sStr=String REM sStr is an implicit string variable -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +DefStr s +Sub ExampleDefStr + sStr=String ' sStr is an implicit string variable +End Sub + diff --git a/source/text/sbasic/shared/03101300.xhp b/source/text/sbasic/shared/03101300.xhp index fa8828313d..e9fec6dc3e 100644 --- a/source/text/sbasic/shared/03101300.xhp +++ b/source/text/sbasic/shared/03101300.xhp @@ -47,7 +47,9 @@ If no type-declaration character or keyword is specified, the DefDate statement sets the default variable type, according to a letter range. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. @@ -58,16 +60,18 @@ DefDate: Date Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefDate -tDate=Date REM tDate is an implicit date variable -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefDate + tDate=Date ' tDate is an implicit date variable +End Sub + diff --git a/source/text/sbasic/shared/03101400.xhp b/source/text/sbasic/shared/03101400.xhp index 88146bebbb..351cbd39db 100644 --- a/source/text/sbasic/shared/03101400.xhp +++ b/source/text/sbasic/shared/03101400.xhp @@ -47,7 +47,9 @@ Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set the default data type for. @@ -58,16 +60,18 @@ DefDbl: Double Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefDBL -dValue=1.23e43 REM dValue is an implicit Double variable type -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefDBL + dValue=1.23e43 ' dValue is an implicit double variable type +End Sub + diff --git a/source/text/sbasic/shared/03101500.xhp b/source/text/sbasic/shared/03101500.xhp index 4b59301441..89399fc3d1 100644 --- a/source/text/sbasic/shared/03101500.xhp +++ b/source/text/sbasic/shared/03101500.xhp @@ -47,7 +47,9 @@ Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set a default data type for. @@ -58,16 +60,18 @@ DefInt: Integer Example: -REM Prefix definitions for variable types -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefInt -iCount=200 REM iCount is an implicit integer variable -end sub + +' Prefix definitions for variable types +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefInt + iCount=200 ' iCount is an implicit integer variable +End Sub + diff --git a/source/text/sbasic/shared/03101600.xhp b/source/text/sbasic/shared/03101600.xhp index 8e236758d3..eef026b188 100644 --- a/source/text/sbasic/shared/03101600.xhp +++ b/source/text/sbasic/shared/03101600.xhp @@ -47,7 +47,9 @@ Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set the default data type for. @@ -58,16 +60,18 @@ DefLng: Long Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefLng -lCount=123456789 REM lCount is an implicit long integer variable -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefLng + lCount=123456789 ' lCount is an implicit long integer variable +End Sub + diff --git a/source/text/sbasic/shared/03101700.xhp b/source/text/sbasic/shared/03101700.xhp index eb631019b0..7de2fc376f 100644 --- a/source/text/sbasic/shared/03101700.xhp +++ b/source/text/sbasic/shared/03101700.xhp @@ -47,7 +47,9 @@ Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set the default data type for. diff --git a/source/text/sbasic/shared/03102000.xhp b/source/text/sbasic/shared/03102000.xhp index 6402243a69..71fb8f9eb4 100644 --- a/source/text/sbasic/shared/03102000.xhp +++ b/source/text/sbasic/shared/03102000.xhp @@ -47,7 +47,9 @@ Sets the default variable type, according to a letter range, if no type-declaration character or keyword is specified. Syntax: -Defxxx Characterrange1[, Characterrange2[,...]] + +Defxxx Characterrange1[, Characterrange2[,...]] + Parameters: Characterrange: Letters that specify the range of variables that you want to set the default data type for. @@ -58,17 +60,19 @@ DefVar: Variant Example: -REM Prefix definitions for variable types: -DefBool b -DefDate t -DefDbL d -DefInt i -DefLng l -DefObj o -DefVar v -Sub ExampleDefVar -vDiv=99 REM vDiv is an implicit variant -vDiv="Hello world" -end sub + +' Prefix definitions for variable types: +DefBool b +DefDate t +DefDbl d +DefInt i +DefLng l +DefObj o +DefVar v +Sub ExampleDefVar + vDiv=99 ' vDiv is an implicit variant + vDiv="Hello world" +End Sub + diff --git a/source/text/sbasic/shared/03102100.xhp b/source/text/sbasic/shared/03102100.xhp index cc232caf2a..0988222ff8 100644 --- a/source/text/sbasic/shared/03102100.xhp +++ b/source/text/sbasic/shared/03102100.xhp @@ -49,12 +49,16 @@ Declares a variable or an array. If the variables are separated by commas (for example, DIM sPar1, sPar2, sPar3 AS STRING), only Variant variables can be defined. Use a separate definition line for each variable. -DIM sPar1 AS STRING -DIM sPar2 AS STRING -DIM sPar3 AS STRING + +Dim sPar1 As String +Dim sPar2 As String +Dim sPar3 As String + Dim declares local variables within subroutines. Global variables are declared with the PUBLIC or the PRIVATE statement. Syntax: -[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] + +[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] + Parameters: VarName: Any variable or array name. @@ -96,25 +100,28 @@ DIM text(20,2) as String REM 63 elements; form 0 to 20 level 1, from 0 to 20 level 2 and from 0 to 20 level 3. You can declare an array types as dynamic if a ReDim statement defines the number of dimensions in the subroutine or the function that contains the array. Generally, you can only define an array dimension once, and you cannot modify it. Within a subroutine, you can declare an array with ReDim. You can only define dimensions with numeric expressions. This ensures that the fields are only as large as necessary. Example: -Sub ExampleDim1 -Dim sVar As String -Dim iVar As Integer -sVar = "Office" -End Sub -Sub ExampleDim2 -REM Two-dimensional data field -Dim stext(20,2) as String -Const sDim as String = " Dimension:" -for i = 0 to 20 -for ii = 0 to 2 -stext(i,ii) = str(i) & sDim & str(ii) -next ii -next i -for i = 0 to 20 -for ii = 0 to 2 -msgbox stext(i,ii) -next ii -next i -End Sub + +Sub ExampleDim1 +Dim sVar As String +Dim iVar As Integer + sVar = "Office" +End Sub + +Sub ExampleDim2 +' Two-dimensional data field +Dim stext(20,2) As String +Const sDim As String = " Dimension:" +For i = 0 To 20 + For ii = 0 To 2 + stext(i,ii) = str(i) & sDim & str(ii) + Next ii +Next i +For i = 0 To 20 + For ii = 0 To 2 + MsgBox stext(i,ii) + Next ii +Next i +End Sub + diff --git a/source/text/sbasic/shared/03102101.xhp b/source/text/sbasic/shared/03102101.xhp index ef08c0acb4..f3c3685598 100644 --- a/source/text/sbasic/shared/03102101.xhp +++ b/source/text/sbasic/shared/03102101.xhp @@ -47,8 +47,10 @@ Declares a variable or an array. Syntax: -[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] -Optionally, you can add the Preserve keyword as a parameter to preserve the contents of the array that is redimensioned. + +[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] + +Optionally, you can add the Preserve keyword as a parameter to preserve the contents of the array that is redimensioned. Parameters: VarName: Any variable or array name. @@ -86,16 +88,18 @@ rem numbered from -15 to 5 Variable fields, regardless of type, can be made dynamic if they are dimensioned by ReDim at the procedure level in subroutines or functions. Normally, you can only set the range of an array once and you cannot modify it. Within a procedure, you can declare an array using the ReDim statement with numeric expressions to define the range of the field sizes. Example: -Sub ExampleRedim -Dim iVar() As Integer, iCount As Integer -ReDim iVar(5) As integer -For iCount = 1 To 5 -iVar(iCount) = iCount -Next iCount -ReDim iVar(10) As integer -For iCount = 1 To 10 -iVar(iCount) = iCount -Next iCount -end sub + +Sub ExampleRedim +Dim iVar() As Integer, iCount As Integer +ReDim iVar(5) As Integer +For iCount = 1 To 5 + iVar(iCount) = iCount +Next iCount +ReDim iVar(10) As Integer +For iCount = 1 To 10 + iVar(iCount) = iCount +Next iCount +End Sub + diff --git a/source/text/sbasic/shared/03102200.xhp b/source/text/sbasic/shared/03102200.xhp index 8fc1189909..937be635be 100644 --- a/source/text/sbasic/shared/03102200.xhp +++ b/source/text/sbasic/shared/03102200.xhp @@ -47,7 +47,9 @@ Determines if a variable is a data field in an array. Syntax: -IsArray (Var) + +IsArray (Var) + Return value: Bool Parameters: @@ -56,9 +58,11 @@ Example: -Sub ExampleIsArray -Dim sDatf(10) as String -print isarray(sdatf()) -end Sub + +Sub ExampleIsArray +Dim sDatf(10) As String + Print isarray(sdatf()) +End Sub + diff --git a/source/text/sbasic/shared/03102300.xhp b/source/text/sbasic/shared/03102300.xhp index b5507de522..82b55280a5 100644 --- a/source/text/sbasic/shared/03102300.xhp +++ b/source/text/sbasic/shared/03102300.xhp @@ -47,7 +47,9 @@ Tests if a numeric or string expression can be converted to a Date variable. Syntax: -IsDate (Expression) + +IsDate (Expression) + Return value: Bool Parameters: @@ -56,12 +58,14 @@ Example: -Sub ExampleIsDate -Dim sDateVar as String -sDateVar = "12.12.1997" -print IsDate(sDateVar) REM Returns True -sDateVar = "12121997" -print IsDate(sDateVar) REM Returns False -end sub + +Sub ExampleIsDate +Dim sDateVar As String + sDateVar = "12.12.1997" + Print IsDate(sDateVar) ' Returns True + sDateVar = "12121997" + Print IsDate(sDateVar) ' Returns False +End Sub + diff --git a/source/text/sbasic/shared/03102400.xhp b/source/text/sbasic/shared/03102400.xhp index 6f9789a2a9..1ec4e5638b 100644 --- a/source/text/sbasic/shared/03102400.xhp +++ b/source/text/sbasic/shared/03102400.xhp @@ -47,7 +47,9 @@ Tests if a Variant variable contains the Empty value. The Empty value indicates that the variable is not initialized. Syntax: -IsEmpty (Var) + +IsEmpty (Var) + Return value: Bool Parameters: @@ -56,10 +58,12 @@ Example: -Sub ExampleIsEmpty -Dim sVar as Variant -sVar = Empty -Print IsEmpty(sVar) REM Returns True -end sub + +Sub ExampleIsEmpty +Dim sVar As Variant + sVar = Empty + Print IsEmpty(sVar) ' Returns True +End Sub + diff --git a/source/text/sbasic/shared/03102450.xhp b/source/text/sbasic/shared/03102450.xhp index 08a8a48e40..98069e5c68 100644 --- a/source/text/sbasic/shared/03102450.xhp +++ b/source/text/sbasic/shared/03102450.xhp @@ -47,7 +47,9 @@ Tests if a variable contains an error value. Syntax: -IsError (Var) + +IsError (Var) + Return value: Bool Parameters: diff --git a/source/text/sbasic/shared/03102600.xhp b/source/text/sbasic/shared/03102600.xhp index 750c23b8a5..2f24ff2500 100644 --- a/source/text/sbasic/shared/03102600.xhp +++ b/source/text/sbasic/shared/03102600.xhp @@ -46,7 +46,9 @@ Tests if a Variant contains the special Null value, indicating that the variable does not contain data. Syntax: -IsNull (Var) + +IsNull (Var) + Return value: Bool Parameters: @@ -57,9 +59,11 @@ Example: -Sub ExampleIsNull -Dim vVar As Variant -msgbox IsNull(vVar) -end sub + +Sub ExampleIsNull +Dim vVar As Variant + MsgBox IsNull(vVar) +End Sub + diff --git a/source/text/sbasic/shared/03102700.xhp b/source/text/sbasic/shared/03102700.xhp index 8c31eed8e8..aff11aa92a 100644 --- a/source/text/sbasic/shared/03102700.xhp +++ b/source/text/sbasic/shared/03102700.xhp @@ -47,7 +47,9 @@ Tests if an expression is a number. If the expression is a number, the function returns True, otherwise the function returns False. Syntax: -IsNumeric (Var) + +IsNumeric (Var) + Return value: Bool Parameters: @@ -56,12 +58,14 @@ Example: -Sub ExampleIsNumeric -Dim vVar as variant -vVar = "ABC" -Print IsNumeric(vVar) REM Returns False -vVar = "123" -Print IsNumeric(vVar) REM Returns True -end sub + +Sub ExampleIsNumeric +Dim vVar As Variant + vVar = "ABC" + Print IsNumeric(vVar) ' Returns False + vVar = "123" + Print IsNumeric(vVar) ' Returns True +End Sub + diff --git a/source/text/sbasic/shared/03102800.xhp b/source/text/sbasic/shared/03102800.xhp index 8c7724ccaa..001a816b60 100644 --- a/source/text/sbasic/shared/03102800.xhp +++ b/source/text/sbasic/shared/03102800.xhp @@ -47,7 +47,9 @@ Tests if an object variable is an OLE object. The function returns True if the variable is an OLE object, otherwise it returns False. Syntax: -IsObject (ObjectVar) + +IsObject (ObjectVar) + Return value: Bool Parameters: diff --git a/source/text/sbasic/shared/03102900.xhp b/source/text/sbasic/shared/03102900.xhp index d0662a78f2..fb893358fc 100644 --- a/source/text/sbasic/shared/03102900.xhp +++ b/source/text/sbasic/shared/03102900.xhp @@ -47,7 +47,9 @@ Returns the lower boundary of an array. Syntax: -LBound (ArrayName [, Dimension]) + +LBound (ArrayName [, Dimension]) + Return value: Integer Parameters: @@ -59,17 +61,20 @@ Example: -Sub ExampleUboundLbound -Dim sVar(10 to 20) As String -print LBound(sVar()) -print UBound(sVar()) -end Sub -Sub ExampleUboundLbound2 -Dim sVar(10 to 20,5 To 70) As String -Print LBound(sVar()) REM Returns 10 -Print UBound(sVar()) REM Returns 20 -Print LBound(sVar(),2) REM Returns 5 -Print UBound(sVar(),2) REM Returns 70 -end Sub + +Sub ExampleUboundLbound +Dim sVar(10 To 20) As String + Print LBound(sVar()) + Print UBound(sVar()) +End Sub + +Sub ExampleUboundLbound2 +Dim sVar(10 To 20,5 To 70) As String + Print LBound(sVar()) ' Returns 10 + Print UBound(sVar()) ' Returns 20 + Print LBound(sVar(),2) ' Returns 5 + Print UBound(sVar(),2) ' Returns 70 +End Sub + diff --git a/source/text/sbasic/shared/03103000.xhp b/source/text/sbasic/shared/03103000.xhp index 997edf5be1..5eef1c56a6 100644 --- a/source/text/sbasic/shared/03103000.xhp +++ b/source/text/sbasic/shared/03103000.xhp @@ -47,7 +47,9 @@ Returns the upper boundary of an array. Syntax: -UBound (ArrayName [, Dimension]) + +UBound (ArrayName [, Dimension]) + Return value: Integer Parameters: @@ -59,17 +61,20 @@ Example: -Sub ExampleUboundLbound -Dim sVar(10 to 20) As String -print LBound(sVar()) -print UBound(sVar()) -end Sub -Sub ExampleUboundLbound2 -Dim sVar(10 to 20,5 To 70) As String -Print LBound(sVar()) REM Returns 10 -Print UBound(sVar()) REM Returns 20 -Print LBound(sVar(),2) REM Returns 5 -Print UBound(sVar(),2) REM Returns 70 -end Sub + +Sub ExampleUboundLbound +Dim sVar(10 To 20) As String + Print LBound(sVar()) + Print UBound(sVar()) +End Sub + +Sub ExampleUboundLbound2 +Dim sVar(10 To 20,5 To 70) As String + Print LBound(sVar()) ' Returns 10 + Print UBound(sVar()) ' Returns 20 + Print LBound(sVar(),2) ' Returns 5 + Print UBound(sVar(),2) ' Returns 70 +End Sub + diff --git a/source/text/sbasic/shared/03103100.xhp b/source/text/sbasic/shared/03103100.xhp index 38c8b3bf95..31905fa2a4 100644 --- a/source/text/sbasic/shared/03103100.xhp +++ b/source/text/sbasic/shared/03103100.xhp @@ -49,16 +49,20 @@ Assigns a value to a variable. Syntax: -[Let] VarName=Expression + +[Let] VarName=Expression + Parameters: VarName: Variable that you want to assign a value to. Value and variable type must be compatible. As in most BASIC dialects, the keyword Let is optional. Example: -Sub ExampleLen -Dim sText as String -Let sText = "Las Vegas" -msgbox Len(sText) REM returns 9 -End Sub + +Sub ExampleLet +Dim sText As String + Let sText = "Las Vegas" + MsgBox Len(sText) ' returns 9 +End Sub + diff --git a/source/text/sbasic/shared/03103200.xhp b/source/text/sbasic/shared/03103200.xhp index 1f21efc8f6..e69f906e7d 100644 --- a/source/text/sbasic/shared/03103200.xhp +++ b/source/text/sbasic/shared/03103200.xhp @@ -47,14 +47,18 @@ Defines the default lower boundary for arrays as 0 or 1. Syntax: -Option Base { 0 | 1} + +Option Base { 0 | 1} + Parameters: This statement must be added before the executable program code in a module. Example: -option Base 1 -Sub ExampleOptionBase -Dim sVar(20) As String -msgbox LBound(sVar()) -end sub + +Option Base 1 +Sub ExampleOptionBase + Dim sVar(20) As String + MsgBox LBound(sVar()) +End Sub + diff --git a/source/text/sbasic/shared/03103300.xhp b/source/text/sbasic/shared/03103300.xhp index bfa8d875e7..1a3eaebad6 100644 --- a/source/text/sbasic/shared/03103300.xhp +++ b/source/text/sbasic/shared/03103300.xhp @@ -47,17 +47,21 @@ Specifies that every variable in the program code must be explicitly declared with the Dim statement. Syntax: -Option Explicit + +Option Explicit + Parameters: This statement must be added before the executable program code in a module. Example: -Option Explicit -Sub ExampleExplicit -Dim sVar As String -sVar = "Las Vegas" -For i% = 1 to 10 REM This results in a run-time error -REM -Next i% -End Sub + +Option Explicit +Sub ExampleExplicit +Dim sVar As String + sVar = "Las Vegas" + For i% = 1 To 10 ' This results in a run-time error + Rem + Next i% +End Sub + diff --git a/source/text/sbasic/shared/03103400.xhp b/source/text/sbasic/shared/03103400.xhp index b73e28bdd2..3abfc5874e 100644 --- a/source/text/sbasic/shared/03103400.xhp +++ b/source/text/sbasic/shared/03103400.xhp @@ -47,12 +47,16 @@ Dimensions a variable or an array at the module level (that is, not within a subroutine or function), so that the variable and the array are valid in all libraries and modules. Syntax: -Public VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + +Public VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + Example: -Public iPublicVar As Integer -Sub ExamplePublic -iPublicVar = iPublicVar + 1 -MsgBox iPublicVar -End sub + +Public iPublicVar As Integer +Sub ExamplePublic + iPublicVar = iPublicVar + 1 + MsgBox iPublicVar +End Sub + diff --git a/source/text/sbasic/shared/03103450.xhp b/source/text/sbasic/shared/03103450.xhp index c9e5d8e41c..be42fb0830 100644 --- a/source/text/sbasic/shared/03103450.xhp +++ b/source/text/sbasic/shared/03103450.xhp @@ -47,12 +47,16 @@ Dimensions a variable or an array at the global level (that is, not within a subroutine or function), so that the variable and the array are valid in all libraries and modules for the current session. Syntax: -Global VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + +Global VarName[(start To end)] [As VarType][, VarName2[(start To end)] [As VarType][,...]] + Example: -Global iGlobalVar As Integer -Sub ExampleGlobal -iGlobalVar = iGlobalVar + 1 -MsgBox iGlobalVar -End sub + +Global iGlobalVar As Integer +Sub ExampleGlobal + iGlobalVar = iGlobalVar + 1 + MsgBox iGlobalVar +End Sub + diff --git a/source/text/sbasic/shared/03103500.xhp b/source/text/sbasic/shared/03103500.xhp index 25abc383cb..493f800569 100644 --- a/source/text/sbasic/shared/03103500.xhp +++ b/source/text/sbasic/shared/03103500.xhp @@ -50,25 +50,30 @@ The Static statement cannot be used to define variable arrays. Arrays must be specified according to a fixed size. Syntax: -Static VarName[(start To end)] [As VarType], VarName2[(start To end)] [As VarType], ... + +Static VarName[(start To end)] [As VarType], VarName2[(start To end)] [As VarType], ... + Example: -Sub ExampleStatic -Dim iCount as Integer, iResult as Integer -For iCount = 0 to 2 -iResult = InitVar() -Next iCount -MsgBox iResult,0,"The answer is" -End Sub -REM Function for initialization of the static variable -Function InitVar() As Integer -Static iInit As Integer -Const iMinimum as Integer = 40 REM minimum return value of this function -if iInit = 0 then REM check if initialized -iInit = iMinimum -else -iInit = iInit + 1 -end if -InitVar = iInit -End Function + +Sub ExampleStatic +Dim iCount As Integer, iResult As Integer + For iCount = 0 To 2 + iResult = InitVar() + Next iCount + MsgBox iResult,0,"The answer is" +End Sub + +' Function for initialization of the static variable +Function InitVar() As Integer + Static iInit As Integer + Const iMinimum As Integer = 40 ' minimum return value of this function + If iInit = 0 Then ' check if initialized + iInit = iMinimum + Else + iInit = iInit + 1 + End If + InitVar = iInit +End Function + diff --git a/source/text/sbasic/shared/03103600.xhp b/source/text/sbasic/shared/03103600.xhp index 7f09ef0a5f..7a48f356bc 100644 --- a/source/text/sbasic/shared/03103600.xhp +++ b/source/text/sbasic/shared/03103600.xhp @@ -48,7 +48,9 @@ Returns a string (TypeName) or a numeric value (VarType) that contains information for a variable. Syntax: -TypeName (Variable)VarType (Variable) + +TypeName (Variable)VarType (Variable) + Return value: String; Integer Parameters: @@ -191,19 +193,21 @@ Example: -Sub ExampleType -Dim iVar As Integer -Dim sVar As String -Dim siVar As Single -Dim dVar As Double -Dim bVar As Boolean -Dim lVar As Long -Msgbox TypeName(iVar) & " " & VarType(iVar) & Chr(13) &_ -TypeName(sVar) & " " & VarType(sVar) & Chr(13) &_ -TypeName(siVar) & " " & VarType(siVar) & Chr(13) &_ -TypeName(dVar) & " " & VarType(dVar) & Chr(13) &_ -TypeName(bVar) & " " & VarType(bVar) & Chr(13) &_ -TypeName(lVar) & " " & VarType(lVar),0,"Some types in $[officename] Basic" -end Sub + +Sub ExampleType +Dim iVar As Integer +Dim sVar As String +Dim siVar As Single +Dim dVar As Double +Dim bVar As Boolean +Dim lVar As Long + MsgBox TypeName(iVar) & " " & VarType(iVar) & Chr(13) &_ + TypeName(sVar) & " " & VarType(sVar) & Chr(13) &_ + TypeName(siVar) & " " & VarType(siVar) & Chr(13) &_ + TypeName(dVar) & " " & VarType(dVar) & Chr(13) &_ + TypeName(bVar) & " " & VarType(bVar) & Chr(13) &_ + TypeName(lVar) & " " & VarType(lVar),0,"Some types In $[officename] Basic" +End Sub + diff --git a/source/text/sbasic/shared/03103700.xhp b/source/text/sbasic/shared/03103700.xhp index 6d7fe49280..07fa6a7352 100644 --- a/source/text/sbasic/shared/03103700.xhp +++ b/source/text/sbasic/shared/03103700.xhp @@ -48,7 +48,9 @@ Sets an object reference on a variable or a Property. Syntax: -Set ObjectVar = Object + +Set ObjectVar = Object + Parameters: ObjectVar: a variable or a property that requires an object reference. @@ -57,10 +59,12 @@ Nothing - Assign the Nothing object to a variable to remove a previous assignment. Example: -Sub ExampleSet -Dim oDoc As Object -Set oDoc = ActiveWindow -Print oDoc.Name -End Sub + +Sub ExampleSet +Dim oDoc As Object + Set oDoc = ActiveWindow + Print oDoc.Name +End Sub + diff --git a/source/text/sbasic/shared/03103800.xhp b/source/text/sbasic/shared/03103800.xhp index f592aa7387..0a53d1995f 100644 --- a/source/text/sbasic/shared/03103800.xhp +++ b/source/text/sbasic/shared/03103800.xhp @@ -60,7 +60,9 @@ "TextEdit1" to TextEdit5" in a loop to create five control names. See also: FindPropertyObject Syntax: -FindObject( ObjName As String ) + +FindObject( ObjName As String ) + Parameters: ObjName: String that specifies the name of the object that you want to address at run-time. diff --git a/source/text/sbasic/shared/03103900.xhp b/source/text/sbasic/shared/03103900.xhp index 738a06fd5f..c7b97bc661 100644 --- a/source/text/sbasic/shared/03103900.xhp +++ b/source/text/sbasic/shared/03103900.xhp @@ -60,7 +60,9 @@ "TextEdit1" to TextEdit5" in a loop to create five names. See also: FindObject Syntax: -FindPropertyObject( ObjVar, PropName As String ) + +FindPropertyObject( ObjVar, PropName As String ) + Parameters: ObjVar: Object variable that you want to dynamically define at run-time. diff --git a/source/text/sbasic/shared/03104000.xhp b/source/text/sbasic/shared/03104000.xhp index 08dfb3bc81..b541e1f973 100644 --- a/source/text/sbasic/shared/03104000.xhp +++ b/source/text/sbasic/shared/03104000.xhp @@ -48,7 +48,9 @@ See also: Optional Syntax: -IsMissing( ArgumentName ) + +IsMissing( ArgumentName ) + Parameters: ArgumentName: the name of an optional argument. diff --git a/source/text/sbasic/shared/03104100.xhp b/source/text/sbasic/shared/03104100.xhp index 14cfd9885a..beeb0ff171 100644 --- a/source/text/sbasic/shared/03104100.xhp +++ b/source/text/sbasic/shared/03104100.xhp @@ -48,7 +48,9 @@ See also: IsMissing Syntax: -Function MyFunction(Text1 As String, Optional Arg2, Optional Arg3) + +Function MyFunction(Text1 As String, Optional Arg2, Optional Arg3) + Examples: Result = MyFunction("Here", 1, "There") ' all arguments are passed. Result = MyFunction("Test", ,1) ' second argument is missing. diff --git a/source/text/sbasic/shared/03104200.xhp b/source/text/sbasic/shared/03104200.xhp index 258e10da24..841ce40c5f 100644 --- a/source/text/sbasic/shared/03104200.xhp +++ b/source/text/sbasic/shared/03104200.xhp @@ -47,8 +47,10 @@ Returns the type Variant with a data field. Syntax: -Array ( Argument list) -See also DimArray + +Array ( Argument list) + +See also DimArray Parameters: Argument list: A list of any number of arguments that are separated by commas. diff --git a/source/text/sbasic/shared/03104300.xhp b/source/text/sbasic/shared/03104300.xhp index d0b1dd4360..f1ee04de94 100644 --- a/source/text/sbasic/shared/03104300.xhp +++ b/source/text/sbasic/shared/03104300.xhp @@ -47,8 +47,10 @@ Returns a Variant array. Syntax: -DimArray ( Argument list) -See also Array + +DimArray ( Argument list) + +See also Array If no parameters are passed, an empty array is created (like Dim A() that is the same as a sequence of length 0 in Uno). If parameters are specified, a dimension is created for each parameter. Parameters: diff --git a/source/text/sbasic/shared/03104400.xhp b/source/text/sbasic/shared/03104400.xhp index 158530170f..b25326223d 100644 --- a/source/text/sbasic/shared/03104400.xhp +++ b/source/text/sbasic/shared/03104400.xhp @@ -48,7 +48,9 @@ Returns True, if all stated Uno interfaces are supported, otherwise False is returned. Syntax: -HasUnoInterfaces( oTest, Uno-Interface-Name 1 [, Uno-Interface-Name 2, ...]) + +HasUnoInterfaces( oTest, Uno-Interface-Name 1 [, Uno-Interface-Name 2, ...]) + Return value: Bool Parameters: diff --git a/source/text/sbasic/shared/03104500.xhp b/source/text/sbasic/shared/03104500.xhp index 88c8393dcf..6ba94e787c 100644 --- a/source/text/sbasic/shared/03104500.xhp +++ b/source/text/sbasic/shared/03104500.xhp @@ -47,25 +47,29 @@ Returns True if the given object is a Uno struct. Syntax: -IsUnoStruct( Uno type ) + +IsUnoStruct( Uno type ) + Return value: Bool Parameters: Uno type : A UnoObject Example: -Sub Main -Dim bIsStruct -' Instantiate a service -Dim oSimpleFileAccess -oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) -bIsStruct = IsUnoStruct( oSimpleFileAccess ) -MsgBox bIsStruct ' Displays False because oSimpleFileAccess is NO struct -' Instantiate a Property struct -Dim aProperty As New com.sun.star.beans.Property -bIsStruct = IsUnoStruct( aProperty ) -MsgBox bIsStruct ' Displays True because aProperty is a struct -bIsStruct = IsUnoStruct( 42 ) -MsgBox bIsStruct ' Displays False because 42 is NO struct -End Sub + +Sub Main +Dim bIsStruct +' Instantiate a service +Dim oSimpleFileAccess +oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) +bIsStruct = IsUnoStruct( oSimpleFileAccess ) +MsgBox bIsStruct ' Displays False because oSimpleFileAccess Is NO struct +' Instantiate a Property struct +Dim aProperty As New com.sun.star.beans.Property +bIsStruct = IsUnoStruct( aProperty ) +MsgBox bIsStruct ' Displays True because aProperty is a struct +bIsStruct = IsUnoStruct( 42 ) +MsgBox bIsStruct ' Displays False because 42 is NO struct +End Sub + diff --git a/source/text/sbasic/shared/03104600.xhp b/source/text/sbasic/shared/03104600.xhp index 0232d2d45e..37e6be2572 100644 --- a/source/text/sbasic/shared/03104600.xhp +++ b/source/text/sbasic/shared/03104600.xhp @@ -47,7 +47,9 @@ Returns True if the two specified Basic Uno objects represent the same Uno object instance. Syntax: -EqualUnoObjects( oObj1, oObj2 ) + +EqualUnoObjects( oObj1, oObj2 ) + Return value: Bool Example: diff --git a/source/text/sbasic/shared/03104700.xhp b/source/text/sbasic/shared/03104700.xhp index 6ebf6c920a..491d6cfa76 100644 --- a/source/text/sbasic/shared/03104700.xhp +++ b/source/text/sbasic/shared/03104700.xhp @@ -47,7 +47,9 @@ Erases the contents of array elements of fixed size arrays, and releases the memory used by arrays of variable size. Syntax: -Erase Arraylist + +Erase Arraylist + Parameters: Arraylist - The list of arrays to be erased. diff --git a/source/text/sbasic/shared/03110100.xhp b/source/text/sbasic/shared/03110100.xhp index c59cdbc92a..f046324d63 100644 --- a/source/text/sbasic/shared/03110100.xhp +++ b/source/text/sbasic/shared/03110100.xhp @@ -50,7 +50,9 @@ Comparison operators compare two expressions. The result is returned as a Boolean expression that determines if the comparison is True (-1) or False (0). Syntax: -Result = Expression1 { = | < | > | <= | >= } Expression2 + +Result = Expression1 { = | < | > | <= | >= } Expression2 + Parameters: Result: Boolean expression that specifies the result of the comparison (True, or False) @@ -64,17 +66,19 @@ >= : Greater than or equal to <> : Not equal to Example: -Sub ExampleUnequal -DIM sFile As String -DIM sRoot As String REM ' Root directory for file in and output -sRoot = "c:\" -sFile = Dir$( sRoot ,22) -If sFile <> "" Then -Do -Msgbox sFile -sFile = Dir$ -Loop Until sFile = "" -End If -End sub + +Sub ExampleUnequal +Dim sFile As String +Dim sRoot As String ' Root directory for file in and output + sRoot = "c:\" + sFile = Dir$( sRoot ,22) + If sFile <> "" Then + Do + MsgBox sFile + sFile = Dir$ + Loop Until sFile = "" + End If +End Sub + diff --git a/source/text/sbasic/shared/03120101.xhp b/source/text/sbasic/shared/03120101.xhp index 31a2a31677..1bca4d1f8c 100644 --- a/source/text/sbasic/shared/03120101.xhp +++ b/source/text/sbasic/shared/03120101.xhp @@ -47,7 +47,9 @@ Returns the ASCII (American Standard Code for Information Interchange) value of the first character in a string expression. Syntax: -Asc (Text As String) + +Asc (Text As String) + Return value: Integer Parameters: @@ -57,11 +59,13 @@ Example: -Sub ExampleASC -Print ASC("A") REM returns 65 -Print ASC("Z") REM returns 90 -Print ASC("Las Vegas") REM returns 76, since only the first character is taken into account -End Sub + +Sub ExampleASC + Print ASC("A") ' returns 65 + Print ASC("Z") ' returns 90 + Print ASC("Las Vegas") ' returns 76, since only the first character is taken into account +End Sub +
CHR
diff --git a/source/text/sbasic/shared/03120102.xhp b/source/text/sbasic/shared/03120102.xhp index 590668b1ad..323ba1d015 100644 --- a/source/text/sbasic/shared/03120102.xhp +++ b/source/text/sbasic/shared/03120102.xhp @@ -47,7 +47,9 @@ Returns the character that corresponds to the specified character code. Syntax: -Chr(Expression As Integer) + +Chr(Expression As Integer) + Return value: String Parameters: @@ -57,11 +59,13 @@ Example: -sub ExampleChr -REM This example inserts quotation marks (ASCII value 34) in a string. -MsgBox "A "+ Chr$(34)+"short" + Chr$(34)+" trip." -REM The printout appears in the dialog as: A "short" trip. -end sub + +Sub ExampleChr + ' This example inserts quotation marks (ASCII value 34) in a string. + MsgBox "A "+ Chr$(34)+"short" + Chr$(34)+" trip." + ' The printout appears in the dialog as: A "short" trip. +End Sub +
ASC
diff --git a/source/text/sbasic/shared/03120103.xhp b/source/text/sbasic/shared/03120103.xhp index 725610b571..3bff4fd088 100644 --- a/source/text/sbasic/shared/03120103.xhp +++ b/source/text/sbasic/shared/03120103.xhp @@ -47,7 +47,9 @@ Converts a numeric expression into a string. Syntax: -Str (Expression) + +Str (Expression) + Return value: String Parameters: @@ -57,12 +59,14 @@ Example: -Sub ExampleStr -Dim iVar As Single -Dim sVar As String -iVar = 123.123 -sVar = LTrim(Str(iVar)) -Msgbox sVar & chr(13) & Str(iVar) -end sub + +Sub ExampleStr +Dim iVar As Single +Dim sVar As String + iVar = 123.123 + sVar = LTrim(Str(iVar)) + MsgBox sVar & chr(13) & Str(iVar) +End Sub + diff --git a/source/text/sbasic/shared/03120104.xhp b/source/text/sbasic/shared/03120104.xhp index 4053a9a5d8..1332655fcb 100644 --- a/source/text/sbasic/shared/03120104.xhp +++ b/source/text/sbasic/shared/03120104.xhp @@ -47,7 +47,9 @@ Converts a string to a numeric expression. Syntax: -Val (Text As String) + +Val (Text As String) + Return value: Double Parameters: @@ -57,9 +59,11 @@ Example: -Sub ExampleVal -msgbox Val("123.123") -msgbox Val("A123.123") -end Sub + +Sub ExampleVal + MsgBox Val("123.123") + MsgBox Val("A123.123") +End Sub + diff --git a/source/text/sbasic/shared/03120105.xhp b/source/text/sbasic/shared/03120105.xhp index e7594f0514..8653ddd195 100644 --- a/source/text/sbasic/shared/03120105.xhp +++ b/source/text/sbasic/shared/03120105.xhp @@ -47,7 +47,9 @@ Converts a string or a numeric expression to the type Byte. Syntax: -Cbyte( expression ) + +Cbyte( expression ) + Return value: Byte Parameters: diff --git a/source/text/sbasic/shared/03120201.xhp b/source/text/sbasic/shared/03120201.xhp index 128cdf3620..368382f785 100644 --- a/source/text/sbasic/shared/03120201.xhp +++ b/source/text/sbasic/shared/03120201.xhp @@ -47,7 +47,9 @@ Returns a string that consists of a specified amount of spaces. Syntax: -Space (n As Long) + +Space (n As Long) + Return value: String Parameters: @@ -56,15 +58,17 @@ Example: -Sub ExampleSpace -Dim sText As String,sOut As String -DIm iLen As Integer -iLen = 10 -sText = "Las Vegas" -sOut = sText & Space(iLen) & sText & Chr(13) &_ -sText & Space(iLen*2) & sText & Chr(13) &_ -sText & Space(iLen*4) & sText & Chr(13) -msgBox sOut,0,"Info:" -End Sub + +Sub ExampleSpace +Dim sText As String,sOut As String +Dim iLen As Integer + iLen = 10 + sText = "Las Vegas" + sOut = sText & Space(iLen) & sText & Chr(13) &_ + sText & Space(iLen*2) & sText & Chr(13) &_ + sText & Space(iLen*4) & sText & Chr(13) + MsgBox sOut,0,"Info:" +End Sub + diff --git a/source/text/sbasic/shared/03120202.xhp b/source/text/sbasic/shared/03120202.xhp index 249fe5004b..5cfd9bd9bb 100644 --- a/source/text/sbasic/shared/03120202.xhp +++ b/source/text/sbasic/shared/03120202.xhp @@ -47,7 +47,9 @@ Creates a string according to the specified character, or the first character of a string expression that is passed to the function. Syntax: -String (n As Long, {expression As Integer | character As String}) + +String (n As Long, {expression As Integer | character As String}) + Return value: String Parameters: @@ -60,12 +62,14 @@ Example: -Sub ExampleString -Dim sText as String -sText = String(10,"A") -Msgbox sText -sText = String(10,65) -Msgbox sText -End Sub + +Sub ExampleString +Dim sText As String + sText = String(10,"A") + MsgBox sText + sText = String(10,65) + MsgBox sText +End Sub + diff --git a/source/text/sbasic/shared/03120301.xhp b/source/text/sbasic/shared/03120301.xhp index f5435495f2..c4fc48ba63 100644 --- a/source/text/sbasic/shared/03120301.xhp +++ b/source/text/sbasic/shared/03120301.xhp @@ -47,7 +47,9 @@ Converts a number to a string, and then formats it according to the format that you specify. Syntax: -Format (Number [, Format As String]) + +Format (Number [, Format As String]) + Return value: String Parameters: @@ -100,10 +102,12 @@ Example: -Sub ExampleFormat -MsgBox Format(6328.2, "##,##0.00")Translators: do not change the decimal point in 6328.2, and do not change "##,##0.00" because BASIC uses US notation in all locales. -REM always use a period as decimal delimiter when you enter numbers in Basic source code. -REM displays for example 6,328.20 in English locale, 6.328,20 in German locale. -End Sub + +Sub ExampleFormat + MsgBox Format(6328.2, "##,##0.00") + ' always use a period as decimal delimiter when you enter numbers in Basic source code. + ' displays for example 6,328.20 in English locale, 6.328,20 in German locale. +End Sub + diff --git a/source/text/sbasic/shared/03120302.xhp b/source/text/sbasic/shared/03120302.xhp index a4eb0af31f..69e3a6684d 100644 --- a/source/text/sbasic/shared/03120302.xhp +++ b/source/text/sbasic/shared/03120302.xhp @@ -48,7 +48,9 @@ See also: UCase Function Syntax: -LCase (Text As String) + +LCase (Text As String) + Return value: String Parameters: @@ -57,11 +59,13 @@ Example: -Sub ExampleLUCase -Dim sVar As String -sVar = "Las Vegas" -Print LCase(sVar) REM Returns "las vegas" -Print UCase(sVar) REM Returns "LAS VEGAS" -end Sub + +Sub ExampleLUCase +Dim sVar As String + sVar = "Las Vegas" + Print LCase(sVar) ' Returns "las vegas" + Print UCase(sVar) ' Returns "LAS VEGAS" +End Sub + diff --git a/source/text/sbasic/shared/03120303.xhp b/source/text/sbasic/shared/03120303.xhp index a96828cee1..5ee9ba2ecb 100644 --- a/source/text/sbasic/shared/03120303.xhp +++ b/source/text/sbasic/shared/03120303.xhp @@ -47,7 +47,9 @@ Returns the number of leftmost characters that you specify of a string expression. Syntax: -Left (Text As String, n As Long) + +Left (Text As String, n As Long) + Return value: String Parameters: @@ -59,16 +61,18 @@ Example: -Sub ExampleUSDate -Dim sInput As String -Dim sUS_date As String -sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") -sUS_date = Mid(sInput, 6, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Right(sInput, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Left(sInput, 4) -MsgBox sUS_date -End Sub + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + diff --git a/source/text/sbasic/shared/03120304.xhp b/source/text/sbasic/shared/03120304.xhp index d4ac846723..a1deb22e9f 100644 --- a/source/text/sbasic/shared/03120304.xhp +++ b/source/text/sbasic/shared/03120304.xhp @@ -47,7 +47,9 @@ Aligns a string to the left of a string variable, or copies a variable of a user-defined type to another variable of a different user-defined type. Syntax: -LSet Var As String = Text or LSet Var1 = Var2 + +LSet Var As String = Text or LSet Var1 = Var2 + Parameters: Var: Any String variable that contains the string that you want align to the left. @@ -59,28 +61,30 @@ Var2: Name of the user-defined type variable that you want to copy from.
If the string is shorter than the string variable, LSet left-aligns the string within the string variable. Any remaining positions in the string variable are replaced by spaces. If the string is longer than the string variable, only the leftmost characters up to the length of the string variable are copied. With the LSet statement, you can also copy a user-defined type variable to another variable of the same type. Example: -Sub ExampleRLSet -Dim sVar As String -Dim sExpr As String -sVar = String(40,"*") -sExpr = "SBX" -REM Align "SBX" within the 40-character reference string -REM Replace asterisks with spaces -RSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(5,"*") -sExpr = "123457896" -RSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(40,"*") -sExpr = "SBX" -REM Left-align "SBX" within the 40-character reference string -LSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(5,"*") -sExpr = "123456789" -LSet sVar = sExpr -Print ">"; sVar; "<" -End Sub + +Sub ExampleRLSet +Dim sVar As String +Dim sExpr As String + sVar = String(40,"*") + sExpr = "SBX" + ' Align "SBX" within the 40-character reference string + ' Replace asterisks with spaces + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123457896" + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(40,"*") + sExpr = "SBX" + ' Left-align "SBX" within the 40-character reference string + LSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123456789" + LSet sVar = sExpr + Print ">"; sVar; "<" +End Sub + diff --git a/source/text/sbasic/shared/03120305.xhp b/source/text/sbasic/shared/03120305.xhp index 90b9e7e36c..41e3f37979 100644 --- a/source/text/sbasic/shared/03120305.xhp +++ b/source/text/sbasic/shared/03120305.xhp @@ -47,7 +47,9 @@ Removes all leading spaces at the start of a string expression. Syntax: -LTrim (Text As String) + +LTrim (Text As String) + Return value: String Parameters: @@ -57,17 +59,19 @@ Example: -Sub ExampleSpaces -Dim sText2 As String,sText As String,sOut As String -sText2 = " <*Las Vegas*> " -sOut = "'"+sText2 +"'"+ Chr(13) -sText = Ltrim(sText2) REM sText = "<*Las Vegas*> " -sOut = sOut + "'"+sText +"'" + Chr(13) -sText = Rtrim(sText2) REM sText = " <*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" + Chr(13) -sText = Trim(sText2) REM sText = "<*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" -MsgBox sOut -end sub + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + diff --git a/source/text/sbasic/shared/03120306.xhp b/source/text/sbasic/shared/03120306.xhp index 7c92a96c03..26b3f0dc15 100644 --- a/source/text/sbasic/shared/03120306.xhp +++ b/source/text/sbasic/shared/03120306.xhp @@ -48,7 +48,9 @@ Returns the specified portion of a string expression (Mid function), or replaces the portion of a string expression with another string (Mid statement). Syntax: -Mid (Text As String, Start As Long [, Length As Long]) or Mid (Text As String, Start As Long , Length As Long, Text As String) + +Mid (Text As String, Start As Long [, Length As Long]) or Mid (Text As String, Start As Long , Length As Long, Text As String) + Return value: String (only by Function) Parameters: @@ -65,16 +67,18 @@ Example: -Sub ExampleUSDate -Dim sInput As String -Dim sUS_date As String -sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") -sUS_date = Mid(sInput, 6, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Right(sInput, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Left(sInput, 4) -MsgBox sUS_date -End Sub + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + diff --git a/source/text/sbasic/shared/03120307.xhp b/source/text/sbasic/shared/03120307.xhp index 88bd2d6dc5..3e148d0792 100644 --- a/source/text/sbasic/shared/03120307.xhp +++ b/source/text/sbasic/shared/03120307.xhp @@ -48,7 +48,9 @@ See also: Left Function. Syntax: -Right (Text As String, n As Long) + +Right (Text As String, n As Long) + Return value: String Parameters: @@ -60,16 +62,18 @@ Example: -Sub ExampleUSDate -Dim sInput As String -Dim sUS_date As String -sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") -sUS_date = Mid(sInput, 6, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Right(sInput, 2) -sUS_date = sUS_date & "/" -sUS_date = sUS_date & Left(sInput, 4) -MsgBox sUS_date -End Sub + +Sub ExampleUSDate +Dim sInput As String +Dim sUS_date As String + sInput = InputBox("Please input a date in the international format 'YYYY-MM-DD'") + sUS_date = Mid(sInput, 6, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Right(sInput, 2) + sUS_date = sUS_date & "/" + sUS_date = sUS_date & Left(sInput, 4) + MsgBox sUS_date +End Sub + diff --git a/source/text/sbasic/shared/03120308.xhp b/source/text/sbasic/shared/03120308.xhp index 3fcea46178..4f92d7e490 100644 --- a/source/text/sbasic/shared/03120308.xhp +++ b/source/text/sbasic/shared/03120308.xhp @@ -47,7 +47,9 @@ Right-aligns a string within a string variable, or copies a user-defined variable type into another. Syntax: -RSet Text As String = Text or RSet Variable1 = Variable2 + +RSet Text As String = Text or RSet Variable1 = Variable2 + Parameters: Text: Any string variable. @@ -61,28 +63,30 @@ You can also use the RSet statement to assign variables of one user-defined type to another. The following example uses the RSet and LSet statements to modify the left and right alignment of a string. Example: -Sub ExampleRLSet -Dim sVar as string -Dim sExpr as string -sVar = String(40,"*") -sExpr = "SBX" -REM Right-align "SBX" in a 40-character string -REM Replace asterisks with spaces -RSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(5,"*") -sExpr = "123457896" -RSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(40,"*") -sExpr = "SBX" -REM Left-align "SBX" in a 40-character string -LSet sVar = sExpr -Print ">"; sVar; "<" -sVar = String(5,"*") -sExpr = "123456789" -LSet sVar = sExpr -Print ">"; sVar; "<" -End Sub + +Sub ExampleRLSet +Dim sVar As String +Dim sExpr As String + sVar = String(40,"*") + sExpr = "SBX" + ' Right-align "SBX" in a 40-character string + ' Replace asterisks with spaces + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123457896" + RSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(40,"*") + sExpr = "SBX" + ' Left-align "SBX" in a 40-character string + LSet sVar = sExpr + Print ">"; sVar; "<" + sVar = String(5,"*") + sExpr = "123456789" + LSet sVar = sExpr + Print ">"; sVar; "<" +End Sub + diff --git a/source/text/sbasic/shared/03120309.xhp b/source/text/sbasic/shared/03120309.xhp index cfdc43abe5..9d958c76b3 100644 --- a/source/text/sbasic/shared/03120309.xhp +++ b/source/text/sbasic/shared/03120309.xhp @@ -48,7 +48,9 @@ See also: LTrim Function Syntax: -RTrim (Text As String) + +RTrim (Text As String) + Return value: String Parameters: @@ -57,17 +59,19 @@ Example: -Sub ExampleSpaces -Dim sText2 as String,sText as String,sOut as String -sText2 = " <*Las Vegas*> " -sOut = "'"+sText2 +"'"+ Chr(13) -sText = Ltrim(sText2) REM sText = "<*Las Vegas*> " -sOut = sOut + "'"+sText +"'" + Chr(13) -sText = Rtrim(sText2) REM sText = " <*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" + Chr(13) -sText = Trim(sText2) REM sText = "<*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" -MsgBox sOut -end sub + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + diff --git a/source/text/sbasic/shared/03120310.xhp b/source/text/sbasic/shared/03120310.xhp index 5cd4875be7..7e97b56a62 100644 --- a/source/text/sbasic/shared/03120310.xhp +++ b/source/text/sbasic/shared/03120310.xhp @@ -59,11 +59,13 @@ Example: -Sub ExampleLUCase -Dim sVar As String -sVar = "Las Vegas" -Print LCase(sVar) REM returns "las vegas" -Print UCase(sVar) REM returns "LAS VEGAS" -end Sub + +Sub ExampleLUCase +Dim sVar As String + sVar = "Las Vegas" + Print LCase(sVar) ' returns "las vegas" + Print UCase(sVar) ' returns "LAS VEGAS" +End Sub + diff --git a/source/text/sbasic/shared/03120311.xhp b/source/text/sbasic/shared/03120311.xhp index 367c2ed9d8..ed0e4d0a40 100644 --- a/source/text/sbasic/shared/03120311.xhp +++ b/source/text/sbasic/shared/03120311.xhp @@ -48,7 +48,9 @@ dedr: fixed #i30791# Removes all leading and trailing spaces from a string expression. Syntax: -Trim( Text As String ) + +Trim( Text As String ) + Return value: String Parameters: @@ -57,17 +59,19 @@ dedr: fixed #i30791# Example: -Sub ExampleSpaces -Dim sText2 as String,sText as String,sOut as String -sText2 = " <*Las Vegas*> " -sOut = "'"+sText2 +"'"+ Chr(13) -sText = Ltrim(sText2) REM sText = "<*Las Vegas*> " -sOut = sOut + "'"+sText +"'" + Chr(13) -sText = Rtrim(sText2) REM sText = " <*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" + Chr(13) -sText = Trim(sText2) REM sText = "<*Las Vegas*>" -sOut = sOut +"'"+ sText +"'" -MsgBox sOut -end sub + +Sub ExampleSpaces +Dim sText2 As String,sText As String,sOut As String + sText2 = " <*Las Vegas*> " + sOut = "'"+sText2 +"'"+ Chr(13) + sText = Ltrim(sText2) ' sText = "<*Las Vegas*> " + sOut = sOut + "'"+sText +"'" + Chr(13) + sText = Rtrim(sText2) ' sText = " <*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + Chr(13) + sText = Trim(sText2) ' sText = "<*Las Vegas*>" + sOut = sOut +"'"+ sText +"'" + MsgBox sOut +End Sub + diff --git a/source/text/sbasic/shared/03120312.xhp b/source/text/sbasic/shared/03120312.xhp index 0c610ab041..8e94dabb95 100644 --- a/source/text/sbasic/shared/03120312.xhp +++ b/source/text/sbasic/shared/03120312.xhp @@ -47,7 +47,9 @@ Converts a system file name to a file URL. Syntax: -ConvertToURL(filename) + +ConvertToURL(filename) + Return value: String Parameters: diff --git a/source/text/sbasic/shared/03120313.xhp b/source/text/sbasic/shared/03120313.xhp index dbf641cae3..b10773083e 100644 --- a/source/text/sbasic/shared/03120313.xhp +++ b/source/text/sbasic/shared/03120313.xhp @@ -47,7 +47,9 @@ Converts a file URL to a system file name. Syntax: -ConvertFromURL(filename) + +ConvertFromURL(filename) + Return value: String Parameters: diff --git a/source/text/sbasic/shared/03120314.xhp b/source/text/sbasic/shared/03120314.xhp index fcd61b6598..17b84ea1de 100644 --- a/source/text/sbasic/shared/03120314.xhp +++ b/source/text/sbasic/shared/03120314.xhp @@ -47,7 +47,9 @@ Returns an array of substrings from a string expression. Syntax: -Split (Text As String, delimiter, number) + +Split (Text As String, delimiter, number) + Return value: String Parameters: @@ -59,40 +61,47 @@ number (optional): The number of substrings that you want to return.
Example:
-Dim a(3) -Sub main() - a(0) = "ABCDE" - a(1) = 42 - a(2) = "MN" - a(3) = "X Y Z" - JStr = Join1() - Call Show(JStr, Split1(JStr)) - JStr = Join2() - Call Show(JStr, Split1(JStr)) - JStr = Join3() - Call Show(JStr, Split1(JStr)) -End Sub -Function Join1() - Join1 = Join(a(), "abc") -End Function -Function Join2() - Join2 = Join(a(), ",") -End Function -Function Join3() - Join3 = Join(a()) -End Function -Function Split1(aStr) - Split1 = Split(aStr, "D") -End Function -Sub Show(JoinStr, TheArray) - l = LBound(TheArray) - u = UBound(TheArray) - total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13) - For i = l To u - total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13) - Next i - MsgBox total$ -End Sub + +Dim a(3) +Sub main() + a(0) = "ABCDE" + a(1) = 42 + a(2) = "MN" + a(3) = "X Y Z" + JStr = Join1() + Call Show(JStr, Split1(JStr)) + JStr = Join2() + Call Show(JStr, Split1(JStr)) + JStr = Join3() + Call Show(JStr, Split1(JStr)) +End Sub + +Function Join1() + Join1 = Join(a(), "abc") +End Function + +Function Join2() + Join2 = Join(a(), ",") +End Function + +Function Join3() + Join3 = Join(a()) +End Function + +Function Split1(aStr) + Split1 = Split(aStr, "D") +End Function + +Sub Show(JoinStr, TheArray) + l = LBound(TheArray) + u = UBound(TheArray) + total$ = "=============================" + Chr$(13) + JoinStr + Chr$(13) + Chr$(13) + For i = l To u + total$ = total$ + TheArray(i) + Str(Len(TheArray(i))) + Chr$(13) + Next i + MsgBox total$ +End Sub +
diff --git a/source/text/sbasic/shared/03120315.xhp b/source/text/sbasic/shared/03120315.xhp index 35b8e37fa8..c2cef0bb9e 100644 --- a/source/text/sbasic/shared/03120315.xhp +++ b/source/text/sbasic/shared/03120315.xhp @@ -47,7 +47,9 @@ Returns a string from a number of substrings in a string array. Syntax: -Join (Text As String Array, delimiter) + +Join (Text As String Array, delimiter) + Return value: String Parameters: diff --git a/source/text/sbasic/shared/03120401.xhp b/source/text/sbasic/shared/03120401.xhp index 7595415613..768208ada9 100644 --- a/source/text/sbasic/shared/03120401.xhp +++ b/source/text/sbasic/shared/03120401.xhp @@ -49,7 +49,9 @@ DEDR: Reviewed The Instr function returns the position at which the match was found. If the string was not found, the function returns 0. Syntax: -InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare]) + +InStr ([Start As Long,] Text1 As String, Text2 As String[, Compare]) + Return value: Integer Parameters: @@ -65,12 +67,14 @@ DEDR: Reviewed Example: -Sub ExamplePosition -Dim sInput As String -Dim iPos as Integer -sInput = "Office" -iPos = Instr(sInput,"c") -print iPos -end sub + +Sub ExamplePosition +Dim sInput As String +Dim iPos As Integer + sInput = "Office" + iPos = Instr(sInput,"c") + Print iPos +End Sub + diff --git a/source/text/sbasic/shared/03120402.xhp b/source/text/sbasic/shared/03120402.xhp index 988ea73da9..e6080f6d18 100644 --- a/source/text/sbasic/shared/03120402.xhp +++ b/source/text/sbasic/shared/03120402.xhp @@ -47,7 +47,9 @@ Returns the number of characters in a string, or the number of bytes that are required to store a variable. Syntax: -Len (Text As String) + +Len (Text As String) + Return value: Long Parameters: diff --git a/source/text/sbasic/shared/03120403.xhp b/source/text/sbasic/shared/03120403.xhp index 6b6a17acd5..57921aeffc 100644 --- a/source/text/sbasic/shared/03120403.xhp +++ b/source/text/sbasic/shared/03120403.xhp @@ -47,7 +47,9 @@ Compares two strings and returns an integer value that represents the result of the comparison. Syntax: -StrComp (Text1 As String, Text2 As String[, Compare]) + +StrComp (Text1 As String, Text2 As String[, Compare]) + Return value: Integer Parameter: @@ -72,12 +74,14 @@ Example: -Sub ExampleStrComp -Dim iVar As Single -Dim sVar As String -iVar = 123.123 -sVar = Str$(iVar) -Msgbox strcomp(sVar , Str$(iVar),1) -end sub + +Sub ExampleStrComp +Dim iVar As Single +Dim sVar As String + iVar = 123.123 + sVar = Str$(iVar) + MsgBox strcomp(sVar , Str$(iVar),1) +End Sub + diff --git a/source/text/sbasic/shared/03130100.xhp b/source/text/sbasic/shared/03130100.xhp index ed8f29dd21..702f76313d 100644 --- a/source/text/sbasic/shared/03130100.xhp +++ b/source/text/sbasic/shared/03130100.xhp @@ -47,7 +47,9 @@ Plays a tone through the computer's speaker. The tone is system-dependent and you cannot modify its volume or pitch. Syntax: -Beep + +Beep + Example: diff --git a/source/text/sbasic/shared/03130500.xhp b/source/text/sbasic/shared/03130500.xhp index 82ac7a14f9..fa23c2b1b1 100644 --- a/source/text/sbasic/shared/03130500.xhp +++ b/source/text/sbasic/shared/03130500.xhp @@ -121,8 +121,10 @@ Example -Sub ExampleShellForWin - Shell("c:\windows\calc.exe",2) -end sub + +Sub ExampleShellForWin + Shell("c:\windows\calc.exe",2) +End Sub + diff --git a/source/text/sbasic/shared/03130600.xhp b/source/text/sbasic/shared/03130600.xhp index 66dd9b73f0..0bf0488382 100644 --- a/source/text/sbasic/shared/03130600.xhp +++ b/source/text/sbasic/shared/03130600.xhp @@ -47,7 +47,9 @@ Interrupts the program execution for the amount of time that you specify in milliseconds. Syntax: -Wait millisec + +Wait millisec + Parameters: millisec: Numeric expression that contains the amount of time (in milliseconds) to wait before the program is executed. diff --git a/source/text/sbasic/shared/03130700.xhp b/source/text/sbasic/shared/03130700.xhp index da0b5f6cc7..f2fc91d7ea 100644 --- a/source/text/sbasic/shared/03130700.xhp +++ b/source/text/sbasic/shared/03130700.xhp @@ -47,18 +47,22 @@ Returns the number of system ticks provided by the operating system. You can use this function to optimize certain processes. Syntax: -GetSystemTicks() + +GetSystemTicks() + Return value: Long Example: -Sub ExampleWait -Dim lTick As Long -lTick = GetSystemTicks() -wait 2000 -lTick = (GetSystemTicks() - lTick) -MsgBox "" & lTick & " Ticks" ,0,"The pause lasted" -End Sub + +Sub ExampleWait +Dim lTick As Long + lTick = GetSystemTicks() + Wait 2000 + lTick = (GetSystemTicks() - lTick) + MsgBox "" & lTick & " Ticks" ,0,"The pause lasted" +End Sub + diff --git a/source/text/sbasic/shared/03130800.xhp b/source/text/sbasic/shared/03130800.xhp index d0590c2309..7e7d7ce242 100644 --- a/source/text/sbasic/shared/03130800.xhp +++ b/source/text/sbasic/shared/03130800.xhp @@ -47,7 +47,9 @@ Returns the value of an environment variable as a string. Environment variables are dependent on the type of operating system that you have. Syntax: -Environ (Environment As String) + +Environ (Environment As String) + Return value: String Parameters: @@ -55,11 +57,13 @@ Example: -Sub ExampleEnviron -Dim sTemp As String -sTemp=Environ ("TEMP") -If sTemp = "" Then sTemp=Environ("TMP") -MsgBox "'" & sTemp & "'" ,64,"Directory of temporary files:" -End Sub + +Sub ExampleEnviron +Dim sTemp As String + sTemp=Environ ("TEMP") + If sTemp = "" Then sTemp=Environ("TMP") + MsgBox "'" & sTemp & "'" ,64,"Directory of temporary files:" +End Sub + diff --git a/source/text/sbasic/shared/03131000.xhp b/source/text/sbasic/shared/03131000.xhp index 286021e969..3da86ecadf 100644 --- a/source/text/sbasic/shared/03131000.xhp +++ b/source/text/sbasic/shared/03131000.xhp @@ -47,14 +47,18 @@ Returns the internal number of the current $[officename] version. Syntax: -s = GetSolarVersion + +s = GetSolarVersion + Return value: String Example: -Sub ExampleGetSolarVersion -Dim sSep As String -sSep = GetSolarVersion -MsgBox sSep,64,"Version number of the solar technology" -End Sub + +Sub ExampleGetSolarVersion +Dim sSep As String + sSep = GetSolarVersion + MsgBox sSep,64,"Version number of the solar technology" +End Sub + diff --git a/source/text/sbasic/shared/03131300.xhp b/source/text/sbasic/shared/03131300.xhp index 01d730012d..ea32934522 100644 --- a/source/text/sbasic/shared/03131300.xhp +++ b/source/text/sbasic/shared/03131300.xhp @@ -47,12 +47,16 @@ Returns the number of twips that represent the width of a pixel. Syntax: -n = TwipsPerPixelX + +n = TwipsPerPixelX + Return value: Integer Example: -Sub ExamplePixelTwips -MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" -End Sub + +Sub ExamplePixelTwips + MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" +End Sub + diff --git a/source/text/sbasic/shared/03131400.xhp b/source/text/sbasic/shared/03131400.xhp index 35d90c75b6..e7fbbfc9ff 100644 --- a/source/text/sbasic/shared/03131400.xhp +++ b/source/text/sbasic/shared/03131400.xhp @@ -47,12 +47,16 @@ Returns the number of twips that represent the height of a pixel. Syntax: -n = TwipsPerPixelY + +n = TwipsPerPixelY + Return value: Integer Example: -Sub ExamplePixelTwips -MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" -End Sub + +Sub ExamplePixelTwips + MsgBox "" & TwipsPerPixelX() & " Twips * " & TwipsPerPixelY() & " Twips",0,"Pixel size" +End Sub + diff --git a/source/text/sbasic/shared/03131500.xhp b/source/text/sbasic/shared/03131500.xhp index a20e071e64..bca10c3412 100644 --- a/source/text/sbasic/shared/03131500.xhp +++ b/source/text/sbasic/shared/03131500.xhp @@ -49,7 +49,9 @@ Use the following structure for your statement: Dim oStruct as new com.sun.star.beans.Property Syntax: -oStruct = CreateUnoStruct( Uno type name ) + +oStruct = CreateUnoStruct( Uno type name ) + Example: oStruct = CreateUnoStruct( "com.sun.star.beans.Property" ) diff --git a/source/text/sbasic/shared/03131600.xhp b/source/text/sbasic/shared/03131600.xhp index 31bac2e975..d5d216dd4e 100644 --- a/source/text/sbasic/shared/03131600.xhp +++ b/source/text/sbasic/shared/03131600.xhp @@ -48,23 +48,28 @@ dedr: reviewed Instantiates a Uno service with the ProcessServiceManager. Syntax: -oService = CreateUnoService( Uno service name ) -For a list of available services, go to: http://api.libreoffice.org/docs/common/ref/com/sun/star/module-ix.html + +oService = CreateUnoService( Uno service name ) + +For a list of available services, go to: http://api.libreoffice.org/docs/common/ref/com/sun/star/module-ix.html Examples: oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) filepicker;API service The following code uses a service to open a file open dialog: -Sub Main -fName = FileOpenDialog ("Please select a file") -print "file chosen: "+fName -End Sub -function FileOpenDialog(title as String) as String -filepicker = createUnoService("com.sun.star.ui.dialogs.FilePicker") -filepicker.Title = title -filepicker.execute() -files = filepicker.getFiles() -FileOpenDialog=files(0) -End function + +Sub Main + fName = FileOpenDialog ("Please select a file") + Print "file chosen: "+fName +End Sub + +Function FileOpenDialog(title As String) As String + filepicker = createUnoService("com.sun.star.ui.dialogs.FilePicker") + filepicker.Title = title + filepicker.execute() + files = filepicker.getFiles() + FileOpenDialog=files(0) +End Function + diff --git a/source/text/sbasic/shared/03131700.xhp b/source/text/sbasic/shared/03131700.xhp index e01f900ecb..303b5952d9 100644 --- a/source/text/sbasic/shared/03131700.xhp +++ b/source/text/sbasic/shared/03131700.xhp @@ -49,7 +49,9 @@ This function is required when you want to instantiate a service using CreateInstanceWithArguments. Syntax: -oServiceManager = GetProcessServiceManager() + +oServiceManager = GetProcessServiceManager() + Example: oServiceManager = GetProcessServiceManager() oIntrospection = oServiceManager.createInstance("com.sun.star.beans.Introspection"); diff --git a/source/text/sbasic/shared/03131800.xhp b/source/text/sbasic/shared/03131800.xhp index 86f5893aeb..a6dc7cfcb5 100644 --- a/source/text/sbasic/shared/03131800.xhp +++ b/source/text/sbasic/shared/03131800.xhp @@ -49,7 +49,9 @@ Dialogs are defined in the dialog libraries. To display a dialog, a "live" dialog must be created from the library. See Examples. Syntax: -CreateUnoDialog( oDlgDesc ) + +CreateUnoDialog( oDlgDesc ) + Example: ' Get dialog description from the dialog library oDlgDesc = DialogLibraries.Standard.Dialog1 diff --git a/source/text/sbasic/shared/03131900.xhp b/source/text/sbasic/shared/03131900.xhp index 64acd20e27..ab3a948baa 100644 --- a/source/text/sbasic/shared/03131900.xhp +++ b/source/text/sbasic/shared/03131900.xhp @@ -72,7 +72,9 @@ Both LibraryContainers exist in an application level and within every document. In the document Basic, the document's LibraryContainers are called automatically. If you want to call the global LibraryContainers from within a document, you must use the keyword GlobalScope. Syntax: -GlobalScope + +GlobalScope + Example: Example in the document Basic ' calling Dialog1 in the document library Standard diff --git a/source/text/sbasic/shared/03132000.xhp b/source/text/sbasic/shared/03132000.xhp index edaaa28088..b569b94c9b 100644 --- a/source/text/sbasic/shared/03132000.xhp +++ b/source/text/sbasic/shared/03132000.xhp @@ -49,16 +49,22 @@ dedr: fixed #i31078# Many Uno interfaces let you register listeners on a special listener interface. This allows you to listen for specific events and call up the appropriate listener method. The CreateUnoListener function waits for the called listener interface and then passes the interface an object that the interface supports. This object is then passed to the method to register the listener. Syntax: -oListener = CreateUnoListener( Prefixname, ListenerInterfaceName ) + +oListener = CreateUnoListener( Prefixname, ListenerInterfaceName ) + Example: The following example is based on a Basic library object. -Dim oListener -oListener = CreateUnoListener( "ContListener_","com.sun.star.container.XContainerListener" ) + +Dim oListener +oListener = CreateUnoListener( "ContListener_","com.sun.star.container.XContainerListener" ) + The CreateUnoListener method requires two parameters. The first is a prefix and is explained in detail below. The second parameter is the fully qualified name of the Listener interface that you want to use. The Listener must then be added to the Broadcaster Object. This is done by calling the appropriate method for adding a Listener. These methods always follow the pattern "addFooListener", where "Foo" is the Listener Interface Type, without the 'X'. In this example, the addContainerListener method is called to register the XContainerListener: -Dim oLib -oLib = BasicLibraries.Library1 ' Library1 must exist! -oLib.addContainerListener( oListener ) ' Register the listener + +Dim oLib +oLib = BasicLibraries.Library1 ' Library1 must exist! +oLib.addContainerListener( oListener ) ' Register the listener + The Listener is now registered. When an event occurs, the corresponding Listener calls the appropriate method from the com.sun.star.container.XContainerListener Interface. The prefix calls registered Listeners from Basic-subroutines. The Basic run-time system searches for Basic-subroutines or functions that have the name "PrefixListenerMethode" and calls them when found. Otherwise, a run-time error occurs. In this example, the Listener-Interface uses the following methods: @@ -104,26 +110,33 @@ dedr: fixed #i31078# An event structure type that contains information about an event exists for every Listener type. When a Listener method is called, an instance of this event is passed to the method as a parameter. Basic Listener methods can also call these event objects, so long as the appropriate parameter is passed in the Sub declaration. For example: -Sub ContListener_disposing( oEvent ) -MsgBox "disposing" -MsgBox oEvent.Dbg_Properties -End Sub -Sub ContListener_elementInserted( oEvent ) -MsgBox "elementInserted" -MsgBox oEvent.Dbg_Properties -End Sub -Sub ContListener_elementRemoved( oEvent ) -MsgBox "elementRemoved" -MsgBox oEvent.Dbg_Properties -End Sub -Sub ContListener_elementReplaced( oEvent ) -MsgBox "elementReplaced" -MsgBox oEvent.Dbg_Properties -End Sub + +Sub ContListener_disposing( oEvent ) + MsgBox "disposing" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementInserted( oEvent ) + MsgBox "elementInserted" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementRemoved( oEvent ) + MsgBox "elementRemoved" + MsgBox oEvent.Dbg_Properties +End Sub + +Sub ContListener_elementReplaced( oEvent ) + MsgBox "elementReplaced" + MsgBox oEvent.Dbg_Properties +End Sub + You do not need to include the parameter of an event object if the object is not used: -' Minimal implementation of Sub disposing -Sub ContListener_disposing -End Sub + +' Minimal implementation of Sub disposing +Sub ContListener_disposing +End Sub + Listener methods must always be implemented to avoid Basic run-time errors. diff --git a/source/text/sbasic/shared/03132100.xhp b/source/text/sbasic/shared/03132100.xhp index e5c892d2f2..b2763ec8dd 100644 --- a/source/text/sbasic/shared/03132100.xhp +++ b/source/text/sbasic/shared/03132100.xhp @@ -46,7 +46,9 @@ This runtime function is only provided for downward compatibility to previous versions. The return value is not defined in client-server environments. Syntax: - GetGUIType() + +GetGUIType() + Return value: Integer Return values: diff --git a/source/text/sbasic/shared/03132200.xhp b/source/text/sbasic/shared/03132200.xhp index 319a976e58..6ff59999ae 100644 --- a/source/text/sbasic/shared/03132200.xhp +++ b/source/text/sbasic/shared/03132200.xhp @@ -50,15 +50,19 @@ Addresses the active component so that its properties can be read and set. ThisComponent is used from document Basic, where it represents the document the Basic belongs to. The type of object accessed by ThisComponent depends on the document type.see i60932 Syntax: -ThisComponent + +ThisComponent + Example: -Sub Main - REM updates the "Table of Contents" in a text doc - Dim allindexes, index As Object - allindexes = ThisComponent.getDocumentIndexes() - index = allindexes.getByName("Table of Contents1") - REM use the default name for Table of Contents and a 1 - index.update() -End Sub + +Sub Main +' updates the "Table of Contents" in a text doc +Dim allindexes, index As Object + allindexes = ThisComponent.getDocumentIndexes() + index = allindexes.getByName("Table of Contents1") + ' use the default name for Table of Contents and a 1 + index.update() +End Sub + diff --git a/source/text/sbasic/shared/03132300.xhp b/source/text/sbasic/shared/03132300.xhp index 51c0e87e93..09d84bf5cf 100644 --- a/source/text/sbasic/shared/03132300.xhp +++ b/source/text/sbasic/shared/03132300.xhp @@ -51,8 +51,10 @@ This object is automatically converted to an Any of the corresponding type when passed to Uno. The type must be specified by its fully qualified Uno type name. The $[officename] API frequently uses the Any type. It is the counterpart of the Variant type known from other environments. The Any type holds one arbitrary Uno type and is used in generic Uno interfaces. Syntax: -oUnoValue = CreateUnoValue( "[]byte", MyBasicValue ) to get a byte sequence. -If CreateUnoValue cannot be converted to the specified Uno type, and error occurs. For the conversion, the TypeConverter service is used. + +oUnoValue = CreateUnoValue( "[]byte", MyBasicValue ) to get a byte sequence. + +If CreateUnoValue cannot be converted to the specified Uno type, and error occurs. For the conversion, the TypeConverter service is used. This function is intended for use in situations where the default Basic to Uno type converting mechanism is insufficient. This can happen when you try to access generic Any based interfaces, such as XPropertySet::setPropertyValue( Name, Value ) or X???Container::insertBy???( ???, Value ), from $[officename] Basic. The Basic runtime does not recognize these types as they are only defined in the corresponding service. In this type of situation, $[officename] Basic chooses the best matching type for the Basic type that you want to convert. However, if the wrong type is selected, an error occurs. You use the CreateUnoValue() function to create a value for the unknown Uno type. You can also use this function to pass non-Any values, but this is not recommend. If Basic already knows the target type, using the CreateUnoValue() function will only lead to additional converting operations that slow down the Basic execution. diff --git a/source/text/sbasic/shared/03132400.xhp b/source/text/sbasic/shared/03132400.xhp index c60501d2f8..2f61d1e655 100644 --- a/source/text/sbasic/shared/03132400.xhp +++ b/source/text/sbasic/shared/03132400.xhp @@ -46,15 +46,20 @@ This method creates instances of the type that is passed as parameter. Syntax: -oObj = CreateObject( type ) + +oObj = CreateObject( type ) + Example: -Type address -Name1 as String -City as String -End Type -Sub main -myaddress = CreateObject("address") -MsgBox IsObject(myaddress) -End Sub + +Type address + Name1 As String + City As String +End Type + +Sub main + myaddress = CreateObject("address") + MsgBox IsObject(myaddress) +End Sub + -- cgit v1.2.3