Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help with Perlscript (no syntax errors!!! ahhhh) works but needs

Status
Not open for further replies.

Phalanx1

Programmer
Jul 21, 2003
128
US
<script language=&quot;PerlScript&quot;>
use Win32::OLE;
use Win32::OLE::Const;
sub ListIt {
my $arial =(&quot;arial&quot;);
my $center=(&quot;center&quot;);
my $FSO = Win32::OLE->new(&quot;Scripting.FileSystemObject&quot;);
$window->document->{drivebox}->{style}->{fontfamily} = $arial;
$window->document->{drivebox}->{style}->{fontsize} = (&quot;12&quot;);
$window->document->{folbox}->{style}->{fontfamily}= $arial;
$window->document->{folbox}->{style}->{fontsize} = (&quot;11&quot;);
$window->document->{filbox}->{style}->{fontfamily} = $arial;
$window->document->{filbox}->{style}->{fontsize} = (&quot;11&quot;);
$window->document->{lab}->{style}->{textalign} = $center;
$window->document->{lab}->{style}->{pixelwidth} = (&quot;450&quot;);
$window->document->{labfil}->{style}->{textalign} = $center;
$window->document->{labfil}->{style}->{pixelwidth} = (&quot;440&quot;);
$window->document->{labfil}->{innertext} =&quot;No file selected->&quot;;
my $Drvs = $FSO->{Drives};
foreach my $oDrv (in ($Drvs)){
if (my $oDrv->DriveType = &quot;2&quot;){
$sVal = $oDrv->{DriveLetter};
$sName = $sVal & &quot; - &quot; & $oDrv->{VolumeName};
$Opt = $window->document->{createElement}(&quot;OPTION&quot;);
$window->document->{Opt}->{text} = $sName;
$window->document->{Opt}->{value} = $sVal;
$window->document->{drivebox}->{add} = $Opt;

$window->{execScript $UpdateDrive &quot;c&quot;};
}
}
next ;
undef $Drvs;
}

sub drivebox_onchange {
if ($window->document->{drivebox}->{value} =&quot;&quot;) {
}
my $dbvalue = $window->document->{drivebox}->{value};
$window->{execScript}(UpdateDrive($dbvalue));
}
sub folbox_onclick {
if ($window->document->{folbox}->{value} =0) {
$sFolPath = $window->document->{folbox}->{value};
$window->document->{lab}->{innertext} = $sFolPath;
$window->{execScript}(UpdateFolder($sFolPath));
}
}
sub folbox_ondblclick {
#--change folder box to subfolder contents of clicked folder->
if ($window->document->{folbox}->{value} = 0){
$sFolPath = $window->document->{folbox}->{value};
$window->document->{lab}->{innertext} = $sFolPath;
$window->{execScript}(UpdateFolder($sFolPath));
$window->{execScript}(GetSubFolders($sFolPath));
}
}
sub filbox_onclick {
$window->document->{labfil}->{innertext} = $sFolPath & '\\' & $window->document->{filbox}->{value};
}
sub UpdateDrive($sDrive) {
my $FSO1= Win32::OLE->new(&quot;Scripting.FileSystemObject&quot;);
my $Opt = $window->document->{createElement} = (&quot;OPTION&quot;);
$window->document->{Opt}->{text} = &quot;________________________________________&quot;;
$window->document->{Opt}->{value} =(&quot;0&quot;);
$window->document->{folbox}->{add} = $Opt;

my $Opt1 = $window->document->{createElement} = (&quot;OPTION&quot;);
$window->document->{Opt}->{text} = &quot;________________________________________&quot;;
$window->document->{Opt}->{value} = (&quot;0&quot;);
$window->document->{filbox}->{add} = $Opt1;
my $oDrv = $FSO1->GetDrive($sDrive & &quot;:\\&quot;);
my $oFol1 = $oDrv->{RootFolder};
my $oFols = $oFol1->{SubFolders};
foreach $oFol (in ($oFols)) {
$sFol = $oFol->{Name};
$PFol = $oFol->{Path};
my $Opt2 = $window->document->{createElement} = (&quot;OPTION&quot;);
$window->document->{Opt}->{text} = $sFol;
$window->document->{Opt}->{value} = $PFol;
$window->document->{folbox}->{add} = $Opt2;
}
next

my $oFils = $oFol1->Files;
foreach $oFil (in ($oFils)) {
my $sFil = $oFil->{Name};
my $Opt3= $window->document->{createElement} = (&quot;OPTION&quot;);
$window->document->{Opt}->{text} = $sFil;
$window->document->{Opt}->{value} = $sFil;
$window->document->{filbox}->{add} = $Opt3;
}
next
undef $FSO1;
my $sFolPath = $sDrive & (&quot;:&quot;);
$window->document->{lab}->{innertext} = $sFolPath;
}
</script>
 
