Jump to content

Save a group of numbers to one number


Recommended Posts

#include <Array.au3>

$ByteA = 256
$ByteB = 128
$ByteC =  64
$ByteD =  32

$bBySet = 0 ; 32 MaxD And of $ByteD // From 1 to 32
$bBySet += ($ByteD - 1) * 256 * 128 * 64 ; 64 MaxC And of $ByteC // From 1 to 64
$bBySet += ($ByteC - 1) * 256 * 128 ; 128 MaxB And of $ByteB // From 1 to 128
$bBySet += ($ByteB - 1) * 256 ; 256 MaxA And Of $ByteA // From 1 to 256
$bBySet += $ByteA

MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")

$ByteA = 200
$ByteB = 90
$ByteC =  50
$ByteD =  10

$bBySet = 0 ; 32 MaxD And of $ByteD ; // From 1 to 32
$bBySet += ($ByteD - 1) * 256 * 128 * 64 ; 64 MaxC And of $ByteC // From 1 to 64
$bBySet += ($ByteC - 1) * 256 * 128 ; 128 MaxB And of $ByteB // From 1 to 128
$bBySet += ($ByteB - 1) * 256 ; 256 MaxA And Of $ByteA // From 1 to 256
$bBySet += $ByteA

MsgBox(0,"Msg",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")

$ByteA = 256
$ByteB = 256
$ByteC = 256
$ByteD = 256
$ByteE = 256
$ByteF = 256
$ByteG = 256
$ByteH = 128 - 1
; Max Autoit Reference Num = In caluclator scientific (256 * 256 * 256 * 256 * 256 * 256 * 256 * 128) - 1
; 9223372036854775807

$bBySet = 0
$bBySet += ($ByteH - 1) * 256 * 256 * 256 * 256 * 256 * 256 * 256
$bBySet += ($ByteG - 1) * 256 * 256 * 256 * 256 * 256 * 256
$bBySet += ($ByteF - 1) * 256 * 256 * 256 * 256 * 256
$bBySet += ($ByteE - 1) * 256 * 256 * 256 * 256
$bBySet += ($ByteD - 1) * 256 * 256 * 256
$bBySet += ($ByteC - 1) * 256 * 256
$bBySet += ($ByteB - 1) * 256
$bBySet += $ByteA

MsgBox(0,"Msg",$bBySet)

$cByArray = NumGet($bBySet,256,256,256,256,256,256,127)
_ArrayDisplay($cByArray,"")

Func NumGet($NuSet,$MaxA,$MaxB,$MaxC = 1,$MaxD = 1,$MaxE = 1,$MaxF = 1,$MaxG = 1,$MaxH = 1)

if $NuSet = 1 Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = 1

Else
if $NuSet <= $MaxA Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = $NuSet

Else
if $NuSet <= ($MaxA * $MaxB) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE) Then

$NuH = 1
$NuG = 1
$NuF = 1

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF) Then

$NuH = 1
$NuG = 1

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG) Then

$NuH = 1

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else

$NuH = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG * $MaxH))
$vMod = $NuH
$NuH = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)) Then $NuH += 1
if Not $NuH Then $NuH = $MaxH

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

Dim $NusAry[8]
$NusAry[0] = $NuA
$NusAry[1] = $NuB
$NusAry[2] = $NuC
$NusAry[3] = $NuD
$NusAry[4] = $NuE
$NusAry[5] = $NuF
$NusAry[6] = $NuG
$NusAry[7] = $NuH

Return $NusAry

EndFunc

 

Edited by wolf9228

صرح السماء كان هنا

 

Link to post
Share on other sites

This is simply amazing;:frantics: who would have thought that up to eight fat bytes could be squeezed into a single tiny int64?

$ByteA = 123
$ByteB = 234
$ByteC = 25
$ByteD = 255
$ByteE = 111
$ByteF = 0
$ByteG = 77
$ByteH = 99

$bytesbuffer=DllStructCreate("align 8;byte[8]")
$int64buffer=DllStructCreate("int64",DllStructGetPtr($bytesbuffer))

