?

Log in

No account? Create an account
entries friends calendar profile Previous Previous Next Next
Grr, S2... - IBNeko's Journal-Nyo~!
ibneko
ibneko
Grr, S2...
Well, I remember S2 again.

Unfortunately, that isn't helping me figure out why the stuff that my parseBarContent function returns isn't reaching the calling function.

and I think I might be too tired to debug further.

It boggles the mind, actually. I designed this with the intention that it'd be usable to create any sort of layout, which made it highly complex, but... I think it might be too complex. Sorry xella. I don't know if you ever got any other layouts out of it.. ^^;;; somehow I doubt it, since I can't even get stuff to look nice on my own journal. Or even look the slightest... like I want.

Granted, I think there's some div tags getting eaten up along the way... and content isn't being returned except for the right sidebar... nothing coming back from the header, nothing from the footer... And I'm not even sure what ate the left sidebar. It boggles the mind.

I also need to figure out if there's been any other updates to S2. There's some odd quirks to the language here and there - it's an incomplete implementation of perl, but I don't recall what's missing, nor do I have more notes other than:

CLASS
------------------------
class stack
{
var string[] array;
var int top;
function push(string aString);
function pop() : string;
}

function stack::push(string aString)
{
$.array[$.top+1] = $aString;
}
function stack::pop() : string
{
$.top--;
return $.array[$.top+1];
}

ARRAYS
------------------------
function array_test(int index, string bit, string[] ret) : string[]
{
$ret[0] = $bit;
return $ret;
}

function RecentPage::print_body() {
var string[] array;
array_test(1, "test", $array);
array_test(2, "boo", $array);
array_test(3, "cat", $array);

foreach var string out ($array){
print $out;
}

var stack aStack;
print $aStack->pop();
}


and some useful string functions for S2 that... probably are really bad.

# -*-s2-*-
layerinfo type = "layout";
layerinfo name = "Auhw-t";
layerinfo lang = "en";

## This layer was built by massively editing the code of Haven
## Thus, there will be some similarities, although a lot of it is new stuff...

layerinfo author_name = "Benjamin Juang";
layerinfo author_email = "ben.juang@comcast.net";
layerinfo redist_uniq = "auhw-t/layout";
layerinfo des = "Auhw-t (n) \"the Hearth\": the Ailurin/wizardry term for what humans refer to as \"Timeheart\"--the most senior/central reality, of which all others are mirrors or variations. (Diane Duane, Book of Night with Moon)";
layerinfo previews = "";



##################################################################################################
##
## String +
##
##
### NOTE TO SELF: RE-WRITE THIS SECTION USING foreach var int i (1 .. $chunk->length())
##
##################################################################################################
## String+::split
## Splits $chunk by $tokens and returns the seperate parts in an array
## Semi-Equiv to perl: @stuff = $chunk.split($tokens);
function split(string chunk, string tokens) : string[]
{
var string[] ret;
var int arrayIndex = 0;
var int start = 0;
foreach var int i (0 .. $chunk->length()){
if ($chunk->substr($i, $tokens->length()) == $tokens){
$ret[$arrayIndex] = $chunk->substr($start,$i-$start);
$arrayIndex++;
$start = $i+$tokens->length();
}
}
return $ret;
}


## String+::replace
## Replaces all instances of $target in $chunk with $replacement
## Semi-Equiv to perl: $chunk =~ s|$target|$replacement|g;
function replace(string chunk, string target, string replacement) : string
{
var string ret;
var int ignore = 0;
foreach var int i (0 .. $chunk->length()){
if ($chunk->substr($i, $target->length()) == $target){
$ret = $ret+$replacement;
$i = $i+$target->length();
$ignore = $target->length()-1;
} else {
if ($ignore < 1){
$ret = $ret+$chunk->substr($i, 1);
} else {
$ignore--;
}
}
}
return $ret;
}

