-
Help a new Java head.
I have an applet coded thus:
/*
* 1.0 code.
*/
import java.applet.*;
import java.awt.*;
import java.io.*;
public class GetImages extends Applet {
public void init() {
//g.drawString("Hello", 0, 0);
//setBackground(Color.white);
}
public String[] listBackup(String ImgPath, String TransID) {
String[] arImages;
String[] fileList;
String imgCount;
File newFile = new File(ImgPath);
//g.drawString(ImgPath, 10, 10);
fileList = newFile.list();
arImages = new String[fileList.length];
//imgCount = Integer.toString(fileList.length);
//g.drawString(imgCount, 10, 10);
for (int i = 0; i < fileList.length; i++){
if (fileList[i].startsWith(TransID + "B")) {
//add name to arImages
arImages[i] = String.valueOf(fileList[i]);
}
}
//listBackup = arImages;
return(arImages);
}
}
and attempt to access it with HTML coded thus:
<script src="args.js"></script>
<APPLET Code="GetImages" Width=50 Height=50 Name="getimages"></APPLET>
<script language="JavaScript"><!--
//test script
document.write("<IMG SRC=" + args["Company"] + "/images/" + args["Julian"]
+ "/" + args["Machine"] + args["Trace"]
+ "C.001 HEIGHT=175 WIDTH=300>");
var MyImages = document.getimages.listBackup(("C:\\java\\" + args["Company"]
+ "\\images\\"
+ args["Julian"] + "\\"), (args["Machine"]
+ args["Trace"]));
var i = 0;
for(i = 0; i <= MyImages.length; i++){
document.write("<IMG SRC=" + args["Company"] + "/images/" + args["Julian"]
+ "/" + args["Machine"]
+ args["Trace"] + MyImages[i] + "HEIGHT=175 WIDTH=300>");
}
// --></script>
<HR>
</body>
</html>
Why doesn't the variable MyImages get set to the array returned from listBackup?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks