Jump to content
Biatu

Check for integer with a zero?

Recommended Posts

I have this script here and im attempting to run this for loop and accumulate an integer, but skip numbers like 0, 10-90, 100-110...basically anything thing that has a zero.

here is my current attempt, but it never works quite right when integers are bigger than 100:

 

Local $iCharIdx=1
For $i=1 To 97
    ConsoleWrite($iCharIdx&@CRLF)
    $iCharIdx+=1
    While Not Mod($iCharIdx,10)
        $iCharIdx+=1
    WEnd
Next

 


What is what? What is what.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

I have this script here and im attempting to run this for loop and accumulate an integer, but skip numbers like 0, 10-90, 100-110...basically anything thing that has a zero.

here is my current attempt, but it never works quite right when integers are bigger than 100:

 

Local $iCharIdx=1
For $i=1 To 97
    ConsoleWrite($iCharIdx&@CRLF)
    $iCharIdx+=1
    While Not Mod($iCharIdx,10)
        $iCharIdx+=1
    WEnd
Next

 

​Yeah....  I don't understand, changing the For loop ubound outputs as expected, skipping every 10th number.... are you trying to skip any number with a zero in it, like skip 101?  Just use StringInStr($i,"0") then?

Share this post


Link to post
Share on other sites

Seems to work : if I try 1 to 200 with you code, no integer divisible by 10 appears in the console.

Also, this should be simplier :

For $i=1 To 200
    If Mod($i, 10) Then ConsoleWrite($i & @CRLF)
Next

 

Share this post


Link to post
Share on other sites

From your description it looks like: 0 or divisible by 10.

But that wouldn't work with, say, 109.

As a low-budget idea, would a StringLen with a StringStripCR & compare the 2 do the trick?

Edit: there were no replies when I started typing. Doesn't say much for my typing speed Eh?

Edited by lorenkinzel

Share this post


Link to post
Share on other sites

I found a workaround, but was hoping to work out a simpler solution. And yes kaisies, any number with a zero in it needed to be skipped..but without any other extra funcs.

Since i already knew the expected size, excluding all the integers with a 0..which is 117 i just used this:
 

Local $iCharIdx=1
For $i=1 To 117
    If StringInStr($i,"0") Then ContinueLoop
    $iCharIdx+=1
Next

$iCharIdx would end at 97 and expected.
 

Edit: Thanx Guys!
Edit2: Patch

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites

I thought using Mod() 10 would work but when it hits 100+ it goes out the window :/

Edit: My original example is a for loop with a BinaryMid function for a character set, whereas im building an index leaving out the 0's.

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...