Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Load next image in a series.
Pages: [1] Print
Author Topic: Load next image in a series.  (Read 315 times)
MCHWinder
Newbie
*
Offline Offline

Posts: 2


View Profile
Load next image in a series.
« on: November 29, 2007, 08:34:31 AM »

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:
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
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: Load next image in a series.
« Reply #1 on: November 29, 2007, 02:32:44 PM »

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
Newbie
*
Offline Offline

Posts: 5


View Profile
Re: Load next image in a series.
« Reply #2 on: November 29, 2007, 02:44:32 PM »

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
Newbie
*
Offline Offline

Posts: 2


View Profile
Re: Load next image in a series.
« Reply #3 on: November 29, 2007, 04:00:55 PM »

Thanks a lot for that, it's working brilliantly now Smiley.

--Matthew
Logged
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Load next image in a series.
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 24, 2008, 06:59:44 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2191 Posts in 572 Topics by 1684 Members
Latest Member: CinemeandaBek

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc