# Scripts

#### Insert Specified Value into Selected Cells

```javascript
var Numbers = Application ("Numbers");
Numbers.includeStandardAdditions = true;

// get the selected cells
var tables = Numbers.documents[0].activeSheet.tables;
var ranges = tables.selectionRange.name();
for(var tableNum in ranges) {
var thisRange = ranges [tableNum];
if (thisRange != null) break;
}
var range = tables[tableNum].ranges[thisRange];
var cells = range.cells;

// set all cells to the date
for(var i=0;i<cells.length;i++) {
cells [i].value = "smol compute";
}
tables [tableNum].selectionRange = range;
```

Replace "smol compute" with the desired values.&#x20;

```javascript
// get the two tables involved
var Numbers = Application("Numbers");
var database = Numbers. documents [0].sheets [0].tables ['Database'];
var form = Numbers. documents [0].sheets [1].tables ['Data Entry'];

// get all of the values from the form
var values = [];
for(var i=0;i<form. rows. length;i++) {
var value = form. rows [i]. cells [0].value();
values.push (value);
}

//create a new row at the bottom of the database
var newRow = database.cells ['A'+database. rows.length].addRowBelow();

// put the values into that row
for(var i=0;i<values.length;i++) {
newRow.cells[i].value = values[i];
}

// clear out the form, going backwards so to end on the first cell
for(var i=form.rows.length-1;i>=0;i--) {
form.rows[i].cells[0].value = "";
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guides.smolcompute.xyz/1/how-to/scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
