lastAssignmentToVariable#
- csoundengine.csoundlib.lastAssignmentToVariable(varname, lines)[source]#
Line of the last assignment to a variable
Given a piece of code (normally the body of an instrument) find the line in which the given variable has its last assignment
- Parameters:
varname (
str
) – the name of the variablelines (
list
[str
]) – the lines which make the instrument body. We need to split the body into lines within the function itself and since the user might need to split the code anyway afterwards, we already ask for the lines instead.
- Return type:
int
|None
- Returns:
the line number of the last assignment, or None if there is no assignment to the given variable
Possible matches:
aout oscili 0.1, 1000 aout, aout2 pan2 ... aout = ... aout=... aout += ... aout2, aout = ...
Example
>>> lastAssignmentToVariable("aout", r''' ... aout oscili:a(0.1, 1000) ... aout *= linen:a(...) ... aout = aout + 10 ... outch 1, aout ... '''.splitlines()) 3