def __getitem__(self,i): result = mkvar() code = ''' &s %s [extract %s %s] ''' % (result,str(i),self) self.writecode(code) return '[value %s]' % result
def __getslice__(self,i=1,j=0): result = mkvar() code = ''' /* /* Extracting a slice from a list /* ''' self.writecode(code) if i != 1: code = '&s i %d\n' % i self.writecode(code) else: code = '&s i 1\n' self.writecode(code) if j != 0: code = '&s j %d\n' % j self.writecode(code) else: code = '&s j\n' self.writecode(code) # Generate code to extract a sublist. The sublist is stored in result code = AML.getslice(self.list,result) self.writecode(code) return List('[value %s]'% result,self.file)
def length(self): result = mkvar() code = ''' &s %s [token %s -count] ''' % (result,self) self.writecode(code) return '[value %s]' % result
def find(self,item): result = mkvar() code = ''' &s %s [token %s -find %s] ''' % (result,self,item) self.writecode(code) return '[ value %s]' % result
def __init__(self,list,file): self.name = mkvar() self.list = list self.file = file self.code = '' code = ''' &s %s %s ''' % (self.name,self.list) self.writecode(code)
def compareto(self,validlist): # Compare a this list against another known correct list. # If an unknown value is found return false, else true result = mkvar() code = ''' &s %s .TRUE. &do i &list %s &s found [calc [token %s -find %%i%%] > 0] &if ^ %%found%% &then &do &s %s .FALSE. &end &end ''' % (result,self,validlist,result) self.writecode(code) return '[value %s]' % result
def count(self): num = mkvar() code = ''' &s %s = [show definedlayer %s count] ''' % (num,self.name) self.writecode(code) return num
def isequal(self,other): result = mkvar() code = AML.isequal(self.list,other.list,result) self.writecode(code) return '[value %s]' % result