RandomData()
语法
RandomData(*Buffer, Length)概要
Fills the specified memory buffer with random data.
参数
*Buffer The memory address of the buffer to fill. Length The size of the buffer to fill.
返回值
无.
Remarks
This command uses the same random seed as the Random() command. RandomSeed() may be used to change the random number seed.
Note: This command uses a pseudorandom number generator which is very fast and produces randomly looking output but it is not strong enough for cryptographic purposes. The slower CryptRandomData() command can be used if more secure random number generation is required.
示例
; Create an image with random content ; CreateImage(0, 200, 200) If StartDrawing(ImageOutput(0)) *Buffer = DrawingBuffer() Pitch = DrawingBufferPitch() RandomData(*Buffer, Pitch*200) StopDrawing() EndIf OpenWindow(0, 0, 0, 200, 200, "Random Image", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ImageGadget(0, 0, 0, 200, 200, ImageID(0)) Repeat Until WaitWindowEvent() = #PB_Event_CloseWindow
参阅
RandomSeed(), Random(), CryptRandomData()
已支持操作系统
所有