Arrh, something else is wrong! With almost identical code snipets to working code.

  • Thread starter David. E. Goble
  • Start date
D

David. E. Goble

Arrrh! some buttons work while others don't, but I can't see why. I
have tried comparing the files that do work, with the ones that don't.
But to no help.

The funny thing is the parts that work have the same code, except
different variables.

(Note Javascript and htm code was writen by a c program, the code then
run thru a html to js converter)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bow's and foggy's stored grahics</title>
<SCRIPT src="avatarsheader.js"></SCRIPT>
<SCRIPT src="smilesheader.js"></SCRIPT>
<SCRIPT src="sigsheader.js"></SCRIPT>
</head>
<body
background="http://home.insightbb.com/clipart/backgrounds/bkgnd019.gif"
bgcolor="#ffffff" link="#0000ff" text="#000000" vlink="#ff0000">
<h1 align="center">Bow's and foggy's stored grahics</h1>
<h2 align="center" style="color: rgb(255, 0, 0);" color="red">Team
Special Forces</h2>
<table border="1" align="center">
<tr>
<td>
<SCRIPT src="avatarsbody.js"></SCRIPT>
</tb>
<td>
<SCRIPT src="smilesbody.js"></SCRIPT>
</tb>
<td>
<SCRIPT src="sigsbody.js"></SCRIPT>
</tb>
</tr>
</tr>
<td colspan="3" align="center">
Then email it to us at <a
href="mailto:[email protected]">[email protected]</a></p>
</td>
</tr>
</table>
</body>
</html>

