Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_color/ (Read 5424 times)
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
$BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_color/
Jun 13th, 2006 at 12:45am
Print Post  
in this code .. document.write("<img src='$BgTags_dir/td0>");
is all the same each time ... what changes is defined be what's checked in a form ... which is entered into

$BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_color/~;

is there a way I can have this without the redundancy of repeating the same code everytime

Code
Select All
	~;

	# Begin BgTags

		fopen(FILE, "$vardir/bgtagsdata.txt");
		$bgtagsdata = <FILE>;
		fclose(FILE);
		($BgTags_val,$BgTags_button,$BgTags_color) = split (/\|/, $bgtagsdata);
		$BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_color/~;


	if ("$BgTags_button" eq "silver") {
	$BgTags_color = "silver";
	$yymain .= qq~
	document.write("<img src='$BgTags_dir/td0>");
	    ~;
	    } elsif {
	    
	    if ("$BgTags_button" eq "gold") {
	   	$BgTags_color = "gold";
	$yymain .= qq~
	document.write("<img src='$BgTags_dir/td0>");
	    ~;
	    } elsif {
	    
	    if ("$BgTags_button" eq "default") {
		    $BgTags_color = "default";
	$yymain .= qq~
	document.write("<img src='$BgTags_dir/td0>");
	    ~;

	    } elsif {

	    if ("$BgTags_button" eq "bronze") {
		    $BgTags_color = "bronze"
	$yymain .= qq~
	document.write("<img src='$BgTags_dir/td0>");
	    ~;

	    } elsif {
	    
	    if ("$BgTags_button" eq "blue") {
		    $BgTags_color = "blue";
	$yymain .= qq~
	document.write("<img src='$BgTags_dir/td0>");
	    ~;
	}
}

 	# End BgTags 

  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #1 - Jun 13th, 2006 at 1:36am
Print Post  
1) Elsif takes a condition, like if does
2) Don't quote variables where it's not needed (for example, don't do this if("$var" == $var2))

But why not do something like this
Code
Select All
	# Begin BgTags

		fopen(FILE, "$vardir/bgtagsdata.txt");
		$bgtagsdata = <FILE>;
		fclose(FILE);
		($BgTags_val,$BgTags_button,$BgTags_color) = split (/\|/, $bgtagsdata);
		$BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_color/~;

		    $bgTags_color = $BgTags_button;
		    $yymain .= qq~document.write("<img src=\"$BgTags_dir/td0\" />");
~; 

  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #2 - Jun 13th, 2006 at 2:09am
Print Post  
could you elaborate a bit ... just to reiterate ... I have a form in admin center that if blue checked uses bule buttons ... if silver cheked uses silver buttons and so on ... I got that code by coping a code that did something simular ... I'm sure you got that that was what I'm trying to do ... but I'm sorry I just don't quite get how to change the code to fit what you suggest other than removing the double quates and something about elseif

I get this error when I click reply, modify, or start new topic ... I removed the double ""


Untrapped Error:
syntax error at ./Sources/Post.pl line 768, near "elsif {" (Might be a runaway multi-line ~~ string starting on line 755) syntax error at ./Sources/Post.pl line 785, near "elsif {" (Might be a runaway multi-line ~~ string starting on line 772) syntax error at ./Sources/Post.pl line 803, near "} elsif" Compilation failed in require at ./Sources/ModifyMessage.pl line 145.

also my admin center push for the options screen didn't push right ... It pushes to "installed mods" but no link to options on the left side menu where the others are
thankyou
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #3 - Jun 13th, 2006 at 3:04am
Print Post  
I need to take a break ... read you all tomorrow ... Thanx again for everything
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #4 - Jun 13th, 2006 at 4:39am
Print Post  
Yeah, I didn't add the ~; at the beginning.
  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #5 - Jun 13th, 2006 at 3:11pm
Print Post  
I'm confused ... should I have changed elsif to else ? or it seems you might be syggestion to take out "if" and "else" altogether ... I did have the ~; at the begining ...

oh I just noticed the differnce in the line

("<img src=\"$BgTags_dir/td0\" />");

whats the   \  \ 's for ... directory ...

I know the closing />  makes it xhtml strict ... gotcha ... I'll give it whirl

thankyou ....
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #6 - Jun 13th, 2006 at 3:29pm
Print Post  
ok .. I just read something from curt explaining about statemenats ... I have to go out for about 2 hours but will be diggin in after that ... Thankyou AK108 and Curt
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #7 - Jun 13th, 2006 at 4:50pm
Print Post  
Actually, the \" should be \\" (escaping it once for Perl and again for Javascript)
  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #8 - Jun 13th, 2006 at 8:21pm
Print Post  
like this
Code
Select All
     document.write("<img src=\"$BgTags_dir/td0.gif\\" onclick='td0();' "+HAND+" align='top' width='23' height='22' border='0' />"); 



"  
("<img src=\"$BgTags_dir/td0.gif\\"

not '
('<img src=\'$BgTags_dir/td0.gif\\'


just double checking ...

In case someone else reads this post and wants to know the explaination of  ... if ... else ... elsif ... that curtis sent me ...

Quote:
When you write an if statement, it can
look like any of the following:
Code
Select All
if (statement) {
do something
} 



OR

Code
Select All
if(statement) {
do something
}
else {
do something else
} 



OR
Code
Select All
if(statement) {
do something
}
elsif(statement) {
do something else
}
else {
do something entirely different
} 

« Last Edit: Jun 13th, 2006 at 10:47pm by BlogTripper »  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #9 - Jun 13th, 2006 at 10:14pm
Print Post  
Yeah, but you forgot the other one. You could've left them as ', but I don't. Just a style issue...
  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #10 - Jun 13th, 2006 at 10:48pm
Print Post  
ok ... in the past it made a difference that's why I ask ... thankyou ... coming to close ...
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #11 - Jun 13th, 2006 at 10:52pm
Print Post  
Nope, that's Javascript writing out HTML, and HTML doesn't care.
  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #12 - Jun 14th, 2006 at 10:30pm
Print Post  
hmmm ... how important is  \escaping\\  ... it works without'em ...
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
AK108
God Member
*****
Offline



Posts: 942
Joined: Oct 1st, 2003
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #13 - Jun 14th, 2006 at 11:42pm
Print Post  
The Javascript shouldn't work unless you escape it properly.
  

For my mods, check out my public notes.

You might be interested in my projects, or my forum, the Flying Kirby Pub.
Back to top
WWWAIM  
IP Logged
 
BlogTripper
Senior Member
****
Offline


My Son Abel love's YaBB
2.1

Posts: 347
Location: Manchester
Joined: Apr 7th, 2006
Gender: Male
Re: $BgTags_dir .= qq~$modimgurl/BgTags/$BgTags_co
Reply #14 - Jun 15th, 2006 at 12:01am
Print Post  
that's odd ... see
user: guess
pass: guest

the td and cell tags ...
  

My mind went crazy and I don't know when it's coming back.  If you happen to see my mind please ask it if it's found my marbles yet, will you?
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint