Source language: Translate to:

Execute commands from external file

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Execute commands from external file

Postby dglojnar » Fri Apr 29, 2016 5:35 am

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 ?
dglojnar
 
Posts: 112
Joined: Sun Apr 03, 2005 10:52 pm

Re: Execute commands from external file

Postby dglojnar » Fri Apr 29, 2016 6:50 am

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]"
dglojnar
 
Posts: 112
Joined: Sun Apr 03, 2005 10:52 pm

Re: Execute commands from external file

Postby HPW » Fri Apr 29, 2016 8:04 am

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
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Execute commands from external file

Postby dglojnar » Fri Apr 29, 2016 12:34 pm

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 ?
dglojnar
 
Posts: 112
Joined: Sun Apr 03, 2005 10:52 pm

Re: Execute commands from external file

Postby HPW » Fri Apr 29, 2016 10:15 pm

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
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Execute commands from external file

Postby dglojnar » Sat Apr 30, 2016 3:10 am

Dear Hans !

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



With best regards !
Drazen
dglojnar
 
Posts: 112
Joined: Sun Apr 03, 2005 10:52 pm


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest