PDA

View Full Version : daily image array


gcapp
04-16-2003, 02:33 PM
Does any one out there know of a simple image array where I can display a different image for everyday of the year?

I know I can do one like:

Dim TEnd(365)
TEnd(0)="http://www.enchantedmountains.info/images/home-page/daily-photo/summer/amish-130.jpg"
TEnd(1)="http://www.enchantedmountains.info/images/home-page/daily-photo/summer/bartlett-130.jpg"
TEnd(2)="http://www.enchantedmountains.info/images/home-page/daily-photo/fall/sciencelake-130.jpg"
TEnd(3)="http://www.enchantedmountains.info/images/home-page/daily-photo/summer/golfer-130.jpg"

and so on, but I would have to list 364 line items. I thought there may be an easier way.

Any ideas??

Gary

david7777
04-16-2003, 02:52 PM
My best guess would be to rename all your iamges to 1.gif, 2.gif... 365.gif. Then use a loop.


Dim TEnd(365)
i = 0
do while i <365
TEnd(i) = i & ".gif"
i=i+1
loop


But that might be more work then just coding the long way...

Maybe you could use the file system:
If you have all the images in a certain directory like "dailypics", then you could maybe check all the files in the directory and sort them alphabetically, then use the one that corresponds to the day of the year.

ie: if it is the 195th day of the year, you would use the 195th file in the directory after sorting it... Again - it might be more trouble than it is worth...

raf
04-16-2003, 03:25 PM
Easiest way: name the images accordingly to the 'daynumber' (01/01/2003 = 1.gif, etc) Then, in your script, you compute the daynumber with DateDiff(y, Date, 01/01/Year(Now)).
Something similar like david 7777 said

Personally, i would create a table(or an application-array !) with the id (from 1 to 365), the filename and alternative message for the image and then select the filename and alternative message using the daynumber as a condition. Easier to manage, better cause of the meaningful filenames and alternative messages, but slightly more overhead at runtime. (make sure to have a command that loads the array in your global.asa's Application_OnStart sub. just in case the app. goes down).

david7777
04-17-2003, 09:04 AM
If you were to go that route though, i think it might be better to create an XML file and use that instead. If you are using ASP.NET, then you could also impliment caching for the file, as to enable a more speedy approach... Im not sure if you can use that sort of caching in classic ASP.

If you want some help on that, just let me know:)