Results 1 to 7 of 7

Thread: Why does |= not work?

  1. #1
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,436
    Blog Entries
    2
    Rep Power
    158

    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
    
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

  2. #2
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Blog Entries
    1
    Rep Power
    157
    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 ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,436
    Blog Entries
    2
    Rep Power
    158
    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.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

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

  5. #5
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,436
    Blog Entries
    2
    Rep Power
    158
    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.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

  6. #6
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,089
    Blog Entries
    5
    Rep Power
    726
    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 ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    51
    Posts
    1,436
    Blog Entries
    2
    Rep Power
    158
    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.
    running thinBasic in HP Pavillon Desktop 590 a0xxx 8GB Ram AMD A6-9225 Radeon R4 5Compute Cores 2C+3G @2.6GHz

    OS: Windows 11 Enterprise x64 Build 22065 (21H2 pre-release)
    (says the systeminfo. anything else says it were Windows 10 - more or less insider - a lot of the system settings do not function - i could imagine it will not send feedback to microsoft since it always says i need a new app to open that feedback-hub-link. But hey: thinbasic runs well )

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

Posting Permissions

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