## String+::indexOf
## Returns the index value for the first instance of $target in $chunk
## Semi-Equiv to java: $target.indexOf($chunk);
function indexOf(string chunk, string target) : int
{
foreach var int i (0 .. $chunk->length()){
if ($chunk->substr($i, $target->length()) == $target){
return $i;
}
}
return -1;
}
function indexOf(string chunk, string target, int start, int end) : int
{
foreach var int i ($start .. $end){
if ($chunk->substr($i, $target->length()) == $target){
return $i;
}
}
return -1;
}

## String+::exp
## returns base^power.
## Equiv to java: Math.exp(int base, int power);
function exp(int base, int power) : int
{
var int ret = 1;
if ($power == 0){ return $ret; }
if ($power > 0){
foreach var int i (1 .. $power){
$ret = $ret * $base;
}
} else {
foreach var int i (1 .. -$power){
$ret = $ret / $base;
}
}
return $ret;
}

## String+::stringToInt , charToInt
## Returns the interger value for the $input
## Semi-Equiv to java: Integer.parseInt(string);
function charToInt(string char) : int
{
if ($char->length() < 0) {return 0; }
if ($char->substr(0,1) == "1")
{ return 1; }
if ($char->substr(0,1) == "2")
{ return 2; }
if ($char->substr(0,1) == "3")
{ return 3; }
if ($char->substr(0,1) == "4")
{ return 4; }
if ($char->substr(0,1) == "5")
{ return 5; }
if ($char->substr(0,1) == "6")
{ return 6; }
if ($char->substr(0,1) == "7")
{ return 7; }
if ($char->substr(0,1) == "8")
{ return 8; }
if ($char->substr(0,1) == "9")
{ return 9; }
return 0;
}
function stringToInt(string chunk) : int
{
var int ret;
foreach var int i (0 .. $chunk->length()){
$ret = $ret+(
charToInt($chunk->substr($i, 1)) * exp(10, $chunk->length()-$i-1)
);
}
return $ret;
}

## String+::parseBool
## Returns the "true" for true, and "false" for false
## parseBool(bool) -> string;
function parseBool(bool input) : string
{
if ($input) { return "true"; }
return "false";
}
##################################################################################################


function untaint(string content) : string
{
var string safe;
$safe = replace($content, "
", "");
$safe = replace($safe, "[", "<");
$safe = replace($safe, "]", ">");
return $safe;
}

function Page::print()
{
print "";

#BODY starts here:
print "";
var string temp = "[table width=\"100%\" height=\"230\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"]
[tr]
[td width=\"496\" height=\"230\"]
[img src=\"http://www.dysdaera.net/lj_layout/wol/mountain_left.jpg\" width=\"496\" height=\"230\"]
[/td]
[td]
 
[/td]
[td width=\"354\" height=\"230\"]
[img src=\"http://www.dysdaera.net/lj_layout/wol/mountain_right.gif\" width=\"354\" height=\"230\"]
[/td]
[/tr]
[/table]";
var string clean = replace($temp, "[", "<");
$clean = replace($clean, "]", ">");
$clean = replace($clean, "table>", "div>");

print $clean;

println "";
}

Tags:
Current Music: Morning of Yoster Island - Koji Kondo, Sadao Watanabe

2 happy kittens | Leave catnip
Comments
xella From: xella Date: June 13th, 2006 05:35 am (UTC) (Link)
I never tried, actually ^^; And would that be why wingsoflove started looking really strange recently, or would that be more of an LJ problem? Like, coz' things are getting shifted around in a parent style or sommat?

(in which case it means that I messed up setting it up way back when, but... shh =P)
ibneko From: ibneko Date: June 13th, 2006 05:43 am (UTC) (Link)
I think it's an LJ problem... stuff ain't working the way it should right now, and the code I was playing with mirrors the stuff I gave you (I think).

:: looks at wingsoflove:: ..yeeeeeeeeah. LJ broke stuff. Probably the functions calling functions calling functions....etc. bit. We'll see. I'll get to talk to Brad, the LiveJournal god (^^;;;; so scared...), come this time next week, and uh, maybe he'll enlighten me as to what changes have gone through the system in the past few years...
2 happy kittens | Leave catnip