Link to home
Start Free TrialLog in
Avatar of Caiapfas
Caiapfas

asked on

Make a listing option while making the webpages

ok, I want to edit this javascript and add a new Var/function. I'm going to create a perl script that looks at the htm files made from this javascript and finds on the very first line <!--_STATE__--> and automaticly adds a link to the page on the main section, for this case Venues. So what I want to do when I initiate the script I would like it to prompt me to ( Do you want to add the (Y)States or the (N)First Letter for the Artist/Venues?) so it would change the output of _STATE_, reason I'm using this script for making artist/events. And the new PERL program will either input a link to the venue under the right section(State) or a link to the artist page under the right letter. SAVING ME HOURS!!!!

I know there are better scripts/ways, but for this case i'm working with legancy. I do plan to move to asp.net, but the need it now. not when I learn asp.net.

Thank you,
Caiapfas


var template = "C:\\aa\\venuetemplate.htm";
var list = "C:\\aa\\venues2.csv";
var dstFolder = "C:\\aa\\venues\\";

var fso =new ActiveXObject("Scripting.FileSystemObject");

//read template
var templFile = fso.OpenTextFile(template, 1);
var templText = templFile.ReadAll();
templFile.close();
WScript.StdOut.WriteLine("Template length is: " + templText.length);

//process venue list
var listFile = fso.OpenTextFile(list, 1);
var head=listFile.ReadLine(); //skip header
WScript.StdOut.WriteLine("Header line: " + head);
while(!listFile.AtEndOfStream) {
  var line=listFile.ReadLine();
  WScript.StdOut.WriteLine("processing line: " + line);
  var fields=line.split(",");   // Comma Delimited
//var fields=line.split("\t");  // Tabs
  WScript.StdOut.WriteLine("fields#: " + fields.length);
  try {
    var VenueID=fields[0];
    WScript.StdOut.WriteLine("venue id: " + fields[0]);
    var VenueName=fields[1];    
    WScript.StdOut.WriteLine("venue name: " + fields[1]);
    var VenueState=fields[2];    
    WScript.StdOut.WriteLine("venue name: " + fields[1]);
    var fname=VenueName.toLowerCase().replace(/ /g, "_") + ".htm";
    WScript.StdOut.WriteLine("output filename: " + fname);
    var dstFileFullname=fso.BuildPath(dstFolder, fname);
    WScript.StdOut.WriteLine("dest filename: " + dstFileFullname);
    var dstFile = fso.CreateTextFile(dstFileFullname, true);    
    dstFile.write(templText.replace(/_VENUE_NAME_/g, VenueName).replace(/_VENUE_ID_/g, VenueID).replace(/_STATE_/g, VenueState));
    dstFile.close();
   }
   catch(e) {
    WScript.echo("Error processing venue id " + VenueID + " with name '" + VenueName + "'");
   }
               
}
listFile.close();
Avatar of Caiapfas
Caiapfas

ASKER

a footnote (N)First Letter for the Artist/Venues?) a.k.a NO, would ignore column 3 and take the first letter of the Venue Name/Artist name...
ASKER CERTIFIED SOLUTION
Avatar of lbertacco
lbertacco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you,

you hit it right on the head, a quick side question...is this just javascript? cause I see things i dont recongnize..
Javascript and Windows Scripting Host
cool, I'm learning perl right now, but I seem to be trying to much at once, altought the results are rolling in, now I have the means to make thousands of custom pages but I need a way to add them the a main section(page). I don't think javascript can do this, so I tried my infant perl skills, ouch would ya mind taking a look?

https://www.experts-exchange.com/questions/20935310/help-Making-a-automatic-link-maker.html

after this I'm on easy street just need to read, read, read and soon asp.net adventures begin..
lbertacco,

Do you think I could get you email address, mine it support@cdatasolutions.com << you can email if you want to keep it off EE..I want to add you to the

// Version 1.3 - PageBuilder
// Script Design by lbertacco

before I hand it over to my friend and I wouldnt mind having it..=}