# How to run code inside a sketch?

**URL:** <https://discourse.processing.org/t/how-to-run-code-inside-a-sketch/44471>\
**Category:** Coding Questions\
**Created:** [May 22, 2024, 9:33am UTC](https://discourse.processing.org/t/how-to-run-code-inside-a-sketch/44471 "2024-05-22T09:33:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiapps](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/aiapps/32/21731_2.png) [@aiapps](https://discourse.processing.org/u/aiapps)\
**Post date:** [May 22, 2024, 9:33am UTC](https://discourse.processing.org/t/how-to-run-code-inside-a-sketch/44471/1 "2024-05-22T09:33:31Z")

</div>

Let’s say I have a variable of type String and it contains code, how can I run it inside a working sketch and get the output result?

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [May 22, 2024, 11:40am UTC](https://discourse.processing.org/t/how-to-run-code-inside-a-sketch/44471/2 "2024-05-22T11:40:21Z")

</div>

Hi, welcome to the forum!

Do you want to share an example of what you are trying to do? There are definitely a way to run a string as a code (for example [here](https://stackoverflow.com/questions/4389232/run-piece-of-code-contained-in-a-string)) but if you can share examples, we may be able to suggest a more efficient way to solve it.