DllStructSetData($bytesbuffer,1,$ByteA,1)
DllStructSetData($bytesbuffer,1,$ByteB,2)
DllStructSetData($bytesbuffer,1,$ByteC,3)
DllStructSetData($bytesbuffer,1,$ByteD,4)
DllStructSetData($bytesbuffer,1,$ByteE,5)
DllStructSetData($bytesbuffer,1,$ByteF,6)
DllStructSetData($bytesbuffer,1,$ByteG,7)
DllStructSetData($bytesbuffer,1,$ByteH,8)

ConsoleWrite("As one large integer: " & DllStructGetData($int64buffer,1) & @CRLF)

ConsoleWrite("As eight bytes: " & @CRLF)
For $index=1 To 8
    ConsoleWrite("Byte " & $index & " = " & DllStructGetData($bytesbuffer,1,$index) & @CRLF)
Next

EDIT: I guess I'm going to have to find myself a sarcasm-emoji; maybe :ermm:;)?

Edited by RTFC
Link to post
Share on other sites
1 hour ago, RTFC said:

This is simply amazing;:frantics: who would have thought that up to eight fat bytes could be squeezed into a single tiny int64?

$ByteA = 123
$ByteB = 234
$ByteC = 25
$ByteD = 255
$ByteE = 111
$ByteF = 0
$ByteG = 77
$ByteH = 99

$bytesbuffer=DllStructCreate("align 8;byte[8]")
$int64buffer=DllStructCreate("int64",DllStructGetPtr($bytesbuffer))

DllStructSetData($bytesbuffer,1,$ByteA,1)
DllStructSetData($bytesbuffer,1,$ByteB,2)
DllStructSetData($bytesbuffer,1,$ByteC,3)
DllStructSetData($bytesbuffer,1,$ByteD,4)
DllStructSetData($bytesbuffer,1,$ByteE,5)
DllStructSetData($bytesbuffer,1,$ByteF,6)
DllStructSetData($bytesbuffer,1,$ByteG,7)
DllStructSetData($bytesbuffer,1,$ByteH,8)

ConsoleWrite("As one large integer: " & DllStructGetData($int64buffer,1) & @CRLF)

ConsoleWrite("As eight bytes: " & @CRLF)
For $index=1 To 8
    ConsoleWrite("Byte " & $index & " = " & DllStructGetData($bytesbuffer,1,$index) & @CRLF)
Next

 

int64 is two sets ... the number of elements of the two groups is equal, the first is positive plus zero and the other is negative. The probabilities of int64 complete are equal to 256 to the power of 8

صرح السماء كان هنا

 

Link to post
Share on other sites

https://docs.microsoft.com/en-us/dotnet/api/system.int64?view=net-5.0

 