Phalanx...

I suggest that you take the time to write a description of your problem when you post to the forum. Having the code is always useful in debugging a problem, as would the following details:

- the expected functionality
- the actual functionality
- a description of what you have already tried
- details on the environment that the problem occurs

I would have thought that these things were just common sense, but when I look at the threads you have started, 7 out of 8 just appear to be a dump of code and a cryptic subject.

Please give us some respect and I'm sure you will find plenty of people willing (and able) to assist.

Thank you,
Jeff
 
Not only is the post unhelpful, it's not even on-topic for this forum (being as it is the Javascript forum).

Suggest you try the Perl forum: forum219
 
I am very sorry about that...
but i can not find a client side perlscript site.
but the purpose of this is part of client side directory listing of the viewers files and that 'viewer' can execute and edit those files....
here is the source that is written in vbscript that im converting to perlscript. again i am sorry for this but i can not find a client side site for perlscript and the people here seem to be incredibly knowledgable and ingenuity run rampant. please help if you can...

sorry about the vbscript could convert to javascript (Ucase vbs.)
so i tried perlscript but here is the vbs.
<code>
<SCRIPT LANGUAGE=&quot;vbscript&quot;>
Public FSO
Dim sFolPath
Sub GetIt()
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim Drvs, oDrv, sName, sVal, Opt
drivebox.style.fontfamily = &quot;arial&quot;
drivebox.style.fontsize = 12
folbox.style.fontfamily = &quot;arial&quot;
folbox.style.fontsize = 11
filbox.style.fontfamily = &quot;arial&quot;
filbox.style.fontsize = 11
lab.style.textalign = &quot;center&quot;
lab.style.pixelwidth = 450
labfil.style.textalign = &quot;center&quot;
labfil.style.pixelwidth = 440
labfil.innertext = &quot;No file selected.&quot;
Set Drvs = FSO.Drives
For Each oDrv in Drvs
If oDrv.DriveType = 2 Then '--fixed
sVal = UCase(oDrv.DriveLetter)
sName = sVal & &quot; - &quot; & oDrv.VolumeName
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = sName
Opt.value = sVal
drivebox.add Opt
Set Opt = Nothing
End If
Next
Set Drvs = Nothing
Set FSO = Nothing

updatedrive &quot;C&quot;

End Sub

sub drivebox_onchange()
If drivebox.value = &quot;&quot; Then Exit Sub
updatedrive drivebox.value
End Sub

Sub folbox_onclick()
If folbox.value = &quot;0&quot; Then Exit Sub
sFolPath = folbox.value
lab.innertext = sFolPath '--all new
updatefolder sFolPath
End Sub


Sub folbox_ondblclick()
'--change folder box to subfolder contents of clicked folder.
If folbox.value = &quot;0&quot; Then Exit Sub
sFolPath = folbox.value '--all new.
lab.innertext = sFolPath
updatefolder sFolPath
GetSubFolders sFolPath
End Sub

