Lawrence,
Welcome to MetaCard! Let me see if I can address your issue:
> on makePictures
> #REM openfile with image names and make cards for each file name
> put 0 into increment
> put empty into picture
>
> open file "volume2001_1images.txt" for read #REM open list of
images file
> repeat until eof
> read from file "volume2001_1images.txt" until return # REM get image
file name
You can certainly do file reading this way (and in fact, it's the only way
in Basic), but MC gives you a much better approach, especially if the
contents of the file is not too large (i.e. multiple megabytes). Read in the
file into a variable and then loop through with "repeat for each line of
<x>", as in:
open file "volume2001_images.txt" for read
read from file "volume2001_images.txt" until eof #Reads the whole file in
in one shot
put it into tData
close file "volume2001_images.txt"
repeat for each line tLine in tData
# each time through the loop it gets the next "line" of data
>
> add 1 to increment # increment counter add next element to array
> put char 1 to 6 of it into picture[increment] # Put 6 letters of
image file name into array
>
> if picture[increment] is not empty then
> clone image "postcard" #clone an existing card
It looks like you're cloning an image, not a card... is this true? Did you
mean to say "clone card"?
> #### NG create invisible image picture[increment] # Make a new
image card and NAME it 6 letters of file name
>
> wait 3 seconds # shows it exec quits before next line of code
> put it into field id 1021 # TESTER
>
> set the name of image "postcard" to picture[increment]
> set the effective fileName of image picture[increment] to
picture[increment] & ".gif" # Put file name into image card
> end if
>
>
> if picture[increment] is empty then exit repeat
>
> end repeat
> close file "volume2001_1images.txt"
>
> end makePictures
>
> One last knotty problem. The last card in my stack is ID 1031. Each "clone
or create" takes the next ID. I delete each
> new card that is "cloned/created" but the ID number keeps growing -- I am
now nearing ID 1500 and cannot find a way
> to reset? start again at ID 1032...??? Does it matter? Can IDs go up to
999,999,999?
Don't worry about IDs... it doesn't matter - IDs can go way up there... I
don't even know if there's a limit.
If I'm interpreting properly, you want to create a new card for each new
picture you read from the text file. I'm assuming you have a card named
"postcard" and an image on that card named "postcard". (If this is true, I'd
suggest renaming one of them to avoid confusion.) Here's how I would do it;
perhaps you can glean from the code below what would fix your problem:
on makePictures
put 0 into increment
# put empty into Pictures -- This is not necessary as local variables
are by default empty
open file "volume2001_images.txt" for read
read from file "volume2001_images.txt" until eof #Reads the whole file
in in one shot
put it into tData
close file "volume2001_images.txt"
repeat for each line tLine in tData
if tLine is not empty then
add 1 to increment
put char 1 to 6 of tLine into picture[increment]
clone card "postcard"
set the name of image "postcard" to picture[increment]
set the filename of image "postcard" to picture[increment] &
".gif"
# you don't need "effective" in this case; there's no
inheritance going on
else
exit repeat
end if
end repeat
end makePictures
Hope this helps,
Ken Ray
Sons of Thunder Software
Email: [EMAIL PROTECTED]
Website: http://www.sonsothunder.com/
Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.