Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Switching images

From: ryanc::iesco-dms::com at: 11-May-2001 10:35

This should do it... REBOL [] images: [ ] descriptions: [ "Keep those pesky intruders out!" "Keep traspassers of you lawn!" "Let them know your neighborhood is serious!" "Let other drivers know to beware." "Keep tailgators off your butt!" "No one will steal this car!" "Sale you bomb for lots of money!" ] current: 1 back-one: does [ either current > 1 [ current: current - 1 ] [ current ] ] next-one: does [ either current < ( length? images ) [ current: current + 1 ] [ current ] ] viewer-win: view layout [ vh2 "Looper" theimage: image (pick images current) 300x350 across button "Prev" [ back-one theimage/image: (load pick images current) desc/text: (pick descriptions current) show theimage show desc ] button "Next" [ next-one theimage/image: (load pick images current) desc/text: (pick descriptions current) show theimage show desc ] button "Quit" [quit] return desc: text (pick descriptions current) 250x30 ] images back doesnt work becuase rebol generally works by processing subsequent values. 'Back eats a series and returns the series back one. 'Back also returns the whole series, you just want one part. To do what you were trying to do... first images: back images looks funny... your changing position, storing the changed position, and copying the first value. The reason I did it a little different is so I could use a common index pointer is becuase just a little easier to see whats going on, and an easy retrofit. I could of used index? images to reference the descriptions too. Parenthesis do what you were wanting to do, blocks are just containers. More below... Ross and Ruth Marsden wrote:
> Hello, > I am new to this list and new to REBOL. I got into REBOL by needing to make > some changes to a script at my workplace. The changes were substantial, > required an upgrade of REBOL/Core, worked mostly first try, and I am now > hooked on REBOL. :-) > > Anyway, looking at REBOL/View, I have started a small project so I can say I > have written something from scratch, that is useful, and works. > The aim is to load some images (all the same size) off the net or somewhere, > and display them in turn using controls to show the next, previous, first, > last, play as a loop, adjust looping speed, delays and so on. > > Here is a try... it does not work; just shows a blank image face, and the > controls buttons. > (Comments and questions are below.) > ;> REBOL [] > > images: [ %/c/ensemble/500hPa_height/m500z_f000_shbg_20010504.gif > %/c/ensemble/500hPa_height/m500z_f024_shbg_20010504.gif > %/c/ensemble/500hPa_height/m500z_f048_shbg_20010504.gif > %/c/ensemble/500hPa_height/m500z_f072_shbg_20010504.gif > %/c/ensemble/500hPa_height/m500z_f096_shbg_20010504.gif > %/c/ensemble/500hPa_height/m500z_f120_shbg_20010504.gif > ] > > view layout [ > vh2 "Looper" > theimage: image [images first] 300x350 > across > button "Prev" [theimage/image: [images back] show theimage] > button "Next" [theimage/image: [images next] show theimage] > button "Quit" [quit] > return > name: text "Merlot" 100x30 > button "Change" [name/text: "Cabernet" show name] > ] > ;> 1) In <theimage: image [images first] 300x350>, if <[images first]> is > replaced by <images/1>, the first image is displayed. YeeHa! > But, what's wrong with <images first>?
good question? (first images) is the same as images/1. (images first) is backwards, since first takes the argument after it, not before.
> > 2) The two lines > name: text "Merlot" 100x30 > button "Change" [name/text: "Cabernet" show name] > are to show that this general technique of using a button action to change > the content of a face does work (as suggested in the REBOL/View > documentation HTML page). > That being the case, what is wrong with the lines > button "Prev" [theimage/image: [images back] show theimage] > button "Next" [theimage/image: [images next] show theimage] >
The block should be a paren, the back should be before the series argument, it doesnt store the index, and you need to load the image to put it directly into /image.
> 3) I also tried a placing the button actions in functions like > previmage: does [theimage/image: [images back] show theimage] > but that does not work either. The functions would eventually check > for the current image being the first or last and do something sensible. > > 4) What about <button "Quit" [quit]>? What is the command to close the > REBOL/View child window created by <view layout [faces]> but leave > the REBOL/View console and or Desktop running.
> Is there a command that can be issued from the console to kill a > REVOL/View app window?
Unview/only viewer-win ; in my example becuase I assigned that name to the view. View/new will show the window and keep going.
> This is when the script has stalled, and the > window controls are patchy... the [X] does nothing, but [_] minimises > the window. (We are on Win95, here.) > > Thanks in advance... Sorry about the length for a first post :-[ > Ross Marsden > Wellington, NZ > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
good luck, and dont hesitate to ask, --Ryan