Page 1 of 1

Execute commands from external file

PostPosted: Fri Apr 29, 2016 5:35 am
by dglojnar
How can I execute list of commands from external file created with Neobook ?
I try with David Esperalta's npExecActions, work good on runtime, but on compiled publication an error apear "I can't understand this command !"
Commands from external file is functions from different plug-ins.

Here's the code example of external file:

Code: Select all
zmGetFileHash "[data]" "[md5]" "MD5"
zmGetFileHash "[data]" "[sha1]" "SHA1"
npHashCreate "[hash_id]"
npHashFile "[hash_id]" "haSHA512" "[data]" "[sha512]"
FileWrite "[pubdir]List\[list_name]_hash.txt" "[pos]" "[data];[filename];[size];[file_ext];[MD5];[sha1];[SHA512];"


Complete code:

Code: Select all
Loop "2" "[len]" "[pos]"
FileRead "[pubdir]List\[list_name].txt" "[pos]" "[data]"
ExtractFileName "[data]" "[filename]"
FileSize "[data]" "[filesize]"
npFormatBytesSize "[filesize]" "[size]"
ExtractFileExt "[data]" "[file_ext]"
StrReplace "[file_ext]" "." "" "[file_ext]" ""
npExecActions "!D:\Hasher\Hash.txt"
SetVar "[progress]" "Progress [posto] %"
Math "[pos]/[len]*100" "0" "[posto]"
Math "[pos]/[len]*606" "0" "[apos]"
SetObjectFill "Rectangle6" "[filcol]" "Solid" "False"
SizeObject "Rectangle6" "[apos]" "18"

EndLoop


Any idea ?

Re: Execute commands from external file

PostPosted: Fri Apr 29, 2016 6:50 am
by dglojnar
Or different approach:

How can I execute NeoBook command from variable ?

Example:

set var "[exec_hash]" "zmGetFileHash [#34][#91]data[#93][#34] [#34][#91]md5[#93][#34] [#34]MD5[#34]"

Re: Execute commands from external file

PostPosted: Fri Apr 29, 2016 8:04 am
by HPW
Hello,

For your first Problem add a hidden object or a unused subroutine to your Pub with one command of each wanted plugin.
This let the neobook Compiler pack/link the plugins into the final exe.
Then your external file will know/find the commands
You can control the packing by viewing Book\FileList\Required plugins
You can call a extern macro-file by using neobooks own "call" command.
You use a Name which does not exist as a function.
Then you make a Textfile with that Name and without Extension.
You put it in that folder where your final exe is. Then the "call" will execute that file instead of a function from the function library

For playing commands from string you may have a look at hpwPlayAction-plugin.

Regards

Re: Execute commands from external file

PostPosted: Fri Apr 29, 2016 12:34 pm
by dglojnar
Dear Hans !

Thank you for quick answer:-)

Maybe I'm stupid, but I'm stuck...

First, the problem is that my commands are generated dynamically, so I never have the same commands in the external file.
Second, If I understand right, I need to create one subroutine for one plug-in command ?
Or one subroutine for all commands ?

You can call a extern macro-file by using neobooks own "call" command.
You use a Name which does not exist as a function.
Then you make a Textfile with that Name and without Extension.
You put it in that folder where your final exe is. Then the "call" will execute that file instead of a function from the function library


Well, I check and there's no function with this name (Hash)
Then I create (from program) a regular text file with name "Hash" without extension.
This file is located in [pubdir] where my EXE is.
I put CALL "Hash"
Or I nedd enter CALL "[pubdir]Hash" ?
Try both options - in debug mode work fine, in compiled version not.
When I compiled, compiler warn me that function "Hash" does not exists.

I'm I doing something wrong ?

Re: Execute commands from external file

PostPosted: Fri Apr 29, 2016 10:15 pm
by HPW
Hello,

One subroutine with one command of each plugin. Does not matter which.
The plugin Name must appear in file-list under required plugins.

CALL "Hash"
You will get a error on compile which says that a fuction hash is missing in the function library. Ignore.
Also it does not work in Design time.
Start the compiled Exe and try.

Edit: When your exe is installed to C:\Program files\ then you will have Problems with creating files because UAC security.

Regards

Re: Execute commands from external file

PostPosted: Sat Apr 30, 2016 3:10 am
by dglojnar
Dear Hans !

Work perfectly !
Thank you very much for your time and effort !



With best regards !
Drazen