Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rounding

Status
Not open for further replies.

jvdboom

Programmer
Joined
Aug 18, 2002
Messages
93
Location
BE
I have a filenames like sint-001.jpg , sint-002.jpg,... running in a loop
a)is there a fast way to get those zeros before the number or a way to perform an function like int() in VB or perl and then get each digit by dividing-rouding-multiplying?
b)is there a way to dedect what the last one is?
 
yes a slideshow with fader it wil come then in an preload aray with .src the code I have already for that.the only thing I have to do is get the path to the files in that array from /data/images/sint/sint-001 to /data/images/sint/sint-041 of course i can use >10 for that but i will someday reuse the code...
 
I made this slide show script and it works pretty good. With it, you don't have to know how many images you have. I preload the image to see if it exists. If it does, it shows it and continues to the next image after four seconds. If it doesn't, it starts over. I put a line in there to adjust the zeros too.

<html>
<head>
<script>
var doLoop=true;
var counter=1,img='',tester=new Image();
tester.onload=isGood;
tester.onerror=isBad;
function testImage(c) {
c=c.toString();
c = (c.length==1 ? '00'+c : (c.length==2 ? '0'+c : c)) ;
tester.src='/data/images/sint/sint-'+c+'.jpg';
}
function isGood(){
document.getElementById('imgView').innerHTML='<img src=&quot;'+tester.src+'&quot;>';
counter++;
setTimeout('testImage('+counter+')',4000);
}
function isBad() {
if(doLoop){
counter=1;
setTimeout('testImage('+counter+')',4000);
}
}
</script>
</head>
<body onload=&quot;testImage(counter)&quot;>
<div id=&quot;imgView&quot;></div>
</body>
</html> Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top