Int64 is an immutable value type that represents signed integers with values that range from negative 9,223,372,036,854,775,808 (which is represented by the Int64.MinValue constant) through positive 9,223,372,036,854,775,807 (which is represented by the Int64.MaxValue constant. The .NET Framework also includes an unsigned 64-bit integer value type, UInt64, which represents values that range from 0 to 18,446,744,073,709,551,615.

صرح السماء كان هنا

 

Link to post
Share on other sites
On 3/5/2021 at 11:09 PM, wolf9228 said:

Add one to the saved numbers
$ByteA = 0
$ByteB = 0
$ByteC =  0
$ByteD =  32

$bBySet = 0 ; 32 MaxD And of $ByteD // From 1 to 32
$bBySet += ($ByteD - 1) * 256 * 128 * 64 ; 64 MaxC And of $ByteC // From 1 to 64
$bBySet += ($ByteC - 1) * 256 * 128 ; 128 MaxB And of $ByteB // From 1 to 128
$bBySet += ($ByteB - 1) * 256 ; 256 MaxA And Of $ByteA // From 1 to 256
$bBySet += $ByteA

;~ MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")

Not getting the results I expected, or I am not understanding how it is supposed to work.

Link to post
Share on other sites
On 3/7/2021 at 2:53 PM, spudw2k said:
$ByteA = 0
$ByteB = 0
$ByteC =  0
$ByteD =  32

$bBySet = 0 ; 32 MaxD And of $ByteD // From 1 to 32
$bBySet += ($ByteD - 1) * 256 * 128 * 64 ; 64 MaxC And of $ByteC // From 1 to 64
$bBySet += ($ByteC - 1) * 256 * 128 ; 128 MaxB And of $ByteB // From 1 to 128
$bBySet += ($ByteB - 1) * 256 ; 256 MaxA And Of $ByteA // From 1 to 256
$bBySet += $ByteA

;~ MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")

Not getting the results I expected, or I am not understanding how it is supposed to work.

There is a maximum that must be adhered to during set and get. I will give other examples later ... Thanks.

صرح السماء كان هنا

 

Link to post
Share on other sites

New Example

#include <Array.au3>

$NumA = 256
$NumB = 128
$NumC =  64
$NumD =  32


$bBySet = NumbSet(256,$NumA,128,$NumB,64,$NumC,32,$NumD)

MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")


$NumA = 25
$NumB = 12
$NumC =  6
$NumD =  3


$bBySet = NumbSet(256,$NumA,128,$NumB,64,$NumC,32,$NumD)

MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")


$NumA = 200
$NumB = 100
$NumC =  50
$NumD =  25


$bBySet = NumbSet(256,$NumA,128,$NumB,64,$NumC,32,$NumD)

MsgBox(0,"",$bBySet)

$cByArray = NumGet($bBySet,256,128,64,32)
_ArrayDisplay($cByArray,"")


Func NumbSet($MaxNuA , $NuA ,$MaxNuB,$NuB,$MaxNuC = 1,$NuC = 1,$MaxNuD = 1,$NuD = 1, _
$MaxNuE = 1,$NuE = 1,$MaxNuF = 1,$NuF = 1,$MaxNuG = 1,$NuG = 1,$MaxNuH = 1,$NuH = 1)

if $MaxNuA < 1 Or $NuA < 1 Or $MaxNuB < 1 Or $NuB < 1 Or $MaxNuC < 1 Or $NuC < 1 Or _
$MaxNuD < 1 Or $NuD < 1 Or $MaxNuE < 1 Or $NuE < 1 Or $MaxNuF < 1 Or $NuF < 1 Or _
$MaxNuG < 1 Or $NuG < 1 Or $MaxNuH < 1 Or $NuH < 1 Then Return SetError(1,0,0)

if $NuA > $MaxNuA or $NuB > $MaxNuB or $NuC > $MaxNuC or $NuD > $MaxNuD or _
$NuE > $MaxNuE or $NuF > $MaxNuF or $NuG > $MaxNuG or $NuH > $MaxNuH Then Return SetError(2,0,0)

$ByteSet = 0
$ByteSet += ($NuH - 1) * $MaxNuA * $MaxNuB * $MaxNuC * $MaxNuD * $MaxNuE * $MaxNuF * $MaxNuG
$ByteSet += ($NuG - 1) * $MaxNuA * $MaxNuB * $MaxNuC * $MaxNuD * $MaxNuE * $MaxNuF
$ByteSet += ($NuF - 1) * $MaxNuA * $MaxNuB * $MaxNuC * $MaxNuD * $MaxNuE
$ByteSet += ($NuE - 1) * $MaxNuA * $MaxNuB * $MaxNuC * $MaxNuD
$ByteSet += ($NuD - 1) * $MaxNuA * $MaxNuB * $MaxNuC
$ByteSet += ($NuC - 1) * $MaxNuA * $MaxNuB
$ByteSet += ($NuB - 1) * $MaxNuA
$ByteSet += $NuA

Return SetError(0,0,$ByteSet)

EndFunc

Func NumGet($NuSet,$MaxA,$MaxB,$MaxC = 1,$MaxD = 1,$MaxE = 1,$MaxF = 1,$MaxG = 1,$MaxH = 1)

if $NuSet = 1 Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = 1

Else
if $NuSet <= $MaxA Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = $NuSet

Else
if $NuSet <= ($MaxA * $MaxB) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE) Then

$NuH = 1
$NuG = 1
$NuF = 1

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF) Then

$NuH = 1
$NuG = 1

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG) Then

$NuH = 1

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else

$NuH = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG * $MaxH))
$vMod = $NuH
$NuH = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)) Then $NuH += 1
if Not $NuH Then $NuH = $MaxH

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

Dim $NusAry[8]
$NusAry[0] = $NuA
$NusAry[1] = $NuB
$NusAry[2] = $NuC
$NusAry[3] = $NuD
$NusAry[4] = $NuE
$NusAry[5] = $NuF
$NusAry[6] = $NuG
$NusAry[7] = $NuH

Return $NusAry

EndFunc

 

صرح السماء كان هنا

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...