Difference between revisions of "List"

From Second Life Wiki
Jump to navigation Jump to search
(reverted to some of the info in the old wiki entry)
(redirect list to category LSL List)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{LSL Header}}
#REDIRECT [[:Category:LSL_List]]
[[Category: LSL Types]]
[[Category: LSL Types]]
[[Category: LSL List]]
Instead of arrays, LSL uses lists. The list {{LSLG|type}} is exactly what it sounds like: a heterogeneous list of the other data types. Lists are created via {{LSLG|csv|comma-separated values (CSV)}} of the other data types. enclosed by square brackets: "[" and "]". See below for examples of the {{LSLG|syntax}}.
Lists not only store the {{LSLG|value}} of the list item, but also its type (see {{LSLG|llGetListEntryType}} and {{LSLG|llCSV2List}}). To directly enter a {{LSLG|float}} {{LSLG|value}} into a list, a decimal point (.) must be used.
Because they store multiple value types, lists are not accessed with square brackets like arrays are. They are read by accessor {{LSLG|functions}} that specify the type of value attempting to be retrieved (e.g. {{LSLG|llList2Integer}}) and written with accessor functions that insert or replace values (or ranges of values) based on new list {{LSLG|variables}} (e.g. {{LSLG|llListReplaceList}}).
Note: while the {{LSLG|LSL}} {{LSLG|compiler}} will only accept {{LSLG|code}} with a maximum of 72 items in a list, lists can actually support as many items as a {{LSLG|script}}'s {{LSLG|memory}} will allow. If a list of more than 72 predefined items is needed, just {{LSLG|concatenate}} (combine) two predefined lists into a new one: longlist = firstpart + secondpart;
Lists cannot contain other lists, so using them like a multidimensional array is not possible natively (although several ways around this are available). Also, {{LSLG|stride|strided}} lists can be used.
Examples:
<pre>//a list with a string, integer, float, vector and rotation
list l = ["somestring",12,3.0,<3.3,4,0>,<0,0,0,1>];</pre>

Latest revision as of 19:53, 22 February 2007

Redirect to: