# How to smartest save random made strings in different cells in a column in the spreadsheet ?

M.E shared this question 2 years ago

I've got GeoGebra to create a random sting every time I click on a button and I want GeoGebra to save every string in different cells in a column in the spreadsheet.

For example I would like the first generated string saved in the cell B2, the next in B3 and so on.

How can I do that smartest when the number of the generated string is n and the string is always made in the same variable (for example f) ? Execute({"B"+(n+1)+"="+f+""})

Execute use a list with string-elements. {"","", ....""} and execute each string similar as he is written in the input-box.

Each string-element can be composed with constants and variables.

Example (when n is ==2): "B"+(n+1)+"=" --> "B3="

in the string is inserted the value of f (and not the name).

If this value (f) is a string then the character " must be insert also (at begin and end of the string).

this charcter must be insert as UnicodeToLetter(34)

Example: {"B"+(n+1)+"="+(UnicodeToLetter(34)+f+UnicodeToLetter(34))+""}

--> B3="abcde" (when n == 2 and f is a string and has the value "abcde") 1

Execute({"B"+(n+1)+"="+f+""})

Execute use a list with string-elements. {"","", ....""} and execute each string similar as he is written in the input-box.

Each string-element can be composed with constants and variables.

Example (when n is ==2): "B"+(n+1)+"=" --> "B3="

in the string is inserted the value of f (and not the name).

If this value (f) is a string then the character " must be insert also (at begin and end of the string).

this charcter must be insert as UnicodeToLetter(34)

Example: {"B"+(n+1)+"="+(UnicodeToLetter(34)+f+UnicodeToLetter(34))+""}

--> B3="abcde" (when n == 2 and f is a string and has the value "abcde") 1

Thank you very much ! :) 1

Moved below 1

Moved below  1

If f is a function, and I would like to have it written in the spreadsheet as f(x) = ...

How can I do that ? 1

I've made a new string object:

Prescription = "f(x) = " f

Then I used the script:

Execute({"B" + (n+1) + "=" + (UnicodeToLetter(34) + Prescription + UnicodeToLetter(34)) + ""}  1

The content of the cells also seems locked/writing-protected so that the content can't be overwritten.

How can I change that ? 1

Now it's no problem.  1

When the string is added to the spreadsheet, the string is viewed in the drawing window.

How can I use a script to make the string invisible in the drawing window once it is added to the spreadsheet ? 1

see script in button 1

Thank you very much ! :)

It was something like this I needed to hide the string afterwards:

Execute[ { "SetConditionToShowObject[ B" + (n + 1) + ", false ]" } ]

I didn't know how to combine the letter an the integer without using quotation marks around both.  1

Which script can I use afterwards to clear all the used cells in a column except the first cell (for example B1) ? 1

see script in button2 1

Thanks.

I don't know if it is you who have deleted my other post about this. But if so, I would recommend you to recover it. Because I would also insert your answer there so if there should be others in the future that would search for the same topic, it is easier for them to find it and then no one else has to use their time for answering it again. 1

Your other post was equal to this one. User rami only inserted a link to this topic, asking to avoid double posts.

This is why your other post has been moderated and deleted. 1

Yes, I know and fully understand the reason.

But it will be difficult for others to find the answer as the topic of this post is very different.

So it would have been better just to delete my post here and answer the other topic.

I'll therefore recommend that you recover the other topic and you are welcome to delete these last post if you doesn't want them here. Although, as they also relate to the post above, it could be smart to let them be there. 