From 3cb6c49b52541dd5f0c650d79a201a69415d8054 Mon Sep 17 00:00:00 2001 From: Laurent Balland-Poirier Date: Tue, 17 Jan 2017 21:15:13 +0100 Subject: Basic: beautify Examples with bascode tag Correct many examples to use tag to get colorised text Merge some identical examples in section Remove useless spaces Remove ^M at end of line with Add localize="false" for pure Basic code Add comments from Johnny_M Treat 03101700.xhp in a different commit Change-Id: I94a799ee13829ed9086127aa7d0e722ffe1dd90d Reviewed-on: https://gerrit.libreoffice.org/33240 Reviewed-by: Olivier Hallot Tested-by: Olivier Hallot (cherry picked from commit 3d5e0e547daaed4c5587d403877a04916cf23eb9) Reviewed-on: https://gerrit.libreoffice.org/37825 --- source/text/sbasic/shared/03030108.xhp | 11 ++++++----- source/text/sbasic/shared/03030201.xhp | 17 +++++++++-------- source/text/sbasic/shared/03030202.xhp | 17 +++++++++-------- source/text/sbasic/shared/03090302.xhp | 31 +++++++++++++------------------ source/text/sbasic/shared/03100400.xhp | 10 ++++++---- source/text/sbasic/shared/03100500.xhp | 13 ++----------- source/text/sbasic/shared/03100600.xhp | 13 ++----------- source/text/sbasic/shared/03100700.xhp | 4 +--- source/text/sbasic/shared/03103800.xhp | 7 ++++--- source/text/sbasic/shared/03103900.xhp | 20 ++------------------ source/text/sbasic/shared/03104100.xhp | 9 +++++---- source/text/sbasic/shared/03104200.xhp | 11 ++++++----- source/text/sbasic/shared/03104300.xhp | 7 ++++--- source/text/sbasic/shared/03104400.xhp | 7 ++++--- source/text/sbasic/shared/03104600.xhp | 23 ++++++++++++----------- source/text/sbasic/shared/03120312.xhp | 17 ++++++++++------- source/text/sbasic/shared/03120313.xhp | 10 ++-------- source/text/sbasic/shared/03131500.xhp | 7 ++++--- source/text/sbasic/shared/03131700.xhp | 15 ++++++++------- source/text/sbasic/shared/03131800.xhp | 23 +++++++++++++---------- source/text/sbasic/shared/03131900.xhp | 16 +++++++++------- source/text/sbasic/shared/03132300.xhp | 5 +---- 22 files changed, 132 insertions(+), 161 deletions(-) diff --git a/source/text/sbasic/shared/03030108.xhp b/source/text/sbasic/shared/03030108.xhp index 3e0a8f8843..26313504b4 100644 --- a/source/text/sbasic/shared/03030108.xhp +++ b/source/text/sbasic/shared/03030108.xhp @@ -1,6 +1,5 @@ - - + @@ -42,7 +41,7 @@ Syntax: -CDateFromIso(String) +CDateFromIso(String) Return value: Internal date number @@ -52,8 +51,10 @@ Example: -dateval = CDateFromIso("20021231") -dateval = CDateFromIso("2002-12-31") + + dateval = CDateFromIso("20021231") + dateval = CDateFromIso("2002-12-31") + return both 12/31/2002 in the date format of your system diff --git a/source/text/sbasic/shared/03030201.xhp b/source/text/sbasic/shared/03030201.xhp index de076c5f68..f5551ae7b1 100644 --- a/source/text/sbasic/shared/03030201.xhp +++ b/source/text/sbasic/shared/03030201.xhp @@ -1,6 +1,6 @@ - + - - + Hour Function [Runtime] @@ -47,9 +46,11 @@ returns the value 12. - Example: - Sub ExampleHour - Print "The current hour is " & Hour( Now ) - End Sub + Example: + + Sub ExampleHour + Print "The current hour is " & Hour( Now ) + End Sub + - \ No newline at end of file + diff --git a/source/text/sbasic/shared/03030202.xhp b/source/text/sbasic/shared/03030202.xhp index 385e6c4761..a03a4205b2 100644 --- a/source/text/sbasic/shared/03030202.xhp +++ b/source/text/sbasic/shared/03030202.xhp @@ -1,6 +1,6 @@ - + - - + Minute Function [Runtime] @@ -47,9 +46,11 @@ returns the value 30. - Example: - Sub ExampleMinute - MsgBox "The current minute is "& Minute(Now)& "." - end sub + Example: + + Sub ExampleMinute + MsgBox "The current minute is "& Minute(Now)& "." + End Sub + - \ No newline at end of file + diff --git a/source/text/sbasic/shared/03090302.xhp b/source/text/sbasic/shared/03090302.xhp index 7fb24ce863..f01205c395 100644 --- a/source/text/sbasic/shared/03090302.xhp +++ b/source/text/sbasic/shared/03090302.xhp @@ -1,6 +1,5 @@ - - + @@ -37,24 +36,20 @@ Continues program execution within a Sub or Function at the procedure line indicated by a label. Syntax: +see Parameters +Parameters: -see Parameters + Sub/Function + statement block + Label1 + Label2: + statement block + Exit Sub + Label1: + statement block + GoTo Label2 + End Sub/Function -Parameters: -Sub/Function -statement block - Label1 - -Label2: - -statement block -Exit Sub - -Label1: - -statement block -GoTo Label2 -End Sub/Function Use the GoTo statement to instruct $[officename] Basic to continue program execution at another place within the procedure. The position must be indicated by a label. To set a label, assign a name, and then and end it with a colon (":"). You cannot use the GoTo statement to jump out of a Sub or Function. Example: diff --git a/source/text/sbasic/shared/03100400.xhp b/source/text/sbasic/shared/03100400.xhp index ed29d8b488..9ddf766a0a 100644 --- a/source/text/sbasic/shared/03100400.xhp +++ b/source/text/sbasic/shared/03100400.xhp @@ -27,19 +27,19 @@ -
CDbl function - CDbl Function [Runtime] Converts any numerical expression or string expression to a double type.
Syntax -CDbl (Expression) + +CDbl (Expression) + Return value Double @@ -49,6 +49,7 @@ +
Example: Sub ExampleCountryConvert @@ -57,6 +58,7 @@ MsgBox CLng(1234.5678) End Sub +
-
\ No newline at end of file + diff --git a/source/text/sbasic/shared/03100500.xhp b/source/text/sbasic/shared/03100500.xhp index d1018e40df..cd09cb11f6 100644 --- a/source/text/sbasic/shared/03100500.xhp +++ b/source/text/sbasic/shared/03100500.xhp @@ -27,13 +27,11 @@ -
CInt function - CInt Function [Runtime] Converts any string or numeric expression to an integer.
@@ -52,14 +50,7 @@ -Example: - -Sub ExampleCountryConvert - MsgBox CDbl(1234.5678) - MsgBox CInt(1234.5678) - MsgBox CLng(1234.5678) -End Sub - + - \ No newline at end of file + diff --git a/source/text/sbasic/shared/03100600.xhp b/source/text/sbasic/shared/03100600.xhp index 704d5a0738..565a477e4e 100644 --- a/source/text/sbasic/shared/03100600.xhp +++ b/source/text/sbasic/shared/03100600.xhp @@ -27,13 +27,11 @@ -
CLng function - CLng Function [Runtime] Converts any string or numeric expression to a long integer.
@@ -52,14 +50,7 @@ -Example: - -Sub ExampleCountryConvert - MsgBox CDbl(1234.5678) - MsgBox CInt(1234.5678) - MsgBox CLng(1234.5678) -End Sub - + - \ No newline at end of file + diff --git a/source/text/sbasic/shared/03100700.xhp b/source/text/sbasic/shared/03100700.xhp index b79232c4de..9701014bbc 100644 --- a/source/text/sbasic/shared/03100700.xhp +++ b/source/text/sbasic/shared/03100700.xhp @@ -27,13 +27,11 @@ -
Const statement - Const Statement [Runtime] Defines a string as a constant.
@@ -60,4 +58,4 @@
- \ No newline at end of file + diff --git a/source/text/sbasic/shared/03103800.xhp b/source/text/sbasic/shared/03103800.xhp index 75400f3e92..091cc13135 100644 --- a/source/text/sbasic/shared/03103800.xhp +++ b/source/text/sbasic/shared/03103800.xhp @@ -1,6 +1,5 @@ - - + @@ -36,6 +35,7 @@ FindObject Function [Runtime] Enables an object to be addressed at run-time as a string parameter through the object name. +
For example, the following command: MyObj.Prop1.Command = 5 @@ -51,7 +51,8 @@ ObjProp.Command = 5 This allows names to be dynamically created at run-time. For example: -"TextEdit1" to TextEdit5" in a loop to create five control names. +"TextEdit1" to "TextEdit5" in a loop to create five control names. +
See also: FindPropertyObject Syntax: diff --git a/source/text/sbasic/shared/03103900.xhp b/source/text/sbasic/shared/03103900.xhp index 5ec50e594a..cffe4396f6 100644 --- a/source/text/sbasic/shared/03103900.xhp +++ b/source/text/sbasic/shared/03103900.xhp @@ -1,6 +1,5 @@ - - + @@ -36,22 +35,7 @@ FindPropertyObject Function [Runtime] Enables objects to be addressed at run-time as a string parameter using the object name. -For instance, the command: - - MyObj.Prop1.Command = 5 - -corresponds to the following command block: - -Dim ObjVar as Object -Dim ObjProp as Object -ObjName As String = "MyObj" -ObjVar = FindObject( ObjName As String ) -PropName As String = "Prop1" -ObjProp = FindPropertyObject( ObjVar, PropName As String ) -ObjProp.Command = 5 - -To dynamically create Names at run-time, use: -"TextEdit1" to TextEdit5" in a loop to create five names. + See also: FindObject Syntax: diff --git a/source/text/sbasic/shared/03104100.xhp b/source/text/sbasic/shared/03104100.xhp index af7d3e0624..7c65a5451e 100644 --- a/source/text/sbasic/shared/03104100.xhp +++ b/source/text/sbasic/shared/03104100.xhp @@ -1,6 +1,5 @@ - - + @@ -42,8 +41,10 @@ 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. + + Result = MyFunction("Here", 1, "There") ' all arguments are passed. + Result = MyFunction("Test", ,1) ' second argument is missing. + See also Examples. diff --git a/source/text/sbasic/shared/03104200.xhp b/source/text/sbasic/shared/03104200.xhp index 8aebedecde..f24dad6ca6 100644 --- a/source/text/sbasic/shared/03104200.xhp +++ b/source/text/sbasic/shared/03104200.xhp @@ -1,6 +1,5 @@ - - + @@ -45,8 +44,10 @@ Argument list: A list of any number of arguments that are separated by commas. Example: -Dim A As Variant -A = Array("Fred","Tom","Bill") -Msgbox A(2) + + Dim A As Variant + A = Array("Fred","Tom","Bill") + Msgbox A(2) + diff --git a/source/text/sbasic/shared/03104300.xhp b/source/text/sbasic/shared/03104300.xhp index 348048cc48..0ff143cd7a 100644 --- a/source/text/sbasic/shared/03104300.xhp +++ b/source/text/sbasic/shared/03104300.xhp @@ -1,6 +1,5 @@ - - + @@ -48,6 +47,8 @@ Example: -a = DimArray( 2, 2, 4 ) is the same as DIM a( 2, 2, 4 ) + + a = DimArray( 2, 2, 4 ) ' is the same as DIM a( 2, 2, 4 ) + diff --git a/source/text/sbasic/shared/03104400.xhp b/source/text/sbasic/shared/03104400.xhp index de99f743be..372affa78b 100644 --- a/source/text/sbasic/shared/03104400.xhp +++ b/source/text/sbasic/shared/03104400.xhp @@ -1,6 +1,5 @@ - - + @@ -49,6 +48,8 @@ Uno-Interface-Name: list of Uno interface names. Example: -bHas = HasUnoInterfaces( oTest, "com.sun.star.beans.XIntrospection" ) + + bHas = HasUnoInterfaces( oTest, "com.sun.star.beans.XIntrospection" ) + diff --git a/source/text/sbasic/shared/03104600.xhp b/source/text/sbasic/shared/03104600.xhp index e01a096070..e47a87feb2 100644 --- a/source/text/sbasic/shared/03104600.xhp +++ b/source/text/sbasic/shared/03104600.xhp @@ -1,6 +1,5 @@ - - + @@ -38,18 +37,20 @@ Syntax: -EqualUnoObjects( oObj1, oObj2 ) +EqualUnoObjects( oObj1, oObj2 ) Return value: Bool Example: -// Copy of objects -> same instance -oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) -oIntro2 = oIntrospection -print EqualUnoObjects( oIntrospection, oIntro2 ) -// Copy of structs as value -> new instance -Dim Struct1 as new com.sun.star.beans.Property -Struct2 = Struct1 -print EqualUnoObjects( Struct1, Struct2 ) + + ' Copy of objects -> same instance + oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" ) + oIntro2 = oIntrospection + print EqualUnoObjects( oIntrospection, oIntro2 ) + ' Copy of structs as value -> new instance + Dim Struct1 as new com.sun.star.beans.Property + Struct2 = Struct1 + print EqualUnoObjects( Struct1, Struct2 ) + diff --git a/source/text/sbasic/shared/03120312.xhp b/source/text/sbasic/shared/03120312.xhp index cfe64d3bf2..afdb523ef1 100644 --- a/source/text/sbasic/shared/03120312.xhp +++ b/source/text/sbasic/shared/03120312.xhp @@ -1,6 +1,5 @@ - - + @@ -47,11 +46,15 @@ Filename: A file name as string. +
Example: -systemFile$ = "c:\folder\mytext.txt" -url$ = ConvertToURL( systemFile$ ) -print url$ -systemFileAgain$ = ConvertFromURL( url$ ) -print systemFileAgain$ + + systemFile$ = "c:\folder\mytext.txt" + url$ = ConvertToURL( systemFile$ ) + print url$ + systemFileAgain$ = ConvertFromURL( url$ ) + print systemFileAgain$ + +
diff --git a/source/text/sbasic/shared/03120313.xhp b/source/text/sbasic/shared/03120313.xhp index e33dcf2f2a..850c486867 100644 --- a/source/text/sbasic/shared/03120313.xhp +++ b/source/text/sbasic/shared/03120313.xhp @@ -1,6 +1,5 @@ - - + @@ -47,11 +46,6 @@ Filename: A file name as a string. -Example: -systemFile$ = "c:\folder\mytext.txt" -url$ = ConvertToURL( systemFile$ ) -print url$ -systemFileAgain$ = ConvertFromURL( url$ ) -print systemFileAgain$ + diff --git a/source/text/sbasic/shared/03131500.xhp b/source/text/sbasic/shared/03131500.xhp index 9e767ceefd..535ad5ea31 100644 --- a/source/text/sbasic/shared/03131500.xhp +++ b/source/text/sbasic/shared/03131500.xhp @@ -1,6 +1,5 @@ - - + @@ -43,6 +42,8 @@ oStruct = CreateUnoStruct( Uno type name )
Example: -oStruct = CreateUnoStruct( "com.sun.star.beans.Property" ) + + oStruct = CreateUnoStruct( "com.sun.star.beans.Property" ) +
diff --git a/source/text/sbasic/shared/03131700.xhp b/source/text/sbasic/shared/03131700.xhp index 1ee4a8d0ae..c358d29d36 100644 --- a/source/text/sbasic/shared/03131700.xhp +++ b/source/text/sbasic/shared/03131700.xhp @@ -1,6 +1,5 @@ - - + @@ -40,12 +39,14 @@ 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"); -this is the same as the following statement: -oIntrospection = CreateUnoService("com.sun.star.beans.Introspection") + + oServiceManager = GetProcessServiceManager() + oIntrospection = oServiceManager.createInstance("com.sun.star.beans.Introspection"); + ' this is the same as the following statement: + oIntrospection = CreateUnoService("com.sun.star.beans.Introspection") + diff --git a/source/text/sbasic/shared/03131800.xhp b/source/text/sbasic/shared/03131800.xhp index 8b142268a1..a7fe27a652 100644 --- a/source/text/sbasic/shared/03131800.xhp +++ b/source/text/sbasic/shared/03131800.xhp @@ -1,6 +1,5 @@ - - + @@ -29,9 +28,11 @@ Sun Microsystems, Inc. +
-CreateUnoDialog function + + CreateUnoDialog function CreateUnoDialog Function [Runtime] Creates a Basic Uno object that represents a Uno dialog control during Basic runtime. @@ -40,14 +41,16 @@ See Examples. Syntax: -CreateUnoDialog( oDlgDesc ) +CreateUnoDialog( oDlgDesc ) Example: -' Get dialog description from the dialog library -oDlgDesc = DialogLibraries.Standard.Dialog1 -' generate "live" dialog -oDlgControl = CreateUnoDialog( oDlgDesc ) -' display "live" dialog -oDlgControl.execute + + ' Get dialog description from the dialog library + oDlgDesc = DialogLibraries.Standard.Dialog1 + ' Generate "live" dialog + oDlgControl = CreateUnoDialog( oDlgDesc ) + ' display "live" dialog + oDlgControl.execute + diff --git a/source/text/sbasic/shared/03131900.xhp b/source/text/sbasic/shared/03131900.xhp index 1a025eb31b..abd2aa7d84 100644 --- a/source/text/sbasic/shared/03131900.xhp +++ b/source/text/sbasic/shared/03131900.xhp @@ -1,6 +1,5 @@ - - + @@ -29,6 +28,7 @@ Sun Microsystems, Inc. +
GlobalScope function @@ -63,13 +63,15 @@ 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 -oDlgDesc = DialogLibraries.Standard.Dialog1 -' calling Dialog2 in the application library Library1 -oDlgDesc = GlobalScope.DialogLibraries.Library1.Dialog2 + + ' calling Dialog1 in the document library Standard + oDlgDesc = DialogLibraries.Standard.Dialog1 + ' calling Dialog2 in the application library Library1 + oDlgDesc = GlobalScope.DialogLibraries.Library1.Dialog2 + diff --git a/source/text/sbasic/shared/03132300.xhp b/source/text/sbasic/shared/03132300.xhp index 6dbb70a9d9..226f7a619e 100644 --- a/source/text/sbasic/shared/03132300.xhp +++ b/source/text/sbasic/shared/03132300.xhp @@ -1,6 +1,5 @@ - - - @@ -42,7 +39,7 @@ 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. +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. -- cgit