Getting Folder list from server

Hi,
I have succeeded in doing this but my method seems a bit laborious. I can't help thinking there must be a better way.
Here is my php code:
(in getFiles.php)
And here are my action sequences:
--------------------------------------------------------------------------------
Actions for Button "getFolders" of Page id 0
--------------------------------------------------------------------------------
-- On click... -----------------------------------------------------------------
Execute Script XMLHttpRequest (HTML)
(url parameter: "../server/getFiles.php", notifyObject parameter: name of self)
-- On User event... ------------------------------------------------------------
Define local variable "ctr" (Initial value: 0)
Define local variable "myArray" (Array)
Define local variable "nameStart" (Initial value: 0)
Define local variable "theLength" (Initial value: 0)
Define local variable "txtline" (Initial value: "")
Comment: value is set to list of files in the directory.
Execute Script pgSplitToArray (HTML)
Comment: splitExp parameter: crlf
Step ctr from 5 to myArray [ 0 ] - 2 by 1
Set txtline to myArray [ ctr ]
If txtline contains "."
Comment: My directories never contain periods.
Else
Comment: The directory name always starts 2 chars after =>
Set nameStart to offset ( ">", txtline ) + 2
Set theLength to charCount ( txtline )
Set txtline to characters nameStart to theLength of txtline
If text of field "result" = ""
Set text of Field "result" to txtline
Else
Set text of Field "result" to text of field "result" & crlf & txtline
End if
End if
End step loop
Is it not possible to convert Javascript arrays directly to Toolbook (Actions) arrays? Are Javascript arrays really just strings in disguise?
I have succeeded in doing this but my method seems a bit laborious. I can't help thinking there must be a better way.
Here is my php code:
(in getFiles.php)
- Code: Select all
<?php
$serverPath=$_SERVER['DOCUMENT_ROOT'].'/programs/';
$files = scandir($serverPath);
print_r($files);
?>
And here are my action sequences:
--------------------------------------------------------------------------------
Actions for Button "getFolders" of Page id 0
--------------------------------------------------------------------------------
-- On click... -----------------------------------------------------------------
Execute Script XMLHttpRequest (HTML)
(url parameter: "../server/getFiles.php", notifyObject parameter: name of self)
-- On User event... ------------------------------------------------------------
Define local variable "ctr" (Initial value: 0)
Define local variable "myArray" (Array)
Define local variable "nameStart" (Initial value: 0)
Define local variable "theLength" (Initial value: 0)
Define local variable "txtline" (Initial value: "")
Comment: value is set to list of files in the directory.
Execute Script pgSplitToArray (HTML)
Comment: splitExp parameter: crlf
Step ctr from 5 to myArray [ 0 ] - 2 by 1
Set txtline to myArray [ ctr ]
If txtline contains "."
Comment: My directories never contain periods.
Else
Comment: The directory name always starts 2 chars after =>
Set nameStart to offset ( ">", txtline ) + 2
Set theLength to charCount ( txtline )
Set txtline to characters nameStart to theLength of txtline
If text of field "result" = ""
Set text of Field "result" to txtline
Else
Set text of Field "result" to text of field "result" & crlf & txtline
End if
End if
End step loop
Is it not possible to convert Javascript arrays directly to Toolbook (Actions) arrays? Are Javascript arrays really just strings in disguise?