Copy_Range_Cells
Last Update: 11/5/2015
LabTalk supports more than one method of programmatically copying data from one block to another (e.g. the copydata X-Function). In terms of speed and flexibility, one of the best involves use of the range -v option switch. Using the -v switch, you can define a single block as a range and assign values to another range defined using -v. Blocks need not have the same "shape" as long as the number of elements is the same (note that the target block must exist before assignment is made).
// Import sample data into a new book fname$=system.path.program$ + "\Samples\Statistics\abrasion_raw.dat"; newbook; impasc; // Define a block as column A & B, all rows range -v ra1 = 1[1]:2[end]; // Create a new sheet newsheet; // Define a block as one column, using the ra1 block size range -v ra2 = 1[1:ra1.GetSize()]; // Assign the values in the first block to the second block ra2 = ra1; col(1)[L]$ = Combined;
Another advantage of range -v is that you can perform math operations on data while copying to a new block of cells.
range -v rs=[Book2]1!1:3; range -v rt=[Book1]1!1:3; rt=rs*10 //multiply elements in rs by 10 and output to rt
Keywords:copy, copydata, range, Set Values, math
Minimum Origin Version Required: 9.1SR0