[ic] scratch values and usertags question
Matthew Crosswell
matthew at compedge.co.nz
Thu Oct 9 11:52:22 EDT 2003
> Q? How do I get the "[" characters to be preserved during the write
> operation? At the moment they are turned into #&91; I did try
> simply writing
> the field to the file but then I lost the "<" and "["
> characters completely.
>
I've sorted out how to do this, but I'd like to know if there are more
efficient ways to do this with IC. It seems a bit long winded to me.
Cheers Matthew :)
#### HTML ####
[save2file filename="filename" filedata="unsafe data with [ and < characters
in it....."]
This could also easily be modified to be a [save2file filename=""]unsafe
data in here....[/save2file] pair.
I had to change permissions of directory and file. The IC user needs to have
write permission to the directory and file.
This is the usertag I used to do the write of the file.
#### USERTAG ####
UserTag save2file Order filename filedata
UserTag save2file addAttr
UserTag save2file Documentation <<EOF
=pod
This tag uses the open/syswrite/close functions to write some data to a
file.
Options:
filename
data
Example: [save2file filename filedata]
=cut
EOF
UserTag save2file Routine <<EOR
sub {
my ($filename, $filedata) = @_;
open(UPLOAD, ">$filename") or die "$filename could not be opened for
writing.\n";
$filedata=~s/\&\#91\;/\[/g;
syswrite UPLOAD, $filedata;
close(UPLOAD);
return;
}
EOR
#### END ####
Also, I've written a tag to get data from a database which was returned in
safe mode, then parse it to return the [ characters so it can be
interpolated in a scratch variable. Again there must be a more straight
forward way of doing this with IC.....anyone?
#### HTML ####
[seti variable][unsafe strdata='[sql-param ..parameter..]'][/seti][seti
content][scratch name=content interpolate=1][/seti]
#### USERTAG ####
UserTag unsafe Order strdata
UserTag unsafe addAttr
UserTag unsafe Documentation <<EOF
=pod
Options: strdata
Example: [unsafe strdata]
=cut
EOF
UserTag unsafe Routine <<EOR
sub {
my ($strdata) = @_;
$strdata=~s/\&\#91\;/\[/g;
return "$strdata";
}
EOR
More information about the interchange-users
mailing list