Что нового

Помогите пожалуйста сделать правильно сложный рандом

Dotacka

Новичок
Сообщения
37
Репутация
0
Добрый день !

Есть такой код :

Код:
;берем данные-----------------------------------------------------------------------------------------

ClipPut(FileReadLine("Box.txt", 1))
Sleep (100)
$boxgold = ClipGet()
Sleep (100)

;Удаляем строчку---------------------------------------------------------------------------------------

$filename = 'Box.txt'
$hFile = FileOpen(@ScriptDir & '\' & $filename, 0)
local $array[0]

While 1
    $sLine = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    _ArrayAdd($array, $sLine)
WEnd

FileClose($hFile)
$hFile = FileOpen(@ScriptDir & '\' & $filename, 2)

For $aa = 1 to ubound($array)-1
   FileWriteLine($hFile, $array[$aa])
Next

FileClose($hFile)
Sleep (100)

;Берем данные из второй строчки---------------------------------------------------------------------------------------

ClipPut(FileReadLine("Box2.txt", 1))
Sleep (100)
$boxgold2 = ClipGet()
Sleep (100)

;Удаляем строчку---------------------------------------------------------------------------------------

$filename = 'Box2.txt'
$hFile = FileOpen(@ScriptDir & '\' & $filename, 0)
local $array[0]

While 1
    $sLine = FileReadLine($hFile)
    If @error = -1 Then ExitLoop
    _ArrayAdd($array, $sLine)
WEnd

FileClose($hFile)
$hFile = FileOpen(@ScriptDir & '\' & $filename, 2)

For $aa = 1 to ubound($array)-1
   FileWriteLine($hFile, $array[$aa])
Next

FileClose($hFile)
Sleep (100)

; Результирующая------------------------------------------------------------------------------

$BoxCollect = $boxgold1 & $boxgold2



Как сделать рандом что бы скрипт брал одну либо две строки?

А результат соответственно был :
Код:
$BoxCollect = $boxgold1 & $boxgold2

или 

$BoxCollect = $boxgold1
 

InnI

AutoIT Гуру
Сообщения
4,922
Репутация
1,432
Три строки нужно добавить
Код:
...

FileClose($hFile)
Sleep (100)

$boxgold2 = ""            ; <= добавить
If Random(0, 1, 1) Then   ; <= добавить

;Берем данные из второй строчки---------------------------------------------------------------------------------------

ClipPut(FileReadLine("Box2.txt", 1))
...

FileClose($hFile)
Sleep (100)

EndIf   ; <= добавить

; Результирующая------------------------------------------------------------------------------

$BoxCollect = $boxgold1 & $boxgold2
 
Автор
D

Dotacka

Новичок
Сообщения
37
Репутация
0
Три строки нужно добавить
Код:
...

FileClose($hFile)
Sleep (100)

$boxgold2 = ""            ; <= добавить
If Random(0, 1, 1) Then   ; <= добавить

;Берем данные из второй строчки---------------------------------------------------------------------------------------

ClipPut(FileReadLine("Box2.txt", 1))
...

FileClose($hFile)
Sleep (100)

EndIf   ; <= добавить

; Результирующая------------------------------------------------------------------------------

$BoxCollect = $boxgold1 & $boxgold2

Cпасибо
 
Верх