|
Pages: [1]
|
 |
|
Author
|
Topic: Load next image in a series. (Read 415 times)
|
|
MCHWinder
|
Hi everyone, I'm having a problem loading the next image in a series using a buton command in Rebol View. Here's the code: REBOL [ Title: "What's My Name?" Version: 1.0.0 Author: "Matthew C H Winder" Purpose: {A simple picture naming game.} ]
file-list: [] foreach file sort load %./ [ if %.jpg = suffix? file [append file-list file] ]
f: layout [ ;box for picture b: box "" 640x480 ;place to type name in t: field "" 240 across ;button to load previous image y: button "<<Back" 140x32 navy center [b/image: load first back file-list 640x480 show b] ;button to load next image x: button "Next >>" 140x32 navy center [b/image: load first next file-list 640x480 show b] return ]
;load first image b/image: load first file-list 640x480 show b
view f
The first image loads ok, and the 'next' button will load the next image, but not any of the images after that. I would greatly appreciate any help you could give me. --Matthew
|
|
|
|
|
Logged
|
|
|
|
|
Rocky Shoals
|
The next function returns the block advanced to the next position, but it does not move the current block index to that new position. For that, you need a set-word. Likewise for the back function. Try this code for your buttons.
y: button "<<Back" 140x32 navy center [ file-list: back file-list b/image: load file-list/1 show b ]
x: button "Next>>" 140x32 navy center [ file-list: next file-list b/image: load file-list/1 show b ]
Note that at the head of the block, back doesn't throw an error, it just stays at the head. Same deal for next at the tail. Next and back are series-friendly.
|
|
|
|
|
Logged
|
|
|
|
|
Rocky Shoals
|
And naturally, you may also want to add buttons (in the appropriate place in the layout) for:
w: button "|<" 140x32 navy center [ file-list: head file-list b/image: load file-list/1 show b ]
z: button ">|" 140x32 navy center [ file-list: back tail file-list b/image: load file-list/1 show b ]
|
|
|
|
|
Logged
|
|
|
|
|
MCHWinder
|
Thanks a lot for that, it's working brilliantly now  . --Matthew
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |