Search these areas:
Support Forums
Product Info

-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Data Analysis
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

Script Library

  Script to do a simple directory listing (like some web servers do)
  chubbard posted this script:
  // showdir - show a directory listing on a westside directory
//   If you do something like and there's no file there
// and the permissions are right, and the moon is blue, you'll often get a directory
// listing. Westside webs don't have this default behaviour, so this script provides it.
//   This script does the same thing for a westside web. It looks prettier, but you
// still need a default.view file in each dir, though it can be really short,
// e.g., assuming you save the script in /, create a view file in the target
// dir with the contents:
------ default.view starts here
<link rel="stylesheet" href="/default.css" type="text/css" />
<ws:viewinfo version="0.41" masterpage="/master.view" modifiedby="mike[]" />
<body bgcolor="#FFFFFF">
------ default.view ends here
// actual function starts here
// depending on your web permissions you may not want the asadmin permission below

public asadmin function showdir()
// first find the current dir by opening the URI file requested and
// then getting its folder

  var uri = request.getRequestURI();
  var oFile = File(uri);
  var sPath = oFile.getFolderPath();

// let's use a table rather than <pre>

<h3>Directory for <%= sPath %></h3>

// now get all the filenames and write them out

  var aFiles = Folder.create(sPath).getFileNames();
  for (var i = 0; i < aFiles.length; i++)
    var oFile = File(sPath + aFiles[i]);
    var sClass = (1 == i % 2) ? "ws-data-td" : "ws-data-alt-td";
    <tr class="<%= sClass %>">
    <td><a href='<%= aFiles[i] %>'><b><%= aFiles[i] %></b></a></td>
    <td align="right"><%= oFile.getSize() %></td>
    <td><%= oFile.getDateCreated() %></td>
    <td><%= oFile.getDateModified() %></td>

<p />
<p>Total of <%= aFiles.length %> files</p>
return "";
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us