|
Pages: [1]
|
 |
|
Author
|
Topic: Select dir modification (Read 632 times)
|
|
JohnW
|
I would like to know if there is a way to modify this script to select the directory instead of having it hard coded in... REBOL [Title: "HTML Thumbnail Photo Generator"]
dir: %product/
make-dir/deep dir/small ; where to keep the thumb
html: "<HTML>" emit: func [data] [repend html data] ; (cookbook example 0006)
view/new layout [ backdrop 00.00.00 i1: image 100x100 effect [aspect] t1: text 80 bold button 80 "Quit" [quit] ]
emit [ <LINK REL="StyleSheet" HREF="style.css" TYPE="text/css" MEDIA="screen">newline <BODY scroll="auto">newline <TABLE class="album" CELLSPACING="6" CELLPADDING="4">newline ]
n: 0 foreach file load dir [ ; Process image files only: if find [%.jpg %.gif] suffix? file [ ; Load the image and show its icon: file: lowercase file photo: load dir/:file i1/image: photo t1/text: file show [i1 t1] wait 0 ; check Quit button
; Create a name for the icon file: icon: copy file clear find/reverse tail icon "." append icon ".png"
; Save the icon image: save/png dir/small/:icon to-image i1
; Add table cell links (and row break if needed): if zero? n // 6 [emit <TR>] emit [ newline <TD align="center" valign="middle"> {<A HREF="} file {" target="_blank">} {<IMG SRC="small/} icon {" border="0">} </A> </TD> ] n: n + 1 new-row: zero? n // 6 if new-row [emit </TR>] ] ] if not new-row [emit </TR>] emit [newline </TABLE> newline ] write dir/album.html html
browse dir/album.html I have tried several variations but I cannot figure it out, John.
|
|
|
|
|
Logged
|
|
|
|
|
PeterWood
|
Try replacing: dir: %product/ with dir: request-dir
|
|
|
|
|
Logged
|
|
|
|
|
JohnW
|
Tried that, unfortunately it produces the following... ** Script Error: new-row has no value ** Near: if not new-row [emit </TR>] emit >>
|
|
|
|
|
Logged
|
|
|
|
|
Anton
|
Hi, I think you got that error because the directory you selected contained no .jpg or .gif files, therefore NEW-ROW was never set a value at all (it is a completely unset word). So trying (after the loop) to get the value of new-row makes an error.
If you open a new console and type:
>> new-row ** Script Error: new-row has no value ** Near: new-row
you can see the same error.
A solution is to give a new-row an initial value (eg. NONE or FALSE) so that it always has a value. eg:
n: 0 new-row: none foreach file ...
or alternatively you could only try to use new-row's value when you know it has one:
if all [n > 0 not new-row][emit </TR>]
(That requires you to think more carefully to understand the code, however.)
On an extra note, the line
|
|
|
|
|
Logged
|
|
|
|
|
Anton
|
On an extra note, the line
file: lowercase file will break the filenames on some filesystems. To be os-independant it's better to preserve the case of filenames.
|
|
|
|
|
Logged
|
|
|
|
|
JohnW
|
I did forget to put the images in the folder, thank you Peter, and Anton it works!
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2294 Posts in 593 Topics by 3751 Members
Latest Member: BSwewattest
|