Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Programming Gambas from Zip/Operators

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Operators Arithmetic http://Gambaswiki.org/wiki/lang/arithop by example: - 6 x = - xUnary minus Changes number to a negative5 / 2 = 2.5Divide3 + 2 = 5Add3 ^ 2 = 9Power of7 – 4 = 3Subtract13 \ 2 = 6 13 DIV 2 = 6Integer division5 * 2 = 10Multiply12 % 7 = 5 12 MOD 7 = 5Remainder after dividing Boolean Two things combined, or one thing operated onOverall ValueExamplesSomethingTrue AND SomethingTrueTrue(1=1) AND (2=2) is TRUE (1<2) AND (5>4) is TRUE Both have to be true to make the whole thing true.SomethingTrue AND SomethingFalseFalse(1=1) AND (2=3) is FALSE (6>5) AND (4<3) is FALSESomethingFalse AND SomethingTrueFalse(5=6) AND (4=4) is FALSESomethingFalse AND SomethingFalseFalse(5=6) AND (2=3) is FALSENOT SomethingTrueFalseNOT (8=8) is FALSE NOT (1 > -1) is FALSE “Not” means “the opposite of”NOT SomethingFalseTrueNOT (1=2) is TRUE NOT ("apple" > "banana") is TRUE i.e., the reverse of (a comes after b)SomethingTrue OR SomethingTrueTrue(1=1) OR (2=2) is TRUE Either one being true will make the whole thing true.SomethingTrue OR SomethingFalseTrue(1=1) OR (2=3) is TRUESomethingFalse OR SomethingTrueTrue(7=3) OR (3=3) is TRUESomethingFalse OR SomethingFalseFalse(1=1) OR (2=3) is FALSESomethingTrue XOR SomethingTrueFalse(1=1) XOR (4=4) is FALSESomethingTrue XOR SomethingFalseTrue(1=1) XOR (4=5) is TRUESomethingFalse XOR SomethingTrueTrue(1=5) XOR (4=4) is TRUESomethingFalse XOR SomethingFalseFalse(1=2) XOR (4=5) is FALSE AND = both OR = either XOR = either, but not both (“exclusive OR”) String Operators Joining (Concatenation)String & String Concatenates two strings.String &/ String Concatenate two strings that contain file names. Add a path separator between the two strings if necessary. An example of a path is /home/gerard/Documents/Gambas/ How to get it: User.Home &/ "Documents" &/ "Gambas/"ComparisonString = String Returns if two strings are equal.String == String Case-insensitive comparison Returns if two strings are equal, regardless of upper or lower caseString LIKE String Checks if a string matches a pattern. Is the first string like the second? There are special codes for the pattern string. Refer to the wiki for more codes, http://Gambaswiki.org/wiki/lang/like * means any character or string of characters "Gambas" Like "G*" means “Does Gambas begin with a G?” ? means any single character; [ ] means either/or the things in brackets: "Gambas" Like "?[Aa]*" means “Does Gambas have a capital or small A as its second letter?” "Gambas" Like "G[^Aa]*" means “Does Gambas not have a capital or small A as its second letter?” Dim Fruit As String = "pear" Label1.text = Fruit Like "{apple,pear,lemon}" shows True, but Label1.text = Fruit Like "{apple, pear, lemon}" shows False because spaces matter.String MATCH StringChecks if a string matches a PCRE regular expression. Refer to http://Gambaswiki.org/wiki/doc/pcre PCRE means Perl Compatible Regular Expressions Regular expressions are the ultimate in finding things in strings.String BEGINS String Checks if a string begins a certain way "Gerard" Begins "G" means “Does Gerard begin with a G?”String ENDS String Checks if a string ends a certain way "Benôit" Ends "t" means “Does Benôit end with a t?”String <> String Does not equal, or “is not the same as”String1 < String2 Does string1 come alphabetically before string2?String1 > String2 Does string1 come alphabetically after string2?String1 <= String2 Does string1 come alphabetically before, or is it the same as, string2?String1 >= String2 Does string1 come alphabetically after, or is it the same as, string2? Constants DataTypes