3.2 Edit the script at will

 

When editing and debugging the script, it is very likely to use the copy and paste functions, which will overwrite the content in the clipboard. Consequently, the returned content will be the last copied code rather than the source data in Excel while executing the clipboard() the next time. In this case, the calculation will fail, and you have to go back to Excel to re-copy the data, which will give you some trouble.

To solve this problem, SPL provides the clipboard@e() function, where the option @e means that it will always return the data copied from Excel for the first time to the clipboard. Let’s have a try:

In the example in the previous section, suppose that we have copied the data from Excel and written the script. At this point, if we edit the script, and cut A3 and A4 and paste them into B2 and B3, A2 will report an error when the script is executed again, because the clipbaord()in A1 gets wrong data. To avoid this problem, we need to modify the code, and use the just mentioned clipboard@e() in A1. By doing so, the script will still be executed normally after moving the code. The edited code is as follows:

A B C
1 =clipboard@e().import@t()
2 =A1.top(-3;math).(name) =A1.top(-3;english).(name) =A1.top(-3;physics).(name)
3 =join@p(A2;B2;B3).export()
4 =clipboard(A3)

A1: Read data from clipboard
A3: Join the names of these students to form a two-dimensional table and convert it to a string
A4: Write the string to clipboard