//Generated By Easy HTML To Any Script Converter
document.writeln("<center>");
document.writeln("<h1>sigs<\/h1>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<table border=\"1\">");
document.writeln("<tr>");
document.writeln("<td align=\"center\"><img id=\"sigsviewer\"
src=\"sigs/motto.jpg\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<p><\/p>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"sigsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\" onclick=\"sigsprevious()\"
type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"sigsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"sigslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<p><\/p>");
document.writeln("<p>If you have a smilely<\/p>");
document.writeln("<\/center>");
//Generated By Easy HTML To Any Script Converter
document.writeln("<script type=\"text/javascript\">");
document.writeln("");
document.writeln("sigsImages=new Array()");
document.writeln("");
document.writeln("sigsImages[0]=\"sigs/finished1.jpg\"");
document.writeln("sigsImages[1]=\"sigs/foghorn.jpg\"");
document.writeln("sigsImages[2]=\"sigs/motto.jpg\"");
document.writeln("sigsImages[3]=\"sigs/sig.jpg\"");
document.writeln("sigsImages[4]=\"sigs/SWAT.jpg\"");
document.writeln("sigsImages[5]=\"sigs/title.gif\"");
document.writeln("");
document.writeln("sigscounter=sigsImages.length-1");
document.writeln("sigsi=0");
document.writeln("");
document.writeln("function sigsfirst()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsviewer\').src=sigsImages[0]");
document.writeln("sigsi=0");
document.writeln("}");
document.writeln("");
document.writeln("function sigsprevious()");
document.writeln("{");
document.writeln("if (sigsi>0)");
document.writeln("{");
document.writeln("sigsi++");
document.writeln("document.getElementById(\'sigsviewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigsnext()");
document.writeln("{");
document.writeln("if (sigsi>sigscounter)");
document.writeln("{");
document.writeln("sigsi--");
document.writeln("document.getElementById(\'sigsviewer\').src=sigsImages[sigsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function sigslast()");
document.writeln("{");
document.writeln("document.getElementById(\'sigsviewer\').src=sigsImages[sigscounter]");
document.writeln("}");
document.writeln("");
document.writeln("<\/script>");//Generated By Easy HTML To Any Script
Converter
document.writeln("<center>");
document.writeln("<h1>avatars<\/h1>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"avatarsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\"
onclick=\"avatarsprevious()\" type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"avatarsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"avatarslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<table border=\"1\">");
document.writeln("<tr>");
document.writeln("<td align=\"center\"><img id=\"avatarsviewer\"
src=\"avatars/soscom.gif\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<p><\/p>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"avatarsfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\"
onclick=\"avatarsprevious()\" type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"avatarsnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"avatarslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<p><\/p>");
document.writeln("<p>If you have a smilely<\/p>");
document.writeln("<\/center>");
//Generated By Easy HTML To Any Script Converter
document.writeln("<script type=\"text/javascript\">");
document.writeln("");
document.writeln("avatarsImages=new Array()");
document.writeln("");
document.writeln("avatarsImages[0]=\"avatars/160thsoar.gif\"");
document.writeln("avatarsImages[1]=\"avatars/75thrgrrgt.gif\"");
document.writeln("avatarsImages[2]=\"avatars/avatart-head_banger.gif\"");
document.writeln("avatarsImages[3]=\"avatars/soscom.gif\"");
document.writeln("avatarsImages[4]=\"avatars/syndrome.gif\"");
document.writeln("avatarsImages[5]=\"avatars/usacapoc.gif\"");
document.writeln("avatarsImages[6]=\"avatars/usajfkswcs.gif\"");
document.writeln("avatarsImages[7]=\"avatars/usasfc.gif\"");
document.writeln("avatarsImages[8]=\"avatars/usasoc.gif\"");
document.writeln("");
document.writeln("avatarscounter=avatarsImages.length-1");
document.writeln("avatarsi=0");
document.writeln("");
document.writeln("function avatarsfirst()");
document.writeln("{");
document.writeln("document.getElementById(\'avatarsviewer\').src=avatarsImages[0]");
document.writeln("avatarsi=0");
document.writeln("}");
document.writeln("");
document.writeln("function avatarsprevious()");
document.writeln("{");
document.writeln("if (avatarsi>0)");
document.writeln("{");
document.writeln("avatarsi--");
document.writeln("document.getElementById(\'avatarsviewer\').src=avatarsImages[avatarsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function avatarsnext()");
document.writeln("{");
document.writeln("if (avatarsi<avatarscounter)");
document.writeln("{");
document.writeln("avatarsi++");
document.writeln("document.getElementById(\'avatarsviewer\').src=avatarsImages[avatarsi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function avatarslast()");
document.writeln("{");
document.writeln("document.getElementById(\'avatarsviewer\').src=avatarsImages[avatarscounter]");
document.writeln("}");
document.writeln("");
document.writeln("<\/script>");
//Generated By Easy HTML To Any Script Converter
document.writeln("<center>");
document.writeln("<h1>smiles<\/h1>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"smilesfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\"
onclick=\"smilesprevious()\" type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"smilesnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"smileslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<table border=\"1\">");
document.writeln("<tr>");
document.writeln("<td align=\"center\"><img id=\"smilesviewer\"
src=\"smiles/alien.gif\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>");
document.writeln("<p><\/p>");
document.writeln("<form>");
document.writeln("<input value=\"First\" onclick=\"smilesfirst()\"
type=\"button\">");
document.writeln("<input value=\"Previous\"
onclick=\"smilesprevious()\" type=\"button\">");
document.writeln("<input value=\"Next\" onclick=\"smilesnext()\"
type=\"button\">");
document.writeln("<input value=\"Last\" onclick=\"smileslast()\"
type=\"button\">");
document.writeln("<\/form>");
document.writeln("<p><\/p>");
document.writeln("<p>If you have a smilely<\/p>");
document.writeln("<\/center>");
//Generated By Easy HTML To Any Script Converter
document.writeln("<script type=\"text/javascript\">");
document.writeln("");
document.writeln("smilesImages=new Array()");
document.writeln("");
document.writeln("smilesImages[0]=\"smiles/007.gif\"");
document.writeln("smilesImages[1]=\"smiles/1luvu.gif\"");
document.writeln("smilesImages[2]=\"smiles/1zhelp.gif\"");
document.writeln("smilesImages[3]=\"smiles/22_yikes.gif\"");
document.writeln("smilesImages[4]=\"smiles/2evil.gif\"");
document.writeln("smilesImages[5]=\"smiles/test.jpg\"");
document.writeln("smilesImages[6]=\"smiles/2twocents.gif\"");
document.writeln("smilesImages[7]=\"smiles/321.gif\"");
document.writeln("smilesImages[8]=\"smiles/ak47.gif\"");
document.writeln("smilesImages[9]=\"smiles/ald.gif\"");
document.writeln("smilesImages[10]=\"smiles/alien.gif\"");
document.writeln("smilesImages[11]=\"smiles/angry.gif\"");
document.writeln("smilesImages[12]=\"smiles/arsch.gif\"");
document.writeln("smilesImages[13]=\"smiles/asdf.gif\"");
document.writeln("smilesImages[14]=\"smiles/aufreg.gif\"");
document.writeln("smilesImages[15]=\"smiles/aus.gif\"");
document.writeln("smilesImages[16]=\"smiles/axt.gif\"");
document.writeln("smilesImages[17]=\"smiles/a_plain.gif\"");
document.writeln("smilesImages[18]=\"smiles/bad.gif\"");
document.writeln("smilesImages[19]=\"smiles/badassleft.gif\"");
document.writeln("smilesImages[20]=\"smiles/badassright.gif\"");
document.writeln("smilesImages[21]=\"smiles/badsmile.gif\"");
document.writeln("smilesImages[22]=\"smiles/bananasmile.gif\"");
document.writeln("smilesImages[23]=\"smiles/bananawalk.gif\"");
document.writeln("smilesImages[24]=\"smiles/batman.gif\"");
document.writeln("smilesImages[25]=\"smiles/bazooka.gif\"");
document.writeln("smilesImages[26]=\"smiles/behead.gif\"");
document.writeln("smilesImages[27]=\"smiles/bekloppt.gif\"");
document.writeln("smilesImages[28]=\"smiles/bier.gif\"");
document.writeln("smilesImages[29]=\"smiles/bigthumb.gif\"");
document.writeln("smilesImages[30]=\"smiles/bigun2.gif\"");
document.writeln("smilesImages[31]=\"smiles/birthday.gif\"");
document.writeln("smilesImages[32]=\"smiles/blaah.gif\"");
document.writeln("smilesImages[33]=\"smiles/blbl.gif\"");
document.writeln("smilesImages[34]=\"smiles/blover.gif\"");
document.writeln("smilesImages[35]=\"smiles/bong.gif\"");
document.writeln("smilesImages[36]=\"smiles/bounce.gif\"");
document.writeln("smilesImages[37]=\"smiles/bricks1.gif\"");
document.writeln("smilesImages[38]=\"smiles/bs.gif\"");
document.writeln("smilesImages[39]=\"smiles/bunny.gif\"");
document.writeln("smilesImages[40]=\"smiles/byewhore.gif\"");
document.writeln("smilesImages[41]=\"smiles/casanova.gif\"");
document.writeln("smilesImages[42]=\"smiles/charley.gif\"");
document.writeln("smilesImages[43]=\"smiles/cry.gif\"");
document.writeln("smilesImages[44]=\"smiles/cussing.gif\"");
document.writeln("smilesImages[45]=\"smiles/drink.gif\"");
document.writeln("smilesImages[46]=\"smiles/dunno.gif\"");
document.writeln("smilesImages[47]=\"smiles/eek3.gif\"");
document.writeln("smilesImages[48]=\"smiles/eek7.gif\"");
document.writeln("smilesImages[49]=\"smiles/enforcer.gif\"");
document.writeln("smilesImages[50]=\"smiles/engel.gif\"");
document.writeln("smilesImages[51]=\"smiles/freak3.gif\"");
document.writeln("smilesImages[52]=\"smiles/girl.gif\"");
document.writeln("smilesImages[53]=\"smiles/grasseater.gif\"");
document.writeln("smilesImages[54]=\"smiles/grenade.gif\"");
document.writeln("smilesImages[55]=\"smiles/hammer.gif\"");
document.writeln("smilesImages[56]=\"smiles/headshake2.gif\"");
document.writeln("smilesImages[57]=\"smiles/laser_shot_jump.gif\"");
document.writeln("smilesImages[58]=\"smiles/microwave.gif\"");
document.writeln("smilesImages[59]=\"smiles/newbie.gif\"");
document.writeln("smilesImages[60]=\"smiles/nono.gif\"");
document.writeln("smilesImages[61]=\"smiles/nuts.gif\"");
document.writeln("smilesImages[62]=\"smiles/partyman.gif\"");
document.writeln("smilesImages[63]=\"smiles/remybussi.gif\"");
document.writeln("smilesImages[64]=\"smiles/robot2.gif\"");
document.writeln("smilesImages[65]=\"smiles/samurai.gif\"");
document.writeln("smilesImages[66]=\"smiles/scratch.gif\"");
document.writeln("smilesImages[67]=\"smiles/screwy.gif\"");
document.writeln("smilesImages[68]=\"smiles/sheep.gif\"");
document.writeln("smilesImages[69]=\"smiles/shoot.gif\"");
document.writeln("smilesImages[70]=\"smiles/silly.gif\"");
document.writeln("smilesImages[71]=\"smiles/sleeping.gif\"");
document.writeln("smilesImages[72]=\"smiles/southpark.gif\"");
document.writeln("smilesImages[73]=\"smiles/spam4.gif\"");
document.writeln("smilesImages[74]=\"smiles/sword.gif\"");
document.writeln("smilesImages[75]=\"smiles/taz.gif\"");
document.writeln("smilesImages[76]=\"smiles/twak.gif\"");
document.writeln("smilesImages[77]=\"smiles/walker.gif\"");
document.writeln("smilesImages[78]=\"smiles/title.gif\"");
document.writeln("");
document.writeln("smilescounter=smilesImages.length-1");
document.writeln("smilesi=0");
document.writeln("");
document.writeln("function smilesfirst()");
document.writeln("{");
document.writeln("document.getElementById(\'smilesviewer\').src=smilesImages[0]");
document.writeln("smilesi=0");
document.writeln("}");
document.writeln("");
document.writeln("function smilesprevious()");
document.writeln("{");
document.writeln("if (smilesi>0)");
document.writeln("{");
document.writeln("smilesi--");
document.writeln("document.getElementById(\'smilesviewer\').src=smilesImages[smilesi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function smilesnext()");
document.writeln("{");
document.writeln("if (smilesi<smilescounter)");
document.writeln("{");
document.writeln("smilesi++");
document.writeln("document.getElementById(\'smilesviewer\').src=smilesImages[smilesi]");
document.writeln("}");
document.writeln("}");
document.writeln("");
document.writeln("function smileslast()");
document.writeln("{");
document.writeln("document.getElementById(\'smilesviewer\').src=smilesImages[smilescounter]");
document.writeln("}");
document.writeln("");
document.writeln("<\/script>");

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define FALSE 0
#define TRUE 1
#define LINESIZE 255

int setupoutfiles(char filename[], FILE **header, FILE **body)
{
char tempstr[LINESIZE]="\0";

strcpy(tempstr, filename);
strcat(filename, "header.htm");
*header=fopen(filename, "w+");
if(!header) return -1;
strcat(tempstr, "body.htm");
*body=fopen(tempstr, "w+");
if(!body) return -1;
return 0;
}

int setupinfile(char filename[], FILE **infile)
{
*infile=fopen(filename, "r+");
if(!infile) return -1;
return 0;
}

void therest(FILE **header, char b[])
{
fprintf(*header, "\n%scounter=%sImages.length-1\n", b, b);
fprintf(*header, "%si=0\n\n", b);
fprintf(*header, "function %sfirst()\n", b);
fprintf(*header, "{\n");
fprintf(*header,
"document.getElementById(\'%sviewer\').src=%sImages[0]\n", b, b);
fprintf(*header, "%si=0\n", b);
fprintf(*header, "}\n\n");

fprintf(*header, "function %sprevious()\n", b);
fprintf(*header, "{\n");
fprintf(*header, "if (%si>0)\n", b);
fprintf(*header, "{\n");
fprintf(*header, "%si--\n", b);
fprintf(*header,
"document.getElementById(\'%sviewer\').src=%sImages[%si]\n", b, b, b);
fprintf(*header, "}\n");
fprintf(*header, "}\n\n");

fprintf(*header, "function %snext()\n", b);
fprintf(*header, "{\n");
fprintf(*header, "if (%si<%scounter)\n", b);
fprintf(*header, "{\n");
fprintf(*header, "%si++\n", b);
fprintf(*header,
"document.getElementById(\'%sviewer\').src=%sImages[%si]\n", b, b, b);
fprintf(*header, "}\n");
fprintf(*header, "}\n\n");

fprintf(*header, "function %slast()\n", b);
fprintf(*header, "{\n");
fprintf(*header,
"document.getElementById(\'%sviewer\').src=%sImages[%scounter]\n", b,
b, b);
fprintf(*header, "}\n\n");
fprintf(*header, "</script>");
}

int myheader(FILE **infile, FILE **header, char b[], char afile[])
{
char line[LINESIZE]="\0";
char base[LINESIZE]="\0";
int i=0;

strcpy(afile, "\0");
fprintf(*header, "<script type=\"text/javascript\">\n\n");
fprintf(*header, "%sImages=new Array()\n\n", b);
while(fgets(line, LINESIZE, *infile)!=NULL)
{
line[strlen(line)-1] = '\0';
if(strstr(line, ".gif")!=NULL || strstr(line, ".jpg")!=NULL)
{
strcpy(base, b);
strcat(base, "/");
strcat(base, line);
/*if(!rand()%1) strcpy(afile, base);*/
fprintf(*header, "%sImages[%d]=\"%s\"\n", b, i++, base);
}
}
therest(header, b);
return 0;
}

void mybuttons(FILE **body, char b[])
{
fprintf(*body, "<form>\n");
fprintf(*body, "<input value=\"First\" onclick=\"%sfirst()\"
type=\"button\">\n", b);
fprintf(*body, "<input value=\"Previous\"
onclick=\"%sprevious()\" type=\"button\">\n", b);
fprintf(*body, "<input value=\"Next\" onclick=\"%snext()\"
type=\"button\">\n", b);
fprintf(*body, "<input value=\"Last\" onclick=\"%slast()\"
type=\"button\">\n", b);
fprintf(*body, "</form>\n");
}
void mybody(FILE **body, char b[], char afile[])
{
fprintf(*body, "<center>\n");
fprintf(*body, "<h1>%s</h1>\n", b);

mybuttons(body, b);

fprintf(*body, "<table border=\"1\">\n");
fprintf(*body, "<tr>\n");
fprintf(*body, "<td align=\"center\">");
fprintf(*body, "<img id=\"%sviewer\"
src=\"%s/alien.gif\"></td>\n", b, b);
fprintf(*body, "</tr>\n");
fprintf(*body, "</table>\n");
fprintf(*body, "<p></p>\n");

mybuttons(body, b);

fprintf(*body, "<p></p>\n");
fprintf(*body, "<p>If you have a smilely</p>\n");
fprintf(*body, "</center>\n");
}

int main(int argc, char *argv[])
{
FILE *infile, *header, *body;
char outfname[LINESIZE]="\0",
tempstr[LINESIZE]="\0";

if(argc>2)
{
if(setupoutfiles(strcpy(outfname, argv[2]), &header, &body))
{
printf("problem opening outfiles %s\n", outfname);
return -1;
}
if(setupinfile(argv[1], &infile))
{
printf("problem opening infile %s\n", argv[1]);
return -1;
}
}
else
{
printf("mymenu infname [basefolder] -> basefolderheader.htm,
basefolderbody.htm\n");
return -1;
}
strcpy(outfname, argv[2]);
myheader(&infile, &header, outfname, tempstr);
mybody(&body, outfname, tempstr);

fclose(header);
fclose(body);
fclose(infile);
return 0;
}

Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
 
D

David. E. Goble

Is there some sort of limitation or something.... Because one second
something will work the next thing its not!
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
 
J

j

David. E. Goble said:
Is there some sort of limitation or something.... Because one second
something will work the next thing its not!

In ``therest'', line 53, you have the following,
fprintf(*header, "if (%si<%scounter)\n", b);

Which invokes undefined behaviour.
And would explain your ``sometimes works
and sometimes not'' dilemma.
 
E

Espen Myrland

David. E. Goble said:
Arrrh! some buttons work while others don't, but I can't see why. I
(Note Javascript and htm code was writen by a c program, the code then
run thru a html to js converter)


This is out of the scope here on comp.lang.c. You should redirect
your question to comp.dev.null. They probably are more familiar
with this sort of stuff.
 
R

Robert

David. E. Goble said:
Arrrh! some buttons work while others don't, but I can't see why. I
have tried comparing the files that do work, with the ones that don't.
But to no help.

The funny thing is the parts that work have the same code, except
different variables.

(Note Javascript and htm code was writen by a c program, the code then
run thru a html to js converter)

Do you have a website one can visit?

Why did you include the C code? In the web browser, you can see the
downloaded code. Look at this and see if the code was generated as you
expect. You can see the result of document.write by entering what
people around hear refer to as a one liner.

The following one-liner when pasted into the command line will
display the generated html. (It looks for line ends which are OS
dependent.):

javascript:'<html><head><title>SourceFileListing<\/title><\/head><body><c
ode><ol><li>'+(document.documentElement||document.body).innerHTML.replace
(/&/g,%22&amp;%22).replace(/</g,%22&lt;%22).replace(/%20%20/g,%22&nbsp;%2
0%22).replace(/\r\n/g,%22<li>%22).replace(/\n/g,%22<li>%22).replace(/\r/g
,%22<li>%22)+'<\/ol><\/code><\/body><\/html>';

I do not see the source to the javascript include files.

You need to narrow the problem down.

Robert
 
D

David. E. Goble

In ``therest'', line 53, you have the following,
fprintf(*header, "if (%si<%scounter)\n", b);

Well the outputed text in all files is what was expected, namely;

if(avatarsi<avatarscounter)
if(smilesi<smilesscounter)
if(sigssi<sigscounter)

Nonetheless I did change it too;

char temp[LINESIZE];
.....

strcpy(temp, b);
strcat(temp, "i<");
fprintf(*header, "if (%s%scounter)\n", temp, b);

and also manually changed this line per run;

fprintf(*body, "<img id=\"%sviewer\" src=\"%s/alien.gif\"></td>\n", b,
b);

It seems to be working for now (Until the next time I change something
lol)

Thanks for your help. Check it out at
http://home.insightbb.com/~bow.foggy/

Which invokes undefined behaviour.
And would explain your ``sometimes works
and sometimes not'' dilemma.

Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
 
D

David. E. Goble

Hi All;

Thanks for your previous help. Need ideas on how to solve a problem.

int myheader(FILE **infile, FILE **header, char b[], char afile[])
{
char line[LINESIZE]="\0";
char base[LINESIZE]="\0";
int i=0;

strcpy(afile, "\0");
fprintf(*header, "<script type=\"text/javascript\">\n\n");
fprintf(*header, "%sImages=new Array()\n\n", b);
while(fgets(line, LINESIZE, *infile)!=NULL)
{
line[strlen(line)-1] = '\0';
if(strstr(line, ".gif")!=NULL || strstr(line, ".jpg")!=NULL)
{
strcpy(base, b);
strcat(base, "/");
strcat(base, line);
/*if(!rand()%1) strcpy(afile, base);

I want to capture once and randomly one of these strings, for
later use. in the function below .

anyother way than storing all of them?

*/

fprintf(*header, "%sImages[%d]=\"%s\"\n", b, i++, base);
}
}
therest(header, b);
return 0;

void mybody(FILE **body, char b[], char afile[])
{
fprintf(*body, "<center>\n");
fprintf(*body, "<h1>%s</h1>\n", b);

mybuttons(body, b);

fprintf(*body, "<table border=\"1\">\n");
fprintf(*body, "<tr>\n");
fprintf(*body, "<td align=\"center\">");
fprintf(*body, "<img id=\"%sviewer\" src=\"%s\"></td>\n", b,
afile); /* <------------------------------------
fprintf(*body, "</tr>\n");
fprintf(*body, "</table>\n");
fprintf(*body, "<p></p>\n");

mybuttons(body, b);

fprintf(*body, "<p></p>\n");
fprintf(*body, "<p>If you have a smilely</p>\n");
fprintf(*body, "</center>\n");
}
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
 
B

bd

David. E. Goble said:
In ``therest'', line 53, you have the following,
fprintf(*header, "if (%si<%scounter)\n", b);

Well the outputed text in all files is what was expected, namely;

if(avatarsi<avatarscounter)
if(smilesi<smilesscounter)
if(sigssi<sigscounter)

Nonetheless I did change it too;

char temp[LINESIZE];
....

strcpy(temp, b);
strcat(temp, "i<");
fprintf(*header, "if (%s%scounter)\n", temp, b);

No need to do that. Just:
fprintf(*header, "if(%si<%scounter)\n", b, b);
 
D

David. E. Goble

David. E. Goble said:
Is there some sort of limitation or something.... Because one second
something will work the next thing its not!

In ``therest'', line 53, you have the following,
fprintf(*header, "if (%si<%scounter)\n", b,b);

Well the outputed text in all files is what was expected, namely;

if(avatarsi<avatarscounter)
if(smilesi<smilesscounter)
if(sigssi<sigscounter)

Nonetheless I did change it too;

char temp[LINESIZE];
....

strcpy(temp, b);
strcat(temp, "i<");
fprintf(*header, "if (%s%scounter)\n", temp, b);

No need to do that. Just:
fprintf(*header, "if(%si<%scounter)\n", b, b);

But, for some reason the output: if (sigsi<sigscounter)

Which is then converted to js: document.writeln("if
(sigsi<sigscounter)");

Does causes the the previous and next buttons to fail.

here is a link to the current working version;

http://home.insightbb.com/~bow.foggy/sigs/
Regards David. E. Goble
http://www.pnc.com.au/~degoble
degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top