Randomise picture load into picture gadget?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

I want to randomise the picture loaded into a picture gadget each time I start the program. Any way this can be done? I've tried things for a few hours but not getting anywhere.

Regards, Fang

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
I want to randomise the picture loaded into a picture gadget each time I start the program. Any way this can be done? I've tried things for a few hours but not getting anywhere.
If all your pictures are numbered, you could use the Rnd command to select
one for loading. If they're not numbered, and just random files, just select
a random number and then read all the files in the dir, one by one, and use
the pic that matches the random number chosen at the start of the dir walk.

For example (pseudo-code):

Code: Select all

; Assume 10 pictures in c:\pics\
num=random number from 1 to 10
start reading c:\pics\
  counter=counter+1
  getNextPictureInFolder
  if counter=num
    useThisPic
  endif
stop reading c:\pics\

PB - Registered PureBasic Coder

Edited by - PB on 05 December 2001 13:19:52
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

What I did initially was load the list of files into a list and read to a filename after I generated a random number. But that wasn't the problem.

The picture item is always initialised after the number of gadgets have been declared and there seems to be no way of "plugging in" a new picture there each time I start the program.

When I try to make the image gadget item a variable gadget, even the gadget windows are no longer drawn.

Oh well, I'll try a few more things

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
The picture item is always initialised after the number of gadgets have been declared and there seems to be no way of "plugging in" a new picture there each time I start the program.
I haven't actually used images in PureBasic yet, so I don't really know what
you mean. But if you like, post a code snippet that I can use in PureBasic
to see what you mean...


PB - Registered PureBasic Coder

Edited by - PB on 05 December 2001 23:07:28
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.

[/quote]
I haven't actually used images in PureBasic yet, so I don't really know what
you mean. But if you like, post a code snippet that I can use in PureBasic
to see what you mean...
[/quote]

It's okay, I figured out what I was doing wrong. Just waiting for a compiler fix to happen shortly and then I can implement the rest of my ideas. Anyone is welcome to my source but it won't make much sense if you aren't doing it for IncrediMail addicts.

Why do you always put in "registered PureBasic user" ??? We all know who we are :):):)

Fangles
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.
Why do you always put in "registered PureBasic user" ??? We all know who we are :):):)
I got the idea from wavemaker. :)


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wavemaker.

Well, actually, Wavemaker is my brother, but I use his login since he has dropped interest in PureBasic (has no time for it). And I don't dare changing his signature without permission XD

Bye,

Juan Calderón Alonso
Registered user
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Fangbeast.
Well, actually, Wavemaker is my brother, but I use his login since he has dropped interest in PureBasic (has no time for it). And I don't dare changing his signature without permission XD
I think I'm going to start putting, "Beware the Registered Fangs of PureBasic" :):)

Fangles
Post Reply