There are a number of list functions which are very similar to the string functions (see 9.5.2 String functions). Remember that E-lists are the list equivalents of E-strings, i.e., they can be altered and extended safely without exceeding their bounds. As with E-strings, E-lists are downwardly compatible with lists. Therefore, if a function requires a list as a parameter you can supply a list or an E-list. But if a function requires an E-list you cannot use a list in its place.
LISTdeclaration does. The following code fragments are (as with
String) practically equivalent:
You need to check that the return value fromDEF lt:LIST DEF lt:PTR TO LONG lt:=List(46)
NILbefore you use it as an E-list. Like
String, the memory allocated using
Listis deallocated using
DisposeLink(see 11.3.5 System support functions).
StrCmpdoes for E-strings, so, for example, the following comparisons all return
ListCmp([1,2,3,4], [1,2,3,4]) ListCmp([1,2,3,4], [1,2,3,7], 3) ListCmp([1,2,3,4,5], [1,2,3], 3)
StrCopy, and the following example shows how to initialise an E-list:
As withDEF lt:LIST, x x:=4 ListCopy(lt, [1,2,3,x])
StrCopy, an E-list cannot be over-filled using
StrAdd, so this next code fragment results in the E-list
ltbecoming the E-list version of
DEF lt:LIST ListCopy(lt, [1,2,3,4]) ListAdd(lt, [5,6,7,8])
StrLen, returning the length of list. There is no E-list specific length function.
StrMax, returning the maximum length of the e-list.
SetStr, setting the length of e-list to length.
ltis an E-list (so a
PTR TO LONG) then
ListItem(lt,n)is the same as
lt[n]. This function is most useful when the list is not an E-list; for example, the following two code fragments are equivalent:
WriteF(ListItem(['Fred','Barney','Wilma','Betty'], name)) DEF lt:PTR TO LONG lt:=['Fred','Barney','Wilma','Betty'] WriteF(lt[name])
Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.