Currently the peptidiotr script has nothing in the way of arrays and no way to store a sequence of data in an iterable set of variables.
Arrays could be implemented simply by defining their elements as discrete variables with names like $array[0], $array[1] etc. Code could recognize that any occurrence of [% in a variable name is to be interpreted in such a way that a subscript variable like %i is converted to its integer value, so that if %i = 21 then $array[%i] and $array[21] are the same var.
PHP has a nice feature where if one declares $varname = "foo", it is then possible to write $$varname and get the same variable as $foo. Perhaps a similar feature could be added to peptiditor, where a variable name like @coord%res_no is legal provided %res_no is set to a positive (or zero) value. Then for example if a loop is counting %i from 1 to 7, then %TMR%i.s and %TMR%i.e would evaluate to the automagic TMR start/end variables, etc. With this kind of feature, it would be unnecessary to look for a square bracket - array syntax would just work, and the use of brackets, parentheses, or any other delimiter would be merely a coding convention.
Currently the peptidiotr script has nothing in the way of arrays and no way to store a sequence of data in an iterable set of variables.
Arrays could be implemented simply by defining their elements as discrete variables with names like
$array[0]
,$array[1]
etc. Code could recognize that any occurrence of[%
in a variable name is to be interpreted in such a way that a subscript variable like%i
is converted to its integer value, so that if%i = 21
then$array[%i]
and$array[21]
are the same var.PHP has a nice feature where if one declares
$varname = "foo"
, it is then possible to write$$varname
and get the same variable as$foo
. Perhaps a similar feature could be added to peptiditor, where a variable name like@coord%res_no
is legal provided%res_no
is set to a positive (or zero) value. Then for example if a loop is counting%i
from 1 to 7, then%TMR%i.s
and%TMR%i.e
would evaluate to the automagic TMR start/end variables, etc. With this kind of feature, it would be unnecessary to look for a square bracket - array syntax would just work, and the use of brackets, parentheses, or any other delimiter would be merely a coding convention.