SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    If iOccurs == null

    If I have an integer iOccurs that has no assigned value, is it not considered null?

    Calling if iOccurs == null is throwing an exception. How do I check for a null value on an integer? I'm probably missing something really simple here.



    ------------------

  2. #2
    Junior Member
    Join Date
    Sep 2001
    Location
    Fremont, CA
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    It's considered unset when a variable is declared but unassigned. IsSet(iOccurs) should be used.

    Chris

    ------------------

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    There are two separate functions to handle two slightly different conditions.

    IsSet( iOccurs )

    IsNull( iOccurs )

    The distinction between Set and Null is not always consistent. Elements of a record are usually initialized as Null even though they are not Set.


    ------------------
    Rob Kapteyn
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    IsSet( iOccurs )
    IsNull( iOccurs )

    Are the safest way for your purpose, but keep in mind that(in silk) if your variable is unset at the time of a comparison(or any other use) there will be an exception thrown at you. If you want to be safe always set an initial value to all variables(ex:list use {},string use "",int 0).



    ------------------

  5. #5
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    To add another 2 cents to the pile, null values are something you want to check and provide an initial value for when they're the result of being passed in as optional parameters.

    foo(int x optional)
    if (x == NULL) x = 0
    ...


    John


    ------------------


    [This message has been edited by John J. Miller (edited 08-19-2002).]

  6. #6
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    Thanks for all the responses. I knew there had to be a simple solution. I appreciate it.



    ------------------

  7. #7
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    I have found this function invaluable for quickly checking that a variable or constant has a value:

    ------------------

  8. #8
    Senior Member
    Join Date
    Jul 1999
    Location
    Bellingham, WA USA
    Posts
    1,323
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: If iOccurs == null

    See, this is why I love this forum.

    ------------------

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:44 AM.

Copyright BetaSoft Inc.