Page 1 of 1

Possible to source tcl file with arguments

Posted: Mon Aug 13, 2018 12:39 pm
by awa5114
I would like to run GiD from the command line and have a tcl script act on it as follows:

gid -n -t tcl_script_path

Unfortunately my script also needs 2 command line arguments. So I tried this

gid -n -t "tcl_script_path arg1 arg2"

Which didn't work. Then I tried to source it from within GiD session as follows:

-np- source {tcl_script_path arg1 arg2}

But I got the following error Error: couldn't read file ....

How do I run a tcl script on GiD using command line arguments from the cmd command line (black screen)? Thanks...

Re: Possible to source tcl file with arguments

Posted: Wed Aug 22, 2018 8:55 pm
by escolano
source {tcl_script_path arg1 arg2}
Is not valid, because the Tcl 'source' standard command expects only an argument, the Tcl filename to be sourced.
Its syntax is
source $filename

and about the GiD command line
gid -t tcl_script_path
is not valid because this syntax expects a tcl command, not a filename to be sourced
if the command already cannot be used, because it is not defined, you must before define sourcing it
e.g.
gid -t "source <your_filename> ; <your_procedure> <argument_1> ... <argument_n>"

or you can invoke your procedure directly inside your filename sourced.