மாறிகளைப் பயன்படுத்தி

பின்வருவன LibreOffice அடிப்படையின் செயல்முறைகள் மற்றும் செயலாற்றிகள் ஆகியவற்றின் அடிப்படை பயன்பாட்டை விளக்குகிறது.

மாறி அடையாளமிடுபவையின் பெயரிடும் மரபுகள்

ஒரு மாறியின் பெயரானது அதிகபட்சம் 255 வரியுருக்களைக் கொண்டிருக்கும். மாறி பெயரின் முதல் வரியுரு கண்டிப்பாக A-Z அல்லது a-z எழுத்தாக இருக்க வேண்டும். மாறியின் பெயரில் எண்களும் பயன்படுத்தப்படலாம். ஆனால், அடிக்கோடிட்ட வரியுருக்களைத் தவிர ("_") நிறுத்தக்குறிகளும் சிறப்பு வரியுருக்களும் அனுமதிக்கப்படாது. LibreOffice அடிப்படை மாறிகள் எழுத்து வடிவுணர்வு கொண்டவை அல்ல. மாறிகள் பெயர்கள் இடைவெளி கொண்டிருக்கலாம் ஆனால், அவை சதுர அடைப்புகளில் இருக்க வேண்டும்.

மாறி காட்டிகளுக்கான எடுத்துக்காட்டுகள்:


      MyNumber=5

சரி


      MyNumber5=15

சரி


      MyNumber_5=20

சரி


      My Number=20

செல்லாது, இடைவெளியுள்ள மாறிகள் சதுர அடைப்புகளுக்குள் இருக்க வேண்டும்


      [My Number]=12

சரி


      DéjàVu=25

செல்லாது, சிறப்பு வரியுருக்களுக்கு அனுமதியில்லை


      5MyNumber=12

செல்லாது, மாறி ஒரு எண்ணுடன் தொடங்கக்கூடாது


      Number,Mine=12

செல்லாது, நிறுத்தக்குறிகளுக்கு அனுமதியில்லை


அறிவிக்கும் மாறிகள்

LibreOffice அடிப்படையில் நீங்கள் மாறிகளை வெளிப்படையாக அறிவிக்க வேண்டிய அவசியமில்லை. மாறியைத் தெளிவில்லாமல் மங்கலான கூற்றைக் கொண்டு செயல்படுத்தலாம். காற்புள்ளிகளைக் கொண்டு பெயர்களைப் பிரிப்பதன் மூலம் நீங்கள் ஒரே சமயத்தில் ஒன்றுக்கும் மேற்பட்ட மாறிகளை அறிவிக்கலாம். மாறியின் வகையை வரையறுக்க, பெயருக்குப் பிறகு வகை-அறிவித்தல் ஒப்பத்தை அல்லது ஏற்புடைய முக்கிய சொல்லைப் பயன்படுத்தலாம்.

மாறிகள் அறிவித்தலுக்கான எடுத்துக்காட்டுகள்:


      Dim a$

மாறியை ஒரு "சரம்" ஆக அறிவித்தல்


      Dim a As String

மாறியை ஒரு "சரம்" ஆக அறிவித்தல்


      Dim a$, b As Integer

ஒரு மாறியைச் சரமாகவும் ஒரு மாறியை முழு எண்ணாகவும் அறிவிக்கிறது


      Dim c As Boolean

c உண்மையோ பொய்யோ ஆகக்கூடிய ஒரு பூலியன் மாறி என அறிவிக்கிறது


நீங்கள் ஒவ்வொரு முறையும் வகை- அறிவித்தல் வரியுருவுக்கு நீங்கள் பயன்படுத்தும் மாறியை அறிவிப்பது மிக முக்கியமாகும். அது திறவுச்சொல்லாக இல்லாமல் அறிவித்தலில் பயன்பட்ட்டிருந்தாலும் கூட. அதனால், பின்வரும் கூற்றானது செல்லாத ஒன்று:


      Dim a$

"ஒரு" சரமாக அறிவிக்கிறது.


      a="TestString"

வகை-அறிவித்தல் காணவில்லை: "a$="


Warning Icon

நீங்கள் ஒரு மாறியை குறிப்பிட்ட வகையாக அறிவித்த பிறகு, நீங்கல் அந்த மாறியை அதே பெயரில் வேறு வகையாக மீண்டும் அறிவிக்க முடியாது!


மாறி அறிவிப்புகளைக் கட்டாயப்படுத்துதல்

மாறிகளின் அறிவித்தல்களைக் கட்டாயப்படுத்த, பின்வரும் கட்டளைகளைப் பயன்படுத்துக:


Option Explicit

தேர்வு வெளிப்படை கூற்றானது நிரல்கூற்றின் முதல் வரியாக இருக்க வேண்டும், முதல் SUB க்கு முன்பு. பொதுவாக, அணிகள் மட்டுமே வெளிப்படையாக அறிவிக்கப்படவேண்டும். மற்ற மாறிகள் வகை-அறிவித்தல் வரியுருவிற்கு ஏற்ப அல்லது - நீக்கப்பட்டுவிட்டால் - முன்னிருப்பு வகை ஒற்றை ஆக அறிவிக்கப்படுகின்றன.

மாறி வகைகள்

LibreOffice அடிப்படை நான்கு மாறி வகுப்புகளை ஆதரிக்கிறது:

முழு எண் மாறிகள்

முழு எண் மாறிகளின் வீச்சு -32768 இலிருந்து 32767 வரை ஆகும். ஒரு முழு எண் மாறிக்கு உங்களுக்கு மிதவை-புள்ளி அளிக்கப்பட்டால், தசம இடமானது அடுத்த முழு எண்ணுக்கு மாற்றப்படுகிறது. முழு எண் மாறிகள் உடனே செயல் முறையில் கணக்கிடப்படுவதோடு அவை முழுச்சுற்றிலுள்ள கணக்கிடும் மாறிகளுக்கு ஏற்புடையாதாய் அமைகின்றன. ஒரு முழு எண் மாறிக்கு இரண்டு பைட்டு நினைவகம் மட்டுமே தேவைப்படுகிறது. "%" என்பது வகை-அறிவிப்பு வரியுரு ஆகும்.


Dim Variable%
Dim Variable As Integer

நீண்ட முழு எண் மாறிகள்

நீண் முழு எண் மாறிகளின் வீச்சு -2147483648 இலிருந்து 2147483647 வரை ஆகும். ஒரு நீண்ட முழு எண் மாறிக்கு உங்களுக்கு மிதவை-புள்ளி அளிக்கப்பட்டால், தசம இடமானது அடுத்த நீண்ட முழு எண்ணுக்கு மாற்றப்படுகிறது. நீண்ட முழு எண் மாறிகள் உடனே செயல் முறையில் கணக்கிடப்படுவதோடு அவை முழுச்சுற்றிலுள்ள கணக்கிடும் மாறிகளுக்கு ஏற்புடையாதாய் அமைகின்றன. ஒரு நீண்ட முழு எண் மாறிக்கு இரண்டு பைட்டு நினைவகம் மட்டுமே தேவைப்படுகிறது. "&" என்பது வகை-அறிவிப்பு வரியுரு ஆகும்.


Dim Variable&
Dim Variable As Long

தசம மாறிகள்

தசம மாறிகளானவை நேர்முறை அல்லது எதிர்முறை அல்லது சுழியமாகவோ அமையலாம். துல்லியம் 29 இலக்கங்கள் வரை உள்ளது.

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

நாணய மாறிகள்

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

சர மாறிகள்

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

பூலியன் மாறிகள்

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

தேதி மாறிகள்

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

முதலாவது மாறி மதிப்புகள்

As soon as the variable has been declared, it is automatically set to the "Null" value. Note the following conventions:

Numeric variables are automatically assigned the value "0" as soon as they are declared.

Date variables are assigned the value 0 internally; equivalent to converting the value to "0" with the Day, Month, Year or the Hour, Minute, Second function.

String variables are assigned an empty-string ("") when they are declared.

அணிகள்

LibreOffice Basic knows one- or multi-dimensional arrays, defined by a specified variable type. Arrays are suitable for editing lists and tables in programs. Individual elements of an array can be addressed through a numeric index.

Arrays must be declared with the Dim statement. There are several ways to define the index range of an array:


      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


The index range can include positive as well as negative numbers.

மாறிலி

Constants have a fixed value. They are only defined once in the program and cannot be redefined later:


Const ConstName=Expression

Please support us!