Javascript helllp~

For general discussions of any sort that don't fit in the other forums.

Moderators: Mystic Dragon, Xalia, Shard, JKatkina

Post Reply
User avatar
DNS
Ancient Dragon
Posts: 3852
Joined: Mon May 15, 2006 3:47 pm
Location: On top of the rainbow
Contact:

Javascript helllp~

Post by DNS »

I was being all wierd and twitchy and decided to make a little genthing for myself. I basically modified one of the generators on seventh sanctum, but now it's acting up~

Front page is nifty and tells me exactly where the problem is; line 2021. the problem is that line 2021 ISN'T the java i changed (basically the contents of the arrays) but a function of the java itself.

I don't know jack shit about javascript, so naturally I'm lost. I've tried the script off of 2 other generators but I still no get it to worky.

code as is follows~ -
<hr>
function GenNumber (nRange)
{
var iNumGen
iNumGen = Math.round((Math.random() * nRange));

return iNumGen;
}

function GetFrom(aArray)
{
var undefined
var sReturn
sReturn = aArray[GenNumber(aArray.length)];
if (sReturn == undefined)
{
sReturn = GetFrom(aArray)
}
return sReturn
}

function GetArray(sArrayName)
{
var bHold = true
//alert(sArrayName)
for (var intLooper=0;intLooper <aVocab.length;intLooper++)
{
if (aVocab[intLooper][0]==sArrayName) <Problem> -1)
{
iTagStart = sLine.indexOf("<iTagEnd> - 1)
{
sLine = ScanLine(sLine)
}

return sLine;
}

function GenPlot()
{
sLine = GetFrom(GetArray("BASE"));

sLine = ScanLine(sLine)

document.GENFORM.STORY.value = sLine;
}
//-->
<hr>

The error message says that 'aVocab[...].0' is a null or not an object.
does anyone know the problems?

Edit: -stare- it's misbehaving. that's as good as the code's gonna get i guess-- the furry character gen in seventh sanctum. the particular problem line is such:
If (aVocab[intlooper][0]==sArrayName)
Shiolar
Dragon
Posts: 1814
Joined: Sun Oct 17, 2021 12:28 pm

Post by Shiolar »

I can't say I know too much about Java, but a couple things stand out to me as possible problems...
if (aVocab[intLooper][0]==sArrayName) <Problem> -1)
{
iTagStart = sLine.indexOf("<iTagEnd> - 1)
In the first line, you have one opening bracket and two closing brackets...
And in the second line, you have a quote mark before iTagEnd but not afterwards, and for code to work you always need two quote marks...
User avatar
DNS
Ancient Dragon
Posts: 3852
Joined: Mon May 15, 2006 3:47 pm
Location: On top of the rainbow
Contact:

Post by DNS »

iTag isn't in the original code. :/ I think the bbcode added it when i pasted it up here. As for the brackets.. they worked for seventh sanctum, but i noticed that too. Did nothing when i tried to change it, though. X.x Cept caused a different error, but yes.
whee~ thanks, though,
User avatar
DragonFlight
Dragon
Posts: 1933
Joined: Wed Jul 06, 2005 10:37 am
Contact:

Post by DragonFlight »

It sounds like you have an array bounding error.

Where do you define aVocab? Is that all of the code? Because it looks like you don't define it there. If that's not all the code, look at where aVocab is initially created and check to make sure you allocated space for the second dimension of the array. Because an error comment like:

"aVocab[...][0] is null or does not exist" means that the second index is invalid and may not have been allocated.
Database Being Revamped

'Epic' is most concisely defined as something that, were you to do it in view of a person in real life, they'd pretty much have to sleep with you immediately to maintain order in the universe.
I sneezed. It seems to have reshaped reality. My bad.
User avatar
DNS
Ancient Dragon
Posts: 3852
Joined: Mon May 15, 2006 3:47 pm
Location: On top of the rainbow
Contact:

Post by DNS »

aaah, i vagually can trasnlate that speak from when i took c++.

I.. don't know if i made the array. :/ that might very well be the problem... could anyone tell me what to do/look for in that sense?
User avatar
DragonFlight
Dragon
Posts: 1933
Joined: Wed Jul 06, 2005 10:37 am
Contact:

Post by DragonFlight »

Look for a statement:

var aVocab

at least, followed somewhere by:

aVocab = (some javascript that defines an array)

I don't know Javascript in particular so I don't know how it defines an array normally.
Database Being Revamped

'Epic' is most concisely defined as something that, were you to do it in view of a person in real life, they'd pretty much have to sleep with you immediately to maintain order in the universe.
I sneezed. It seems to have reshaped reality. My bad.
User avatar
DNS
Ancient Dragon
Posts: 3852
Joined: Mon May 15, 2006 3:47 pm
Location: On top of the rainbow
Contact:

Post by DNS »

Squeee~ -hugs- thanks, DF. I got the code working.
User avatar
DragonFlight
Dragon
Posts: 1933
Joined: Wed Jul 06, 2005 10:37 am
Contact:

Post by DragonFlight »

Yay! What'd the problem end up being?
Database Being Revamped

'Epic' is most concisely defined as something that, were you to do it in view of a person in real life, they'd pretty much have to sleep with you immediately to maintain order in the universe.
I sneezed. It seems to have reshaped reality. My bad.
User avatar
DNS
Ancient Dragon
Posts: 3852
Joined: Mon May 15, 2006 3:47 pm
Location: On top of the rainbow
Contact:

Post by DNS »

An extra two lines of code at the top of the first array, which I wouldn't've caught unless you told me to check for the vars thingum. -hugs- thankyou
Post Reply