Sign in to follow this  
Followers 0
egalvez

Math syntax I'm having trouble with...

4 posts in this topic

I was a math major long ago, but I'm drawing a blank on this one. :) I suspect someone else can figure this out in less than a minute. I have a For/Next loop that goes from 1 to 500. I need to be able to tell which group x falls in (see graphic for the two groups). Here's what I want the code to say, but I don't know how to word the If x is in Group 1 Then and the ElseIf x is in Group 2. I realize I probably don't need the ElseIf, i.e., it could probably just be a plain Else.

For x = 1 to 500
    If x is in Group 1 Then
        do something here
    ElseIf x is in Group 2 Then
        do something here
    EndIf
Next

Here are the groups:

Posted Image

Thank you. :D

Share this post


Link to post
Share on other sites



Some logic to identify Group1 and Group2:

For $x = 1 to 500
    If ($x/16) - Int($x/16) = 0 Then
        $group = 2
    ElseIf ($x/16) - Int($x/16) < .51 Then
        $group = 1  
    Else
        $group = 2  
    EndIf
    MsgBox(262144,'Debug',"x=" & $x & "  $group=" & $group);### Debug MSGBOX
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I was a math major long ago, but I'm drawing a blank on this one. :)  I suspect someone else can figure this out in less than a minute.  I have a For/Next loop that goes from 1 to 500.  I need to be able to tell which group x falls in (see graphic for the two groups).  Here's what I want the code to say, but I don't know how to word the If x is in Group 1 Then and the ElseIf x is in Group 2.  I realize I probably don't need the ElseIf, i.e., it could probably just be a plain Else.

For x = 1 to 500
    If x is in Group 1 Then
        do something here
    ElseIf x is in Group 2 Then
        do something here
    EndIf
Next

<{POST_SNAPBACK}>

The Mod function.

For $x = 0 To 33
   $iRem = Mod($x, 16)
   If $iRem > 0 And $iRem < 9 Then
      MsgBox(4096, "Group1", $X & " = Group1", 1)
   Else
      MsgBox(4096, "Group2", $X & " = Group2", 1)
   EndIf
Next

Phillip

Share this post


Link to post
Share on other sites

Thank you for your help, both of you.

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
Sign in to follow this  
Followers 0