Sub filbox_onclick()
If filbox.value <> &quot;0&quot; Then
labfil.innertext = sFolPath & &quot;\&quot; & filbox.value
End If
End Sub

Sub UpdateDrive(sDrive)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim sSel, sFol, sFil, i, oDrv, oFol, oFol1, oFols, oFils, oFil, Opt, PFol
On Error Resume Next
folbox.length = 0
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = &quot;________________________________________&quot;
Opt.value = &quot;0&quot;
folbox.add Opt
Set Opt = Nothing

filbox.length = 0
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = &quot;________________________________________&quot;
Opt.value = &quot;0&quot;
filbox.add Opt
Set Opt = Nothing

Set oDrv = FSO.GetDrive(sDrive & &quot;:\&quot;)
Set oFol1 = oDrv.RootFolder
Set oFols = oFol1.SubFolders
For Each oFol in oFols
sFol = oFol.Name
PFol = oFol.Path
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = sFol
Opt.value = PFol
folbox.add Opt
Set Opt = Nothing
Next

Set oFols = Nothing
Set oFils = oFol1.Files
For Each oFil in oFils
sFil = oFil.Name
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = sFil
Opt.value = sFil
filbox.add Opt
Set Opt = Nothing
Next
Set oFils = Nothing
Set oFol1 = Nothing
Set oDrv = Nothing
Set FSO = Nothing
sFolPath = sDrive & &quot;:&quot;
lab.innertext = sFolPath
End Sub

Sub UpdateFolder(sFolP)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim oFol, oFils, oFil, sFil, Opt
On Error Resume Next
If FSO.FolderExists(sFolP) = False Then
Exit Sub
End If

filbox.length = 0
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = &quot;________________________________________&quot;
Opt.value = &quot;0&quot;
filbox.add Opt
Set Opt = Nothing

Set oFol = FSO.GetFolder(sFolP)
Set oFils = oFol.Files
For Each oFil in oFils
sFil = oFil.Name
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = sFil
Opt.value = sFil
filbox.add Opt
Set Opt = Nothing
Next
Set oFils = Nothing
Set oFol = Nothing
Set FSO = Nothing
End Sub

Sub GetSubFolders(sPathSub)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim s1, oFol, oFols, sFol, oFol1, PFol
On Error Resume Next
If FSO.FolderExists(sPathSub) = False Then Exit Sub
folbox.length = 0
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = &quot;________________________________________&quot;
Opt.value = &quot;0&quot;
folbox.add Opt
Set Opt = Nothing

Set oFol1 = FSO.GetFolder(sPathSub)
Set oFols = oFol1.SubFolders
For Each oFol in oFols
sFol = oFol.Name
PFol = oFol.Path
Set Opt = document.createElement(&quot;OPTION&quot;)
Opt.text = sFol
Opt.value = PFol
folbox.add Opt
Set Opt = Nothing
Next
Set oFols = Nothing
Set oFol1 = Nothing
Set FSO = Nothing
End Sub

Sub butup_onclick()
Dim s3, r
s3 = lab.innertext
If Len(s3) < 4 Then Exit Sub
r = InStrRev(s3, &quot;\&quot;)
If r < 4 Then
s3 = Left(s3, 3)
Lab.innertext = Left(s3, 2)
sFolPath = Left(s3, 2)
Else
s3 = Left(s3, (r - 1))
Lab.innertext = s3
sFolPath = s3
End If

Getsubfolders s3
Updatefolder s3
End Sub

Sub butopen_onclick()
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim sFil
On Error Resume Next
sFil = filbox.value
If sFil = &quot;&quot; or FSO.FileExists(sFolPath & &quot;\&quot; & sFil) = False Then
Set FSO = Nothing
Exit Sub
End If
OpenFil(sFolPath & &quot;\&quot; & sFil)
End Sub

