# Small code

## Recommended Posts

I need a code that can make this thing :

```\$a = 0
\$b = 0

While True
\$f = GenerateNumber() ; returns a random integer

\$a = \$f

; Now the problem is that i want something like \$a has the current generated number and
; \$b the previous
; Ex : step 1 : \$a = 10 \$b = 0 ; no previous number generated
;      step 2 : \$a = 20 \$b = 10
;      step 2 : \$a = 110 \$b = 20
; and so on ...
;
; It's driving me nuts !!! Please bring some "light" here.

Wend```
Edited by OmYcroN

##### Share on other sites

hmm ... seems it's something like this :

```\$a = 0
\$b = 0

While True
\$f = GenerateNumber() ; returns a random integer

If \$a == 0 Then
\$a = \$f
Else
\$b = \$a
\$a = \$f
Endif
Wend```

Sorry for the post but now it hit me ...

##### Share on other sites

My version:

```\$a = 0
\$b = 0
\$i = 0
While \$i < 10
\$a = Random(10, 99, 1)
ConsoleWrite("\$a = " & \$a & ", \$b = " & \$b & @CRLF)
\$b = \$a
\$i += 1
Wend```

Br,

UEZ:idea:

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

I had to do the same a while ago.

Here you go:

```HotKeySet("{ESC}", "_Exit")

Global \$a = 0, \$b = 0

While Sleep(25)
\$f = Random(1, 100, 1)
\$b = \$a
\$a = \$f

MsgBox(0, "", "Current generated number:    " & \$a & @CRLF & "Previous generated number:    " & \$b)
WEnd

Func _Exit()
Exit
EndFunc```

EDIT: Didn't saw UEZ's post. Both options both ^^

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

## Create an account

Register a new account

×

• Wiki

• Back

• Git