Closed Thread Icon

Preserved Topic: IndexOf in XSSI? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20945" title="Pages that link to Preserved Topic: IndexOf in XSSI? (Page 1 of 1)" rel="nofollow" >Preserved Topic: IndexOf in XSSI? <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-16-2001 15:28

Ok - in Javascript, I have:

var location = "/divisions/swat/swat_training/index.htm";
document.write("Location: " + location);

var findit = location.lastIndexOf(".");
document.write("<br>Findit: " + findit);

var newext = ".pdf";
document.write("<br>Newext: " + newext);

var result=location.substr(0,findit) + newext;
document.write("<br>Result: " + result);


which gives me:

Location: /divisions/swat/swat_training/index.htm
Findit: 35
Newext: .pdf
Result: /divisions/swat/swat_training/index.pdf


This is fine. But I need to do this in XSSI, but I can't get IndexOf to work right. I'm using:

<!--#set var="current" value="$DOCUMENT_URI"-->
Location: <!--#echo var="DOCUMENT_URI"--><br>
<!--#set var="findit" value="$current.lastIndexOf\(\".\"\)"-->
Findit: <!--#echo var="findit"--><br>
<!--#set var="newext" value="\".pdf\""-->
Var: <!--#echo var="newext"--><br>
<!--#set var="result" value="$current.substr\(0\,$findit\)\+$newext"-->
Result: <!--#echo var="result" --><br>


and that gives me:

Location: /development/code/ssi_test.htm
Findit: /development/code/ssi_test.htm.lastIndexOf\("."\)
Var: ".pdf"
Result: /development/code/ssi_test.htm.substr\(0\,/development/code/ssi_test.htm.lastIndexOf\("."\)\)\+".pdf"


Anyone?

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-16-2001 17:14

Hmmmm.....my research makes me think that this isn't possible.

<Pugzly removes SSI hat, and dons CGI hat>

I have another idea.......

<Pugzly heads off to figure out how to do LastIndexOf in Perl>

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-16-2001 19:53

Pugzly, you can't call JS functions from XSSI...

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-16-2001 20:01

This will do what you want (in PERL):

$url = "/divisions/swat/swat_training/index.htm";
$url =~ s!\.(.+?)$!\.pdf!g;
print $url;

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-17-2001 17:21

Hmmm...I know you can't call a JS function from XSSI, I was just looking for a LastIndexOf type function in XSSI.

Anyways, what I did was took your cool .pdf script, and changed
my $fileName = $cgi->param('filename');
to
my $fileName = $ENV{'DOCUMENT_URI'};
$fileName =~ s!\.(.+?)$!\.pdf!g;


So that the script will just look for a .pdf version of the page that called it. That way, I don't have to pass the filename along to the script. I suspect that second line is a regular expression, which still scare me a little. But it works. The reason I did this is because I'm at over 400 pages of content and having to manually edit each call to the script when I created a new page was getting to be a pain. So now I just call the script itself with no parameters.

Thanks for the help.



mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-18-2001 08:06

XSSI practically doesn't have any built-in functions (i.e. there's no LastIndexOf function in XSSI), so that's why your first idea couldn't work.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-19-2001 05:32

Yeah, the more I looked around, the more I discovered I couldn't do it in XSSI. One of these days, I'll learn how to do PHP/mySQL stuff, and my life will be much easier.

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 06-19-2001 05:37

much more easier.
even without MySQL.

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-19-2001 05:50

My problem is that my sites tend to have a LOT of content (several hundred pages), so I might as well do the mySQL stuff right from the start.

Anyone got some good PHP links for doing templates?

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 06-19-2001 05:56

http://hotwired.lycos.com/webmonkey/99/25/index2a.html


« BackwardsOnwards »

Show Forum Drop Down Menu