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

M.E shared this question 2 years ago
Answered

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) ?

Best Answer
photo

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")

Comments (16)

photo
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")

photo
1

Thank you very much ! :)

photo
1

Moved below

photo
1

Moved below

photo
photo
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 ?

photo
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)) + ""}

photo
photo
1

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

How can I change that ?

photo
1

Now it's no problem.

photo
photo
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 ?

photo
1

see script in button

photo
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.

photo
photo
1

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

photo
1

see script in button2

photo
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.

photo
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.

photo
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.

photo
© 2020 International GeoGebra Institute