LibreOffice 24.2 सहयोग
दिएको कुराले आधारभूत LibreOffice भित्र प्रयोग आधारभूत चलहरूको व्याख्या गर्दछ ।
यो चलमा अधिकतम २५५ क्यारेक्टरहरूको नाम मात्र सूचीकृत हुन्छ । चल नामको पहिलो क्यारेक्टर अक्षर A-Z वा a-z सम्मको हुनै पर्दछ । नम्बरहरूपनि चलको नाममा प्रयोग गर्न सकिन्छ तर अन्डरस्कोर क्यारेक्टर ("_") को अपवादसँग योजक प्रतीकहरू र विशेष क्यारेक्टरहरू लाई आनुमति हुँदैन । आधारभूत LibreOffice भित्र चल पहिचायकहरू केस संवेदनशील हुँदैनन् । चलहरूमा नामहरू खालीठाउँमा सूचीकृत्र हुनपनि सक्छन् तर तिनीहरूले यसो गरेमा बर्ग कोष्ठहरूमा बन्द गरिनै पर्दछ ।
चल पहिचायकका लागि उदाहरणहरू:
MyNumber=5 'Correct'
MyNumber5=15 'Correct'
MyNumber_5=20 'Correct'
My Number=20 'Not valid, variable with space must be enclosed in square brackets'
[My Number]=12 'Correct'
DéjàVu=25 'मान्य छैन, विशेष क्यारेक्टरहरू लाई अनुमति छैन'
5MyNumber=12 'मान्य छैन, variable को नाम नम्बरबाट सुरु हुनु हुँदैन'
Number,Mine=12 'Not valid, punctuation marks are not allowed'
LibreOffice आधारभूत भित्र चलहरूको स्पस्टता घोषणा गर्न आवश्यक पर्दैन । अचलहरूलाई शुध्दिकरण गर्न Dimकथन पूरा गर्नुपर्दछ । एकै पटकमा एक भन्दा भडि चलहरूलाई घोषणा गर्न नामहरू लाई अल्पविराम दिएर विभाजन गर्नुपर्दछ । चलको प्रकारलाई परिभाषित गर्न कि नाम पछाडि प्रकार घोषणा चिन्ह वा उपर्युक्त शब्दकुञ्जीको प्रयोग गर्नुपर्दछ ।
चल घोषणा गर्नका लागि उदाहरण:
Dim a$ 'Declares the variable "a" as a String'
Dim a As String 'Declares the variable "a" as a String'
Dim a$, b As Integer 'Declares one variable as a String and one as an Integer'
Dim c As Boolean 'Declares c as a Boolean variable that can be TRUE or FALSE'
एकपटक घोषणा गरेको निश्चित प्रकारको चलमा, तपाईँ फरक प्रकारको एउटै मानाङ्कन भएको चल घोषणा गर्न सक्नुहुन्न !
When you declare multiple variables in a single line of code you need to specify the type of each variable. If the type of a variable is not explicitly specified, then Basic will assume that the variable is of the Variant type.
' Both variables "a" and "b" are of the Integer type
Dim a As Integer, b As Integer
' Variable "c" is a Variant and "d" is an Integer
Dim c, d As Integer
' A variable can also be explicitly declared as a Variant
Dim e As Variant, f As Double
The Variant type is a special data type that can store any kind of value. To learn more, refer to the section The Variant type below.
तलका आदेशको प्रयोग गरेर चलहरूको घोषणा गर्न दबाब दिनुहोस् ।
Option Explicit
स्पष्ट विकल्पकथनले पहिलो सवभन्दा अगाडि मोड्युलमा पहिलो रेखा लिन्छ । साधारणतया, बाँणहरूलाई मात्र घोषित स्पष्टताको जरुरत पर्दछ । सबै चलका क्यारेक्टरहरू प्रकार घोषणाका अनुसारै घोषणा गरिन्छ, वा - यदि एउटा पूर्वनिर्धारित प्रकार भुलेको - भए ।
आधारभूत LibreOffice ले चारवटा चल बर्गहरूलाई समर्थन गर्दछ:
सङ्ख्यात्मकचलहरू नम्बर मानमा सूचीकृत गर्न सकिन्छ । केही चलहरू ठुला वा साना नम्बरहरूमा भण्डारण गर्नलाई प्रयोग गरिन्छ र अरूलाई उत्प्लावन बिन्दु वा खण्डित नम्बरहरूका लागि प्रयोग गरिन्छ ।
स्ट्रिङचलहरू सूचीत क्यारेक्टर स्ट्रिङहरू ।
बुलियनसूचीत चलहरू कि TRUE वा FALSE मानमा छन् ।
वस्तु चलले विभिन्न प्रकारहरूको वस्तु भण्डारण गर्न सक्छ, जस्तै कागजात भित्र टेबलहरू र कागजातहरू ।
इन्टिजर चलहरूको दायरा- ३२७६८ बाट ३२७६७ सम्म छ । यदि उत्प्लावन बिन्दु मान इन्टिजर चललाई मानांङ्कन गर्ने हो भने दशमलव भएका स्थानहरूलाई अर्को इन्टिजरमा राउन्डेड हुन्छन् । कार्य-विधिहरूमा इन्टिजर चलहरू शीघ्र गणना गरिन्छन् र लूप्समा गणक चलहरूका लागि उपयुक्त हुन्छन् ।एउटा इन्टिजरलाई केबल दुई बाइटको स्मृति आवश्यकता पर्दछ । "%" टाइप-घोषणा क्यारेक्टर हो ।
Dim Variable%
Dim Variable As Integer
लामो इन्टिजर चलहरूको दायरा -२१४७४८३६४८ देखि२१४७४८३६४७ छ । यदि लामो इन्टिजर चललाई उत्प्लावन बिन्दु मान मानांङ्कन गर्ने हो भने दशमलव भएका स्थानहरूलाई अर्को इन्टिजरमा राउन्ड गर्नुहोस् ।कार्यविधीमा लामो इन्टिजर चलहरू शीघ्र गणना हुन्छन र तिनीहरू लामो मानहरूका लागि लूप्समा गणक चलहरका लागि उपयुक्त हुन्छन् । एउटा लामो इन्टिजर चललाई चार बाइट स्मृति आवश्यकता पर्दछ । "&" प्रकार- घोषणा क्यारेक्टर हो ।
Dim Variable&
Dim Variable As Long
Decimal variables can take positive or negative numbers or zero. Accuracy is up to 29 digits.
You 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, LibreOffice Basic rounds the figure up or down.
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
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 Currency
Numbers can be encoded using octal and hexadecimal forms.
xi = &o13 ' 8 + 3
ci = &h65 ' 6*16 + 5
MAX_Integer = &o77777 ' 32767 = &h7FFF
MIN_Integer = &o100000 ' -32768 = &h8000
MAX_Long = &h7fffffff ' 2147483647 = &o17777777777
MIN_Long = &h80000000 ' -2147483648 = &o20000000000
String variables can hold character strings with up to 2,147,483,648 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 2 Gbytes. The memory required for storing string variables depends on the number of characters in the variable. The type-declaration character is "$".
In BASIC String functions, the first character of the string has index 1.
Dim Variable$
Dim Variable As String
बुलियन चलहरूले दुई मानहरूमा एउटा मात्रै भण्डार गर्दछ:TRUE वा FALSE, नम्बर ०ले FALSE मुल्याङ्कन ,प्रत्येक अरू मानको TRUE मुल्याङ्कन गर्दछ ।
Dim Variable As Boolean
मिति चलहरूले एउटा आन्तरिक ढाँचामा भण्डारण गरिएको मितिहरू र समय मानहरू मात्र समाहित गर्न सक्दछ । मितिश्रृंखला, मितिमान, समयश्रृंखला वा Timevalue सँग मिति चलहरूमा मानाङ्कन गरिएका मानहरू स्वचालित रूपमा आन्तरिक ढाँचामा रूपान्तरित हुन्छन् । दिन, महिना, वर्ष वा घण्टा, मिनेट, सेकेन्ड प्रकार्य प्रयोग गरेर मिति-चलहरू सामान्य नम्बरहरूमा रूपान्तरित हुन्छन् । आन्तरिक ढाँचाले दुइवटा नम्बरहरूको बीचमा भिन्नता गणना गरेर मिति/समय मानहरूको एउटा तुलमा सक्षम पार्दछ । यी चलहरू कुञ्जी शब्द सँग मात्र घोषणा गर्न सकिन्छ मिति ।
Dim Variable As Date
Date literals allow to specify unambiguous date variables that are independent from the current language. Literals are enclosed between hash signs #. Possible formats are:
#yyyy-mm-dd#
#mm/dd/yyyy#
start_date = #12/30/1899# ' = 1
dob = #2010-09-28#
Variables declared as Variant can handle any data type. This means that the actual data type is defined during runtime as a value is assigned to the variable.
There are three main ways to create a Variant variable, as shown below:
Dim varA ' The type is not specified, hence the variable is a Variant
Dim varB as Variant ' The variable is explicitly declared as a Variant
varC = "abc" ' Previously undeclared variables are treated as Variants
The example below uses the TypeName function to show how the type of a Variant variable changes upon assignment.
Dim myVar As Variant
MsgBox TypeName(myVar) ' Empty
myVar = "Hello!"
MsgBox TypeName(myVar) ' String
myVar = 10
MsgBox TypeName(myVar) ' Integer
A Variant variable is initialized with the Empty special data type. You can use the IsEmpty function to test if a variable is an Empty Variant.
You can also use the keyword Any to declare a variable as a Variant. However, Any is deprecated and is available for backward compatibility.
Arguments with type Variant or Any passed in function calls are not checked for their types.
Dim myVar As Any ' Variable "myVar" is a Variant
जति सक्दो चाँडो चलहरू घोषणा भइरहेका हुन्छन्, यसले स्वचालित रूपमै "नल" मानमा सेट हुन्छ । दिएका परम्पराहरूलाई याद गर्नुहोस्:
सङ्ख्यात्मकचलहरू मान "0" घोषणा भएपछि जति सक्दो चाँडो स्वाचालित तरीकाले मानांकित हुन्छन् ।
मिति चलहरू मान 0 सँग आन्तरिक रूपमा मानांकित छन्; मानलाई "0" मा दिन, महिना, वर्ष वा घण्टा, मिनेट, सेकेन्ड प्रकार्य सँग रूपान्तरण गरे बराबर
घोषित स्ट्रिङ चलहरू खाली-स्ट्रिङमा ("") मानाङ्कन भएका हुन्छन् ।
विशेष प्रकारको चलद्वारा परिभाषित गरिएको, आधारभूत LibreOfficeले एउटा वा बहु-आयामिक बाँणहरू बुझाउछ । बाँणहरू कार्यक्रममा सूची र तालिकाहरू सम्पादन गर्नका लागि उपयुक्त हुन्छन् । बाँणहरूको व्यक्तिगत तत्वहरू सङ्ख्यात्मक अनुक्रमणिकाद्वारा ठेगना पत्ता लगाउन सकिन्छ ।
एर्रेहरू अनिवार्य रूपमा Dim statement मा उल्लेखित (Declared) हुनै पर्दछ । एर्रेहरूलाई परिभाषित गर्ने थुप्रै तरिकाहरू छन्l
Dim Text$(20) '21 elements numbered from 0 to 20'
Dim Text$(5,4) '30 elements (a matrix of 6 x 5 elements)'
Dim Text$(5 To 25) '21 elements numbered from 5 to 25'
Dim Text$(-15 To 5) '21 elements (including 0), numbered from -15 to 5'
अनुक्रणिका दायरामा सकारात्मक जस्तै नकारात्मक नम्बरहरू पनि समावेश गर्न सकिन्छ ।
अचलहरू निश्चित मानका हुन्छन् । तिनीहरू पहिले नै मात्रै कार्यक्रममा परिभाषित हुन्छन् र त्यसपछि पुन: परिभाषित गर्न सकिँदैन:
Const ConstName=Expression