Results 1 to 7 of 7

Thread: Why does |= not work?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170

    Why does |= not work?

    i thought it were logical to assign something additional using OR as simple as this - but it does not work

    Uses "console"
    
    Long lTest
    
    lTest |= 1                     ' should equal  lTest = lTest | 1 
    PrintL lTest
    
    WaitKey
    
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159
    because this isn't C its ThinBasic!

    result = ANDb (Num1, Num2) ' Used to perform AND bitwise operations.
    result = ORb (Num1, Num2) 'Used to perform OR bitwise operations.
    result = expression1 OR expression2  ' Used to perform a logical disjunction on two expressions.
    | ' Alias of Or opertaor.
    
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    Yes correct.

    We have
    a += b
    
    which is just shorter and means the same as
    a = a + b
    
    also there are similar operations as -=, *= etc.

    but no
    a |= b
    ' that means
    a = a | b
    
    i was wondering because i typed it in that way, no doubt that it would work - but it does not.
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    In traditional BASIC. <> is not equal.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    no, maybe it was a little vague, i did not write

    !=
    c-like "NOT equal"

    but

    |=
    basic-like "equals Itself OR Parameter"

    logic numeric operator that will prove "3 = 2 OR 1"

    A = A OR B

    A |= B
    Last edited by ReneMiner; 01-03-2015 at 08:29.
    I think there are missing some Forum-sections as beta-testing and support

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    The note by Michael is good one,

    maybe if AND() and OR() could be used for logical, not bitwise operations, it would be nice.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  7. #7
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    For implicit assignement there are already available:

    +=, -=, *=, /=, \=

    We also have &= and += that are doing the same when it comes to stringExpressions, used to concatenate such.

    and these were reasoned to have:


    implicit AND
    &=

    numericVar &= numericExpression

    would equal
    numericVar = (numericVar AND numericExpression)


    implicit OR
    |=

    numericVar |= numericExpression

    equals then
    numericVar = (numericVar OR numericExpression)


    stringVar |= stringExpression

    equals
    stringVar = IIF$(Instr(stringVar, stringExpression), stringVar, stringVar & stringExpression)
    Last edited by ReneMiner; 02-03-2015 at 10:21.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. How to make OBJ2M15 work
    By Lionheart008 in forum TBGL General
    Replies: 9
    Last Post: 22-10-2008, 22:12
  2. So how do you want to work on the game?
    By Michael Hartlef in forum CM contest 2009
    Replies: 20
    Last Post: 30-09-2008, 16:26
  3. How does Karma work?
    By marcuslee in forum Shout Box Area
    Replies: 4
    Last Post: 03-09-2008, 07:33
  4. An idea, will this work
    By kryton9 in forum General
    Replies: 15
    Last Post: 24-04-2007, 11:11
  5. Back to work
    By ErosOlmi in forum Shout Box Area
    Replies: 1
    Last Post: 04-01-2007, 21:27

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •