SPONSORS:






User Tag List

Results 1 to 6 of 6
  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)

    Stuff( ) can\'t accept zero as a valid parameter.

    The following code is examining strings that are being pulled from an ini file. These are mostly numerical values, however, some of them are preceded by an upper case V. I want to strip that V off. However, in the case that the V is not there, the StrPos() method will return a position of 0 which seemingly Stuff( ) can't deal with. Any suggestions? I have an idea or two, but want to know if there is a quick fix that might pop up here.

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

  2. #2
    Member
    Join Date
    Sep 2002
    Location
    Chicago, Illinois, USA
    Posts
    90
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff( ) can\'t accept zero as a valid parameter.

    Try this:

    INTEGER iYourCodeHardToRead = StrPos("V", GetSetupValue("HWSensitiveCodes", "DRangeZeroStart", True))

    (iYourCodeHardToRead > 0) ? iYourCodeHardToRead : 1

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

  3. #3
    Member
    Join Date
    Jun 2001
    Location
    Berkeley, CA, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff( ) can\'t accept zero as a valid parameter.

    Another method to try:

    if (sVar[1] == "V")
    {
    sVar[1] = " "
    sVar = Trim(sVar)
    }


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

  4. #4
    Senior Member
    Join Date
    Dec 2001
    Location
    Bozeman, MT, USA
    Posts
    265
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff( ) can\'t accept zero as a valid parameter.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by silk1:
    Try this:

    (iYourCodeHardToRead &gt; 0) ? iYourCodeHardToRead : 1

    <HR></BLOCKQUOTE>

    What is the name of that type of if statement again?

    ------------------
    Ryan McCullough
    Accelrys Inc.
    ryan@accelrys.com
    Ryan McCullough
    RightNow Tech. Inc.

  5. #5
    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: Stuff( ) can\'t accept zero as a valid parameter.

    Silk1,

    I realize that line is not the most elegant. In fact, you say it is hard to read... It was hard to write, but there are some constraints on this end that made it necessary to do that in one call, so I had to 1)Get the ini value of my variable 2) Get the positon of the "V" in that value 3) Strip it out, and 4) Convert the string to a number, all in one call.

    Ended up bagging the whole approach and writing a function that does what I need. There are about 30 of these values I need to do this to, so I read them into an array and am manipulating the array instead.

    Thanks all for your feedback. I LOVE this forum!

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

  6. #6
    Senior Member
    Join Date
    Jul 2001
    Location
    Westford, MA, USA
    Posts
    160
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stuff( ) can\'t accept zero as a valid parameter.

    Ryan -- It's not a statement -- it's the ?: operator. It exists in C as well. It's a ternary operator -- has three operands. Given that 4Test supports built-in booleans, here's how it goes: leftmost operator is evaluated first; if it resolves to true, the middle operand is evaluated next and the last operand is ignored; otherwise (if false), the third operand is evaluated and the middle operand is ignored.

    So in other words, it's an if/else.

    4Test calls this the conditional operator, and it's in the 5.5.3 online help under "? operator."
    AG

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

 

 

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 09:01 AM.

Copyright BetaSoft Inc.