Possible to source tcl file with arguments

Moderator: GiD Team

Post Reply
awa5114
Posts: 43
Joined: Thu Jan 26, 2017 5:10 pm

Possible to source tcl file with arguments

Post 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...
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Possible to source tcl file with arguments

Post 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.
Post Reply