Basal
22 July 01:41
Here is [http://en.wikipedia.org/wiki/BASIC_ program ming_language wikipedia entry].
BASIC is a abounding procedural accent or item aggressive depending on the Basal you are using.
BASIC is an acronym for Beginners Advantageous Allegorical Apprenticeship Code
Modern BASICS are usually chip into a visual, event-driven environment; in such applications, there is no program access point in the developers view. In the case of a command-line REALbasic program , there is a Run accident of the ConsoleApplication chic which is invoked if the program begins, and which receives command-line arguments as an arrangement of strings.
BASIC syntax uses actual little appropriate punctuation, above those accepted to algebra and alotof additional languages, such as + for addition. The according assurance (=) is acclimated for both appointment and adequation testing, which raises no ambiguity back (unlike C) an appointment account may not be acclimated as allotment of addition expression. Parentheses are acclimated for alignment terms, as in algebra, as able-bodied as for indexing into arrays. A aeon (or dot) is acclimated for accessing item backdrop or methods. Aboveboard brackets, coiled braces, and additional odd punctuation are not used.
Code blocks are belted by statements; for example, an if block begins with an if account and ends with end if. Statements are afar by band breaks, admitting a account that needs to amount assorted curve can do so via a appropriate band assiduity appearance (_).
Heres a archetypal archetype of Basal code:
Dim i As Integer
Dim s As String
for i = 1 to 4
s = s + spam,
next
MsgBox s + broiled beans, and spam!
Both VisualBasic and REALbasic use a individual apostrophe to denote a comment, which continues to the end of the line. The old REM account may aswell be used, admitting it is no best in fashion. REALbasic may aswell use C++-style // comments. Basal supports no block animadversion mechanism, admitting the IDE may abutment bound commenting or uncommenting blocks of code. Example:
acceptation = 6 REM Sos this, but cipher writes comments this way anymore.
// This animadversion will plan alone in REALbasic.
REALbasic is a strongly-typed language; Beheld Basal is added about typed, but both crave variables to be declared afore they are used. Bounded variables are declared using a Dim statement:
Dim i As Integer
Multiple variables may be declared on a individual line, and they may be accustomed antecedent ethics at acknowledgment time, as apparent here:
Dim x As Integer, xstr As String
Dim displace As Cord = liver
Note that an important aberration exists amid REALbasic and VisualBasic if two variables are declared with alone one type:
Dim a, b As Double
In REALbasic, both a and b would be variables of blazon Double. In Beheld Basic, b would be a Double, but a would be a Alternative (essentially, an untyped variable).
Note that in the case of an item declaration, there is a added adjustment for initializing the capricious to a new item instance:
Dim d1 as New Date // this...
Dim d2 as Date = New Date // does the aforementioned as this
Variables may aswell be declared as backdrop of classes, windows, or modules. These use the aforementioned syntax, or are edited anon by the IDE.
Methods are authentic by a Action or Sub keyword. Actuality is an example.
Action Factorial( num As Accumulation ) As Integer
Dim out As Accumulation = 1
Dim i As Integer
For i = 2 to Num
out = out Next i
Acknowledgment out
End Function
REALbasic uses block scoping aural a method; that is, a Dim account aural (for example) an If block makes a capricious that goes out of ambit at the end of that block. Bounded variables declared at the top of a adjustment go out of ambit at the end of the method. All variables declared aural a adjustment are aloof alfresco that method, and with the barring of changeless variables, use assemblage storage.
Properties of classes, modules, and windows are stored on the heap. Bore backdrop may be clandestine (accessible alone aural the module), accessible (accessible from anywhere by using the bore name as a prefix), or all-around (accessible from anywhere with no prefix). Chic backdrop may be clandestine (accessible alone aural that class), adequate (accessible aural that chic or its subclasses), or accessible (accessible from anywhere via an item reference). Windows are absolutely just classes, and accept the aforementioned scoping rules.
BASIC supports If/ElseIf/Else blocks:
If adequateness < 10 Then
aftereffect = Accompany me added food!
ElseIf adequateness = 10 Then
aftereffect = I couldnt eat addition bite.
Else
Explode
End If
There is aswell a single-line architecture advantageous for quick tests:
If not haveShrubbery Then Say Ni
For beyond blocks of tests, a Baddest Case may be used:
Baddest Case healthStage
Case 0
x = Im not absolutely asleep yet
Case 1
x = Im activity better
Case 2
x = Anticipate Ill go for a airing now
Else
x = I feel happy...
End Select
BASIC sports a array of looping constructs, including For/Next, Do/Loop, and While/Wend. The For account may use either a after counter, or may iterate over the elements of an arrangement using For Each.
For Anniversary charlatan in Knights
results.Append knight.Name + says Ni!
Next
Most Basal applications are beheld (GUI) applications, and accept no accepted output. However, if one just needs to affectation a abbreviate message, the MsgBox account may be used:
MsgBox Accost world!
For debugging purposes, in REALbasic, you could aswell use System.DebugLog, which sends its altercation to the accepted debugging animate for the belvedere youre on.
BASIC includes supports for arrays, which may be anesthetized as arguments, alternate from functions, assigned to variables, and so on. There is aswell a Accumulating class, and in REALbasic, a Concordance chic which holds approximate key/value pairs.
In cases area none of these congenital containers are suitable, one can calmly ascertain a custom alembic chic using whatever centralized accumulator is alotof appropriate.
Arrays of alotof archaic datatypes (e.g. numbers and strings) can be sorted or shuffled, as in this example:
Action Choose5( cards() as Cord ) as String()
// drag the accustomed cards, accept 5 at random,
// and acknowledgment them in sorted order
cards.Shuffle
Dim out() as String
For i As Accumulation = 1 to 5
out.Append cards(i)
Next
out.Sort
acknowledgment out
End Function
The Concordance chic provides a congenital accomplishing of a resizable assortment table. Additional algorithms may of advance be accounting by the user as needed.
BASIC uses advertence counting rather than debris collection. If there are no added references to an item or string, its anamnesis is automatically (and immediately) released.
Visual Basal projects are comprised of a array of files, alotof of them apparent text. REALbasic projects are usually stored in a single-file, proprietary bifold format, admitting it is aswell accessible to abundance activity items externally, in either bifold or XML format.
Dont abash Beheld Basal with REALbasic. They accept accepted roots and agnate syntax, but rather altered semantics. REALbasics semantics are afterpiece to Java or VB.NET than to Beheld Basic, which is added procedural than object-oriented.
[http://www.realbasic.com REALbasic Home Page]
[http://www.rbgarage.com/rbg/index.php REALbasic Garage]
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/VBRef98/html/vbmscLROverview.asp VB Reference]
REALbasic developers should accede [http://www.rbdeveloper.com REALbasic Developer] magazine.
Numerous books on both REALbasic and Beheld Basal may be begin via [http://www.amazon.com Amazon.com].
Here is [http://en.wikipedia.org/wiki/BASIC_ program ming_language wikipedia entry].
BASIC is a abounding procedural accent or item aggressive depending on the Basal you are using.
BASIC is an acronym for Beginners Advantageous Allegorical Apprenticeship Code
Modern BASICS are usually chip into a visual, event-driven environment; in such applications, there is no program access point in the developers view. In the case of a command-line REALbasic program , there is a Run accident of the ConsoleApplication chic which is invoked if the program begins, and which receives command-line arguments as an arrangement of strings.
BASIC syntax uses actual little appropriate punctuation, above those accepted to algebra and alotof additional languages, such as + for addition. The according assurance (=) is acclimated for both appointment and adequation testing, which raises no ambiguity back (unlike C) an appointment account may not be acclimated as allotment of addition expression. Parentheses are acclimated for alignment terms, as in algebra, as able-bodied as for indexing into arrays. A aeon (or dot) is acclimated for accessing item backdrop or methods. Aboveboard brackets, coiled braces, and additional odd punctuation are not used.
Code blocks are belted by statements; for example, an if block begins with an if account and ends with end if. Statements are afar by band breaks, admitting a account that needs to amount assorted curve can do so via a appropriate band assiduity appearance (_).
Heres a archetypal archetype of Basal code:
Dim i As Integer
Dim s As String
for i = 1 to 4
s = s + spam,
next
MsgBox s + broiled beans, and spam!
Both VisualBasic and REALbasic use a individual apostrophe to denote a comment, which continues to the end of the line. The old REM account may aswell be used, admitting it is no best in fashion. REALbasic may aswell use C++-style // comments. Basal supports no block animadversion mechanism, admitting the IDE may abutment bound commenting or uncommenting blocks of code. Example:
acceptation = 6 REM Sos this, but cipher writes comments this way anymore.
// This animadversion will plan alone in REALbasic.
REALbasic is a strongly-typed language; Beheld Basal is added about typed, but both crave variables to be declared afore they are used. Bounded variables are declared using a Dim statement:
Dim i As Integer
Multiple variables may be declared on a individual line, and they may be accustomed antecedent ethics at acknowledgment time, as apparent here:
Dim x As Integer, xstr As String
Dim displace As Cord = liver
Note that an important aberration exists amid REALbasic and VisualBasic if two variables are declared with alone one type:
Dim a, b As Double
In REALbasic, both a and b would be variables of blazon Double. In Beheld Basic, b would be a Double, but a would be a Alternative (essentially, an untyped variable).
Note that in the case of an item declaration, there is a added adjustment for initializing the capricious to a new item instance:
Dim d1 as New Date // this...
Dim d2 as Date = New Date // does the aforementioned as this
Variables may aswell be declared as backdrop of classes, windows, or modules. These use the aforementioned syntax, or are edited anon by the IDE.
Methods are authentic by a Action or Sub keyword. Actuality is an example.
Action Factorial( num As Accumulation ) As Integer
Dim out As Accumulation = 1
Dim i As Integer
For i = 2 to Num
out = out Next i
Acknowledgment out
End Function
REALbasic uses block scoping aural a method; that is, a Dim account aural (for example) an If block makes a capricious that goes out of ambit at the end of that block. Bounded variables declared at the top of a adjustment go out of ambit at the end of the method. All variables declared aural a adjustment are aloof alfresco that method, and with the barring of changeless variables, use assemblage storage.
Properties of classes, modules, and windows are stored on the heap. Bore backdrop may be clandestine (accessible alone aural the module), accessible (accessible from anywhere by using the bore name as a prefix), or all-around (accessible from anywhere with no prefix). Chic backdrop may be clandestine (accessible alone aural that class), adequate (accessible aural that chic or its subclasses), or accessible (accessible from anywhere via an item reference). Windows are absolutely just classes, and accept the aforementioned scoping rules.
BASIC supports If/ElseIf/Else blocks:
If adequateness < 10 Then
aftereffect = Accompany me added food!
ElseIf adequateness = 10 Then
aftereffect = I couldnt eat addition bite.
Else
Explode
End If
There is aswell a single-line architecture advantageous for quick tests:
If not haveShrubbery Then Say Ni
For beyond blocks of tests, a Baddest Case may be used:
Baddest Case healthStage
Case 0
x = Im not absolutely asleep yet
Case 1
x = Im activity better
Case 2
x = Anticipate Ill go for a airing now
Else
x = I feel happy...
End Select
BASIC sports a array of looping constructs, including For/Next, Do/Loop, and While/Wend. The For account may use either a after counter, or may iterate over the elements of an arrangement using For Each.
For Anniversary charlatan in Knights
results.Append knight.Name + says Ni!
Next
Most Basal applications are beheld (GUI) applications, and accept no accepted output. However, if one just needs to affectation a abbreviate message, the MsgBox account may be used:
MsgBox Accost world!
For debugging purposes, in REALbasic, you could aswell use System.DebugLog, which sends its altercation to the accepted debugging animate for the belvedere youre on.
BASIC includes supports for arrays, which may be anesthetized as arguments, alternate from functions, assigned to variables, and so on. There is aswell a Accumulating class, and in REALbasic, a Concordance chic which holds approximate key/value pairs.
In cases area none of these congenital containers are suitable, one can calmly ascertain a custom alembic chic using whatever centralized accumulator is alotof appropriate.
Arrays of alotof archaic datatypes (e.g. numbers and strings) can be sorted or shuffled, as in this example:
Action Choose5( cards() as Cord ) as String()
// drag the accustomed cards, accept 5 at random,
// and acknowledgment them in sorted order
cards.Shuffle
Dim out() as String
For i As Accumulation = 1 to 5
out.Append cards(i)
Next
out.Sort
acknowledgment out
End Function
The Concordance chic provides a congenital accomplishing of a resizable assortment table. Additional algorithms may of advance be accounting by the user as needed.
BASIC uses advertence counting rather than debris collection. If there are no added references to an item or string, its anamnesis is automatically (and immediately) released.
Visual Basal projects are comprised of a array of files, alotof of them apparent text. REALbasic projects are usually stored in a single-file, proprietary bifold format, admitting it is aswell accessible to abundance activity items externally, in either bifold or XML format.
Dont abash Beheld Basal with REALbasic. They accept accepted roots and agnate syntax, but rather altered semantics. REALbasics semantics are afterpiece to Java or VB.NET than to Beheld Basic, which is added procedural than object-oriented.
[http://www.realbasic.com REALbasic Home Page]
[http://www.rbgarage.com/rbg/index.php REALbasic Garage]
[http://msdn.microsoft.com/library/default.asp?url=/library/en-us/VBRef98/html/vbmscLROverview.asp VB Reference]
REALbasic developers should accede [http://www.rbdeveloper.com REALbasic Developer] magazine.
Numerous books on both REALbasic and Beheld Basal may be begin via [http://www.amazon.com Amazon.com].
|
Tags: accessible, program, basic, example, windows, class, classes, block, applications, language, method, declared, format, anywhere, single, blocks, statement, public, string, supports basic, realbasic, variables, statement, class, visual, object, integer, string, declared, example, accessible, block, method, properties, single, blocks, cards, return, function, format, reference, anywhere, module, windows, msgbox, program, applications, language, syntax, arrays, variable, supports, comment, classes, , visual basic, statement may, http www, used for, accessible from, accessible from anywhere, public accessible from, accessible only within, private accessible only, |
Also see ...
PermalinkArticle In : Reference & Education - Book