Sub OpenFil(sPathFil)
Dim SH, sExt, s, s1, CK, Lex, sEXE
Set SH = CreateObject(&quot;WScript.Shell&quot;)
Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
CK = &quot;\Shell\Open\Command\&quot;
sExt = &quot;.&quot; & FSO.GetExtensionName(sPathFil)
Err.clear
On Error Resume Next

s = SH.RegRead(&quot;HKCR\&quot; & sExt & &quot;\&quot;) '--look up ext in HKCR.
If Err.number <> 0 Then
MsgBox &quot;This is an unregistered file type with no default program to open it.&quot; & vbcrlf & &quot;Error: &quot; & Err.description, 64
Exit Sub
End If

s1 = SH.RegRead(&quot;HKCR\&quot; & s & CK)
If Err.number <> 0 Then
MsgBox &quot;Default program not found.&quot;, 64
Exit Sub
End If

Lex = InStr(1, s1, &quot;exe&quot;, 1)
If Lex <> 0 Then
s1 = Left(s1, (Lex + 2))
sEXE = Replace(s1, Chr(34), &quot;&quot;)
sEXE = Chr(34) & sEXE & chr(34) & &quot; &quot; & chr(34) & sPathFil & Chr(34)
SH.Run sEXE, 4, False
If Err.number <> 0 Then
MsgBox &quot;Error opening file.&quot; & vbcrlf & hex(Err.number) & &quot; : &quot; & Err.description, 64
End If
End If
Set FSO = Nothing
End Sub
</SCRIPT>
<!-- and the HTML that interacts with it-->
<html>
<head>
<title>Client Side Lister</title>
</head>
<body>
<DIV ALIGN=&quot;center&quot; id=&quot;CSL&quot;>
<TABLE CELLPADDING=10 BORDER=1 BORDERCOLOR=&quot;#0000A0&quot; width=450>
<TR><TD><input type=&quot;button&quot; value=&quot;open a file of your computer&quot; onclick=&quot;GetIt()&quot;>
<TABLE><TR><TD ALIGN=&quot;center&quot;>
<FONT FACE=&quot;arial&quot; SIZE=1 COLOR=&quot;#0000A0&quot;><B>
<LABEL ID=&quot;lab&quot;></LABEL>
</B></FONT>
</TD></TR></TABLE>
<TABLE>
<TR>
<TD>
<FONT FACE=&quot;arial&quot; SIZE=2 COLOR=&quot;#0000A0&quot;><B>
Drives:
</B></FONT><BR>

<SELECT ID=&quot;drivebox&quot; SIZE=1>
</SELECT>

</TD>

<TD COLSPAN=40>
<FONT FACE=&quot;arial&quot; SIZE=2 COLOR=&quot;#0000A0&quot;><B>
Folders:
</B></FONT><BR>

<SELECT ID=&quot;folbox&quot; SIZE=8>
</SELECT>

<INPUT NAME=&quot;butup&quot; TYPE=&quot;button&quot; VALUE=&quot;Up&quot;></INPUT>
<BR><BR>
<FONT FACE=&quot;arial&quot; SIZE=2 COLOR=&quot;#0000A0&quot;><B>
Files:
</B></FONT><BR>
<SELECT ID=&quot;filbox&quot; SIZE=8>
</SELECT>

</TD>
</TR>
</TABLE>
<BR>
<TABLE>
<TR><TD WIDTH=440 ALIGN=&quot;center&quot;>
<FONT FACE=&quot;arial&quot; SIZE=1 COLOR=&quot;#0000A0&quot;><B>
<LABEL ID=&quot;labfil&quot;></LABEL>
</B></FONT><BR><BR>
<INPUT NAME=&quot;butopen&quot; TYPE=&quot;button&quot; VALUE=&quot;Open File&quot;>
</TD>

</TABLE>
</TD></TR>
</TABLE>
</DIV>
</body>
</html>
the problem is ??? it sez there is not one >:-<
please help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top