Jump to content

Help with storing an incremental value in array


Terenz
 Share

Recommended Posts

Hello guys.
 
It's a little difficult for me to explay what i need to do, if someone don't understand tell me.
I need to store an incremental variable in an array and the compare with a string. This is a scheme:
$N_NUMBER = 4
$N_TOTAL = 5

$VALUE1 = $N_NUMBER
$VALUE2 = ($N_NUMBER * 2) + 1
$VALUE3 = ($N_NUMBER * 3) + 2
$VALUE4 = ($N_NUMBER * 4) + 3
; $VALUE number = $N_TOTAL - 1

$EXAMPLE = 9 ; example number

If $EXAMPLE = $VALUE1 Or $EXAMPLE = $VALUE2 Or $EXAMPLE = $VALUE3 Or $EXAMPLE = $VALUE4 Or $EXAMPLE = $VALUE5 Then
    ConsoleWrite("Success")
EndIf

I don't know $N_TOTAL variable, can be 5 or 10

$VALUE so must to be an array,the size is base by $N_TOTAL - 1 but the number is incremental and multiplied, i don't know who to store it. At the end i need to compare the string $EXAMPLE with the array $VALUE, without do all that OR

Some help? Thanks

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

I have do it in this way:

$N_NUMBER = 4
$N_TOTAL = 5
Local $TEST[$N_TOTAL - 1]

;~ $VALUE1 = $N_NUMBER ; 4
;~ $VALUE2 = ($N_NUMBER * 2) + 1 ;9
;~ $VALUE3 = ($N_NUMBER * 3) + 2 ;14
;~ $VALUE4 = ($N_NUMBER * 4) + 3 ;19
; $VALUE number = $N_TOTAL - 1

$TEST[0] = $N_NUMBER
For $x = 1 To $N_TOTAL - 2
    Local $j
    $j += 1
    $TEST[$x] = $N_NUMBER * ($x + 1) + $j
Next

;~ MsgBox(0, 0, $TEST[0])
;~ MsgBox(0, 0, $TEST[1])
;~ MsgBox(0, 0, $TEST[2])
;~ MsgBox(0, 0, $TEST[3])

$EXAMPLE = 9 ; example number

For $x = 0 To UBound($TEST)
    If $EXAMPLE = $TEST[$x] Then
        MsgBox(0, 0, "Success")
        ExitLoop
    EndIf
Next

Is correct or there is a better way?

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

#include <Array.au3>
$N_NUMBER = 4
$N_TOTAL = 4
Local $TEST[$N_TOTAL]

For $i = 0 To UBound($TEST)-1
    $TEST[$i] = $N_NUMBER * ($i+1) + $i
Next

$bFound = False
For $i = 0 To UBound($TEST)-1
    If $TEST[$i] = 9 Then
        $bFound = True
        ExitLoop
    EndIf
Next
If $bFound Then MsgBox(1,1,"success on dim=[" & $i & "]")

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

×
×
  • Create New...