rejetto forum

{.for each.} exception

raybob · 9 · 2650

0 Members and 1 Guest are viewing this topic.

Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
I'm trying to use HFS to compile an XML file.  Everything works fine except that the command {.for each.} appears to not be working.  I've boiled down my code as much as possible, yet it still doesn't work.  I don't see any errors in my code, although there very well might be.

For debugging purposes I've attached the macro log, in which it states an exception and to report the bug.  According to the log everything processes fine until it gets to the extremely basic {.for each.} command and then it just doesn't process it.

Is it possible that you can't use {.for each.} inside {.save.}, or is this a bug in HFS itself ?
« Last Edit: September 01, 2011, 07:32:50 PM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
Upon further testing, it seems that this command doesn't work at all.... however it does work as used in other places of my template such as [ajax.move].  Perhaps it only doesn't work when used in HFS.events?

Here's as simple as I could make it:

Code: [Select]
9/1/2011 3:31:24 PM
exists|command.txt
    1
if|1|{: {.load|command.txt.} {.delete|command.txt.} :}
    {.load|command.txt.} {.delete|command.txt.}
load|command.txt
    {.for each|fn|user1|user2|user3|user4|{:{.save|test{.random|1|2|3|4|5|6|7|8|9.}.txt|{.^fn.}.}:}.}
for each|fn|user1|user2|user3|user4|{:{.save|test{.random|1|2|3|4|5|6|7|8|9.}.txt|{.^fn.}.}:}
    <div class=macroerror>macro error: for each<br>cannot be used here</div>
for each|fn|user1|user2|user3|user4|{:{.save|test{.random|1|2|3|4|5|6|7|8|9.}.txt|{.^fn.}.}:}
    Exception, please report this bug on www.rejetto.com/forum/
delete|command.txt

I was also able to reproduce this with a fresh copy of HFS with absolutely nothing changed.

« Last Edit: September 01, 2011, 08:07:15 PM by raybob95 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
sorry for being so late.
could you provide me an hfs.events that will reproduce the problem on my hfs ?


Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
Like I said, I reproduced this on a fresh install of HFS, so you should be able to with ease.

Hfs.events
Code: [Select]
[every 10 seconds]
{.if|{.exists|command.txt.}|{:
{.load|command.txt.}
{.delete|command.txt.}
:}.}

Command.txt
Code: [Select]
{.for each|fn|user1|user2|user3|user4|{:{.save|test{.random|1|2|3|4|5|6|7|8|9.}.txt|{.^fn.}.}:}.}



EDIT:

I think I may have also found a similar bug with {.for.} .... try putting this in command.txt:

Code: [Select]
{.for|n|1|1000000|{.append|numbers.txt|{.^n.}.}.}
It tells me {.for.} and ^n cannot be used here.


« Last Edit: September 23, 2011, 08:52:47 PM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
Here's another example of code that doesn't work....

Code: [Select]
{.for each|user|{.replace|;|{.no pipe||.}|{.load|Master User List.txt.}.}|{:{.save|C:\Documents and Settings\Admin\Desktop\Account Keys\{.^user.}.txt|{.load|32 Random.txt.}.}:}.}

Either in command.txt or in Debug>Run Script   in HFS.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
sorry for the late reply.
I understand this is very unclear, the message should be improved.
The reason why it "cannot be used here" it's because you are using simple variables outside a connection.
Simple variables are bound to the connection. You are running those scripts outside a connection.
Anyway, i think the better would be if it would just work as excepected, so i will try to create a temporary context (as for the connection) where to store such variables.
Thank you for pointing it out.


Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
Hey you're right it works in the template....

Here's my finished Ajax Script :)

Code: [Select]
[ajax.FTP]

{.if|{.and|{.cookie|username.}|{.cookie|accountkey.}|{.=|{.cookie|accountkey.}|{.load|C:\Documents and Settings\admin\Desktop\Account Keys\{.cookie|username.}.txt.}.}.}|{:{.set|loggedon|1.}{.set|username|{.cookie|username.}.}:}.}

{.if|{.^username.}|{:
{.if|{.exists|C:\documents and settings\admin\desktop\FTP Config\{.^username.}.txt.}|{:{.set|action|delete.}:}|{:{.set|action|add.}:}.}

{.if|{.=|{.^action.}|add.}|
{:{.append|C:\documents and settings\admin\desktop\FTP Config\USERS.txt|;{.^username.}.}:}|
{:{.save|C:\documents and settings\admin\desktop\FTP Config\USERS.txt|{.replace|;{.^username.}||{.load|C:\documents and settings\admin\desktop\FTP Config\users.txt.}.}.}:}.}

{.if|{.=|{.^action.}|add.}|
{:{.mkdir|D:\[USER FILES]\{.^username.}\FTP Shared.}:}.}

{.if|{.=|{.^action.}|add.}|
{:{.save|C:\documents and settings\admin\desktop\User Options\{.^username.}\FTP.txt|YES.}:}|
{:{.delete|C:\documents and settings\admin\desktop\User Options\{.^username.}\FTP.txt.}:}.}


{.if|{.=|{.^action.}|add.}|{:
{.save|c:\documents and settings\admin\desktop\ftp config\{.^username.}.txt|
<User Name="{.^username.}">
            <Option Name="Pass">{.if not|{.postvar|password.}|{:{.get account|{.^username.}|password.}:}|{:{.postvar|password.}:}.}</Option>
            <Option Name="Group" />
            <Option Name="Bypass server userlimit">0</Option>
            <Option Name="User Limit">0</Option>
            <Option Name="IP Limit">0</Option>
            <Option Name="Enabled">1</Option>
            <Option Name="Comments" />
            <Option Name="ForceSsl">0</Option>
            <IpFilter>
                <Disallowed />
                <Allowed />
            </IpFilter>
            <Permissions>
                <Permission Dir="C:\FTP Home">
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">0</Option>
                    <Option Name="FileDelete">0</Option>
                    <Option Name="FileAppend">0</Option>
                    <Option Name="DirCreate">0</Option>
                    <Option Name="DirDelete">0</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">1</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>
                <Permission Dir="D:\[USER FILES]\{.^username.}\[private]">
                    <Aliases>
                        <Alias>/PRIVATE</Alias>
                    </Aliases>
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">1</Option>
                    <Option Name="FileDelete">1</Option>
                    <Option Name="FileAppend">1</Option>
                    <Option Name="DirCreate">1</Option>
                    <Option Name="DirDelete">1</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>
                <Permission Dir="D:\[USER FILES]\{.^username.}\FTP Shared">
                    <Aliases>
                        <Alias>/SHARED</Alias>
                    </Aliases>
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">1</Option>
                    <Option Name="FileDelete">1</Option>
                    <Option Name="FileAppend">1</Option>
                    <Option Name="DirCreate">1</Option>
                    <Option Name="DirDelete">1</Option>
                    <Option Name="DirList">1</Option>
                    <Option Name="DirSubdirs">1</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>
            </Permissions>
            <SpeedLimits DlType="0" DlLimit="10" ServerDlLimitBypass="0" UlType="0" UlLimit="10" ServerUlLimitBypass="0">
                <Download />
                <Upload />
            </SpeedLimits>
        </User>
.}:}|{:{.delete|c:\documents and settings\admin\desktop\ftp config\{.^username.}.txt.}:}.}



{.if|{.=|{.^action.}|add.}|{:
{.save|c:\documents and settings\admin\desktop\FTP config\{.^username.}-anonymous.txt|                
<Permission Dir="D:\[USER FILES]\{.^username.}\FTP Shared">
                    <Aliases>
                        <Alias>/{.^username.}</Alias>
                    </Aliases>
                    <Option Name="FileRead">1</Option>
                    <Option Name="FileWrite">0</Option>
                    <Option Name="FileDelete">0</Option>
                    <Option Name="FileAppend">0</Option>
                    <Option Name="DirCreate">0</Option>
                    <Option Name="DirDelete">0</Option>
                    <Option Name="DirList">0</Option>
                    <Option Name="DirSubdirs">0</Option>
                    <Option Name="IsHome">0</Option>
                    <Option Name="AutoCreate">0</Option>
                </Permission>
.}:}|{:{.delete|c:\documents and settings\admin\desktop\ftp config\{.^username.}-anonymous.txt.}:}.}



{.delete|C:\Program Files\FileZilla Server\FileZilla Server.xml.}

{.save|C:\Program Files\FileZilla Server\FileZilla Server.xml|<FileZillaServer>
{.load|C:\documents and settings\admin\desktop\FTP Config\SETTINGS.txt.}
<Groups />
<Users>
{.load|C:\documents and settings\admin\desktop\FTP Config\ANONYMOUS1.txt.}
{.for each|user|{.replace|;|{.no pipe||.}|{.load|C:\documents and settings\admin\desktop\FTP Config\users.txt.}.}|{:{.if|{.!=|{.^user.}|null.}|{:{.load|C:\documents and settings\admin\desktop\FTP Config\{.^user.}-anonymous.txt.}:}.}:}.}
{.load|C:\documents and settings\admin\desktop\FTP Config\ANONYMOUS2.txt.}
{.for each|user|{.replace|;|{.no pipe||.}|{.load|C:\documents and settings\admin\desktop\FTP Config\users.txt.}.}|{:{.if|{.!=|{.^user.}|null.}|{:{.load|C:\documents and settings\admin\desktop\FTP Config\{.^user.}.txt.}:}.}:}.}
</Users>
</FileZillaServer>.}

{.exec|Reload Config.bat.}

{.if|{.=|{.^action.}|add.}|New FTP Account Added Successfully!.}
{.if|{.=|{.^action.}|delete.}|FTP Account Deleted Successfully!.}

:}|{:{.redirect|/~deny.}:}.}


Code: [Select]
<script type="text/javascript">

function AJAXDisableFTP() { $.post("/~ajax.FTP", function(data) { $.prompt(data, { buttons:{Submit:"Submit"}, submit: function(){ window.location = '{.get account|{.^username.}|redirect.}'; } } ); }); }

function AJAXEnableFTP() {

var passwordinput = 'Enter your desired FTP Password or leave the field<br />blank to use your current HTTP account password:<br /><div style="height:16px;"></div><input name="password" type="password" size="60" /><br /><div style="height:16px;"></div>This password cannot be changed later!';
$.prompt(passwordinput,{ buttons:{Submit:"Submit"}, submit: function(v,m,f){ $.post("/~ajax.FTP", { password: f.password }, function(data) { $.prompt(data, { buttons:{Submit:"Submit"}, submit: function(){ window.location = '{.get account|{.^username.}|redirect.}' } } ); }); } });

}

</script>
« Last Edit: October 09, 2011, 11:13:17 PM by raybob95 »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 453
    • View Profile
    • FileSplat.com
Also it seems as if {.disconnect.} does not work under the [download] events section....

Sorry Rejetto if I'm overloading you with requests this really already is great software and I'm a little over-zealous  ;)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13308
    • View Profile
Also it seems as if {.disconnect.} does not work under the [download] events section....

it works here. I put this in the events and i'm correctly prevented from downloading anything.

[download]
{.disconnect.}

Quote
Sorry Rejetto if I'm overloading you with requests this really already is great software and I'm a little over-zealous  ;)


it's alright, it's not you :)