Используя два файла, вы можете использовать что-то вроде этого.
В этом примере первый скрипт (send.plt
) отправляет «аргументы» в виде одной строки во второй скрипт.
Arg2Sent = "This is a long string send to another script as a single argument"
call "receive.plt" sprintf("%s", Arg2Sent)
Второй скрипт (receive.plt
) содержат:
array Arg[words(ARG1)]
do for [i=1:|Arg|]{
Arg[i] = word(ARG1, i)
print sprintf("Arg[%2g]: %s", i, Arg[i])
}
Выход
Arg[ 1]: This
Arg[ 2]: is
Arg[ 3]: a
Arg[ 4]: long
Arg[ 5]: string
Arg[ 6]: send
Arg[ 7]: to
Arg[ 8]: another
Arg[ 9]: script
Arg[10]: as
Arg[11]: a
Arg[12]: single
Arg[13]: argument
Другой пример, на этот раз с использованием чисел.
Arg2Sent = "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765"
call "receive.plt" sprintf("%s", Arg2Sent)
Выход
Arg[ 2]: 1
Arg[ 3]: 1
Arg[ 4]: 2
Arg[ 5]: 3
Arg[ 6]: 5
Arg[ 7]: 8
Arg[ 8]: 13
Arg[ 9]: 21
Arg[10]: 34
Arg[11]: 55
Arg[12]: 89
Arg[13]: 144
Arg[14]: 233
Arg[15]: 377
Arg[16]: 610
Arg[17]: 987
Arg[18]: 1597
Arg[19]: 2584
Arg[20]: 4181
Arg[21]: 6765
Длинный пример
Arg2Sent = "'first filename with spaces.txt' \
'second filename with spaces.txt' \
'third filename with spaces.txt' \
'fourth filename with spaces.txt' \
'fifth filename with spaces.txt' \
'sixth filename with spaces.txt' \
'seventh filename with spaces.txt' \
'eighth filename with spaces.txt' \
'ninth filename with spaces.txt' \
'tenth filename with spaces.txt' \
'eleventh filename with spaces.txt' \
'twelfth filename with spaces.txt' \
'thirteenth filename with spaces.txt' \
'fourteenth filename with spaces.txt' \
'fifteenth filename with spaces.txt' \
'sixteenth filename with spaces.txt' \
'seventeenth filename with spaces.txt' \
'eighteenth filename with spaces.txt' \
'nineteenth filename with spaces.txt' \
'twentieth filename with spaces.txt'"
call "receive.plt" sprintf("%s", Arg2Sent)
Выход
Arg[ 1]: first filename with spaces.txt
Arg[ 2]: second filename with spaces.txt
Arg[ 3]: third filename with spaces.txt
Arg[ 4]: fourth filename with spaces.txt
Arg[ 5]: fifth filename with spaces.txt
Arg[ 6]: sixth filename with spaces.txt
Arg[ 7]: seventh filename with spaces.txt
Arg[ 8]: eighth filename with spaces.txt
Arg[ 9]: ninth filename with spaces.txt
Arg[10]: tenth filename with spaces.txt
Arg[11]: eleventh filename with spaces.txt
Arg[12]: twelfth filename with spaces.txt
Arg[13]: thirteenth filename with spaces.txt
Arg[14]: fourteenth filename with spaces.txt
Arg[15]: fifteenth filename with spaces.txt
Arg[16]: sixteenth filename with spaces.txt
Arg[17]: seventeenth filename with spaces.txt
Arg[18]: eighteenth filename with spaces.txt
Arg[19]: nineteenth filename with spaces.txt
Arg[20]: twentieth filename with spaces.txt
Последний пример
Arg2Sent = "data.dat 1 2 'lp pt 6' 'pi -1' blue 'A randon example'"
call "receive.plt" sprintf("%s", Arg2Sent)
receive.plt
содержит
array Arg[words(ARG1)]
do for [i=1:|Arg|]{
Arg[i] = word(ARG1, i)
}
filename = sprintf("%s", Arg[1])
firstcolumn = int(Arg[2])
secondcolumn = int(Arg[3])
plottype = sprintf("%s", Arg[4])
pointstyle = sprintf("%s", Arg[5])
color = sprintf("'%s'", Arg[6])
title = sprintf("%s", Arg[7])
plot filename u firstcolumn:secondcolumn w @plottype @pointstyle lc @color t title
выход