Help coderanch get a
new server
by contributing to the fundraiser

ian bert

Greenhorn
+ Follow
since Jun 08, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by ian bert

The point of the Variable object is to serve as a variable in a parsed programming system.
Previous incarnations of the system used string arrays to keep the declared variables, and a system of parseBlah() to get numbers and such. Such a method was extremely tedious and felt the brunt of my programming fury, instead of the more important areas, like the math functions.

I just messed around with Campbells idea to parametrise the class to Variable<T>, which solved a lot of problems but seems to create new ones, mainly the fact that the type, T, must be stated explicitly.
Perferably I'd like a way to do this psudo code


like I said, Variable will be used in its own system, and needs to be extremely dynamic (or at least the system itself does)

Thanks for the help
12 years ago
Im building a generic Variable object for use in a parsed language system.
To make it versatile, the Variable object has a Data object that contains the actual variable data (no way right?).
The problem being that when I want to get the data, I am using a method, getData(), that returns an Object; meaning that I have to cast it later where I want to do things with that data.

Being somewhat new to OOP, I cant figure out a way to dynamically cast the object Data either at the class level, or the return level of getData().

I assume something like this is possible?

here is the Variable class in all its glory, with the important parts pointed out.
12 years ago
All the parts of the code the poster thing wont allow is seperated by a space

Script.js
var xmlDoc;
products.function(id, name, file_size, summary)
{
this.id=id;
this.name=name;
this.file_size=file_size;
this.summary=summary;
}
function loadXML(){
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("product_info.xml");
var id=attrs.getNamedItem("id").value;
var name=attrs.getNamedItem("name").value;
var version=parseFloat(attrs.getNamedItem("file_size").value)
var file_size=attrs.getNamedItem("summary").value;
getmessage();
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("product_info.xml");
var id=attrs.getNamedItem("id").value;
var name=attrs.getNamedItem("name").value;
var version=parseFloat(attrs.getNamedItem("file_size").value)
var file_size=attrs.getNamedItem("summary").value;
xmlDoc.o nload=getmessage;
}
else
{
alert('Your browser cannot handle this script');
}
}
// Actual message maker
function getmessage()
{
document.getElementById("name").innerHTML=xmlDoc.getElementsByTagName("name")[0].childNodes[0].nodeValue;
document.getElementById("file_size").innerHTML=xmlDoc.getElementsByTagName("file_size")[0].childNodes[0].nodeValue;
document.getElementById("summary").innerHTML=xmlDoc.getElementsByTagName("summary")[0].childNodes[0].nodeValue;
document.getElementById("version").innerHTML=xmlDoc.getElementsByTagName("version")[0].childNodes[0].nodeValue;
}

function dio(){
window.open("dio.html");

}

Programs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="SHORTCUT ICON" href="images/logo_orig/bp.ico" />
<script src="script.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Bertolacci Productions~Programs</title>
</head>
<body bgcolor="#fffacd" text="#000000" link="FF4500">
<center>
<h1>Programs</h1>
</center>
<hr color="#CC9900" size=2 width="100%"/>
<center>
<a href="http://www.bertolacciproductions.com"><img src="images/buttons/home.bmp" alt="Home" border="none"/></a>
<a href="new.html"><img src="images/buttons/new.bmp" alt="New" border="none"/></a>
<a href="programs.html"><img src="images/buttons/programs.bmp" alt="Programs" border="none"/></a>
<a href="add-ins.html"><img src="images/buttons/add-ins.bmp" alt="Add-Ins" border="none"/></a>
<a href="box-sets.html"><img src="images/buttons/boxset.bmp" alt="Box Sets" border="none"/></a>
<a href="service.html"><img src="images/buttons/service.bmp" alt="Services" border="none"/></a>
<a href="about.html"><img src="images/buttons/about.bmp" alt="About" border="none"/></a>
<a href="code/codebook.html"><img src="images/buttons/code.bmp" alt="Code Cook Book" border="none"/></a>
</center>
<hr color="#CC9900" size=2 width="100%"/>
<center>
<table border="0">
<tr>
<td width="121">Programs</td>
<td width="121">Games</td>
<td width="121">Other</td>
</tr>
<tr>
<td width="121"></td>
<td width="121"><a o nclick="dio(001)" href="Downloads/programs/games/bustin'_blox.exe">Bustin' Blox</a></td>
<td width="121"></td>

<tr>
</table>
</center>
</body>
</html>

product_info.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<products>
<download id="001" name="Bustin' Blox" file_size"2 Mb" summary"Our version of Brick. Only One Level (Kinda Sucks)" version="1.0"/>
<download id="002" id="001" name="ASDF" file_size"ASDF" summary"ASDF" version="1.0"/>
</products>

dio.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="SHORTCUT ICON" href="images/logo_orig/info.ico" />
<script src="script.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Product Info</title>
</head>
<body o nload="loadXML(id)" bgcolor="#fffacd" text="#000000" link="FF4500">
<center>
<h1>Product Information</h1>
</center>
<p>
<b><u>File Name: </u></b><span id="name"></span><br />
<b><u>File Size: </u></b><span id="file_size"></span><br />
<b><u>File Summary: </u></b><span id="summary"></span><br />
<b><u>File Version: </u></b><span id="version"></span><br />
</p>
</body>
</html>
~Ok so this may seem like deja vu to some, but i need to find a way to use XPath to do an XML Look up. My server can only do Javascritp (duh) or PHP.

~I want to be able to click on a link in an HTML or PHP page and get two dialogues:
1. the Download window
2. the Information Window

~The Information window is my problem. I need to have just one HTML (or PHP0 page for the window and just one XML page. This XML page would have all the information on the products.

~The Information window needs to access the XML page, get the correct entry, load it and display it.

~Does anyone have any idea how to do this, or where I could learn how to do this?
yeah How do i get select pices of XML and bypassing others;

EG:
say i want to get information on a certant download, asdf.zip
i click on the link and two windows come up: the download window and the information window,
but lets say I only want one xml file with all the entries on it, how can i get just one of those entries into that information window?
Hi Hello ? world gone blank?
OK you may have seen my topic in 'HTML and Javascript' but I need all the help I can get.

So here is my problem:

I Need to be able to access file information by putting it in an XML file and parsing it w/ Javascritp or PHP (I chose Javascript because I Kinda know it.)

The System I have worked out right now is:
Click on product link --> a Window comes up and calls the XML file and displaying it on the same page.

But The problem is that The second window only calls the first piece of XML and I don't know how to get it to access a different section.

My code:

main Javascript file (script.js):


the second page/XML display page (dio.html):


the product download page only part of it (programs.html):


XML page (product_info.xml):

[ July 16, 2007: Message edited by: ian bert ]
I recently read something on xpointer and xlink but it didn't help me with my "Quest". but is there a way to use this that I'm not finding?

but my "Quest" is giving me hell. I did read (skim) AJAX in Action and I found some stuff that might help me, but it wasn't done in a way that i could under stand, if only Eric Pascarello could help me (as he wrote it)

P.S. I am getting the reading from www.w3schools.com
Its hard to put the code up because theres a lot. but I have put in a link to a folder with code_stuff.zip it will be on my server.
code_stuff.zip
go here and click on the code_stuff.zip and it will download.
[ July 15, 2007: Message edited by: ian bert ]
no im using just java script and XML
should I?
im not using the XMLHttpRequest but i might try it
but heres the list of events
1. click on link
2. link is also a onclick that makes a new page (dio.html)
3. dio.html requests onload to parser
4. parser get info from xml and sends it to dio.html
5. dio.html displays info