Netscript Arrays

Netscript arrays have the same properties and functions as JavaScript arrays. In other words, any function that can be called on a JavaScript array can also be called on a Netscript one.

See the documentation for JavaScript Arrays here

Code Examples
For this example we will be creating a simple copy program.

Arrays like this one can be defined with multiple names files = ['hack.script','copyhack.script','random.script']; Using this array we can make a simple function to copy these scripts to another server. This will start with the the first script 'hack.script' and go through the array elements.

toServer = 'test'; //put server to send files to x = (toServer + 'has recieved all the files'); y = (ls(toServer) + 'double check they were added'); files = ['hack.script','copyhack.script','random.script']; for(i = 0; i < files.length; ++i) { scp(files[i], toServer); } tprint(x); tprint(y); with a little bit more specification we can make this alot easier by adding and defining variables. The script will immediately end and show the results a few seconds after it runs.

BEWARE THE scp COMMAND CAN AND WILL AUTOMATICALLY OVERWRITE CODE THAT HAS THE SAME NAME.