repeated send-comands

Klaus Major klaus at major-k.de
Mon Sep 22 16:14:01 EDT 2003


Hi Richard,

here's a quick and dir... er, clean hack to get you started :-)

Its a modified stack of mine "autoslide_lite", so there are still some 
comments :-)

This example will even loop through all images and will start over 
again with the first image
after the last image has been shown...

on preopenstack
   global der_pfad, gesamtbilder,aktuellesbild,diebilder
   ## german for the_path, totalimages, currentimage, theimages

   ## Here we store the complete and absolute path to the images,
   ## the number of images, the number of the current image and a list 
of all
   ## available image-files, the ones in the folder "bilder"... (german 
for images)

   put 1 into aktuellesbild
   ## We should really start with the first image, to not confuse the 
audience ;-) See script of cd 1

   set the itemdel to "/"
   get the filename of this stack
   delete item -1 of it
   put it & "/bilder/" into der_pfad
   ## my example has all the images in a folder called "bilder", change 
to your needs...
   ## Will store the absolute path to the folder containing our images!!!

   set the directory to der_pfad
   ## Now we are inside this folder...

   put the files into diebilder
   ## store the filenames in the variable diebilder
   ## Ready!
end preopenstack


Script of first (and only :-) card:

on openCard
   global der_pfad, gesamtbilder,aktuellesbild,diebilder
   ## See the stackscript for explanation of variable names...

   if char 1 of line 1 of diebilder = "." then delete line 1 of diebilder
   ## Only for Mac OS X -> ".DS_Store"

   put the num of lines of diebilder into gesamtbilder
   ## You get the picture...

   set the filename of img "anzeige" to (der_pfad & line aktuellesbild 
of diebilder)
   ## We create an absolute path...

  ## Do your custom scaling etc... here...

  ## Now we start the automatic slideshow:
  ## The next 3 lines could be put into a button to start the show with 
a click, too...

   send "nextimage" to this cd in 2 secs ## or whatever
   global going_on
   put the result into going_on
   ## This will put the id of the "nextimage" message into a global var
   ## and we can cancel it later via a simple mouseclick :-)
end openCard

##Put this in the cardscript, too!

on nextimage
   global der_pfad, gesamtbilder,aktuellesbild,diebilder

   if aktuellesbild < gesamtbilder then
     ## We did not reach the last image yet...

     put aktuellesbild + 1 into aktuellesbild
   else

     ## This is the last image, so we start over again...
     put 1 into aktuellesbild
   end if

   lock screen
   set the filename of img "anzeige" to (der_pfad & line aktuellesbild 
of diebilder)
  ## Do your custom scaling etc... here...

   unlock screen with visual dissolve very slow
   ## Here we finally display the image
end nextimage


Then you need your button to cancel the show:

on mouseup
    global going_on
    cancel going_on
end mouseup


You could consider to have another button to start the show...
See above in the script of "nextimage"...

Drop a line for more info/assistance :-)


Hope that helps...


Regards

Klaus Major
klaus at major-k.de
www.major-k.de




More information about the use-livecode mailing list