# Creating a function usable across screens

**URL:** https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645
**Category:** Teachers' Lounge
**Tags:** function
**Created:** [March 3, 2022, 3:37pm UTC](https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645 "2022-03-03T15:37:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mperreaultajdcm](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mperreaultajdcm](https://community.thunkable.com/u/mperreaultajdcm)
#### Post date: [March 3, 2022, 3:37pm UTC](https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645/1 "2022-03-03T15:37:28Z")

</div>

I’m teaching my students how to create user creation and login screens from scratch. I want them to learn about Salting and Hashing passwords.

I’d like user creation to be on it’s own screen, and login to be its own screen.

I’d like to write a salt, pepper and hashing function for storing and checking passwords. However, I’m not seeing how to re-use functions across multiple screeens, and it seems clumsy to rewrite the function on each screen.

I’m new to thunkable but excited about how it can be used to quickly teach programming and rapid prototyping in school.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 3, 2022, 8:47pm UTC](https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645/2 "2022-03-03T20:47:27Z")

</div>

It’s a great tool and one I use in my teaching but Thunkable does not have global functions. It should. So for now you’ll need to copy code to do that. You can copy and paste blocks from one screen to another within the same project.

Please consider posting a comment on the feature request here:

> <https://github.com/thunkable/thunkable-issues/issues/703>
>
> \*\*Is your feature request related to a problem? Please describe.\*\*
> The problem …I have is that I must maintain mulitple copies of helper functions witihin project and across projects. Examples are functions to determine the type of data in a JSON object (list, string, number, object) or to determine if a variables contains a numeric value (to keep the map object from crashing from receiving a string for latitude or longitude).
> 
> As I improve these helper functions (ie change them) I must change them in EVERY screen and EVERY project. This is both time consuming and error prone.
> 
> \*\*Describe the solution you'd like\*\*
> I would like to see a section in the BLOCK screen where Global functions (either across screens, or better yet, across projects). This would work just like the current list for functions, but it would contain a list of functions which share a single definition.
> !\[image\](https://user-images.githubusercontent.com/66176281/95867263-d09b8d80-0d1d-11eb-8234-128507b54a04.png)
> 
> Where would the functions be edited? I would envision either 1) as separate dummy screen to hold the definitions (for project scoped functions) or 2) a container Project (For inter project scope
> 
> \*\*Describe alternatives you've considered\*\*
> Currently, I create projects to to hold my library of functions. When I need them in a project, I save the screen to My Screens then create a new screen based on the template. Then I copy the function into each screen that needs it. Oh, so much cut-and-paste...
> 
> \*\*Which platform are you asking for?\*\*
> Thunkable ✕ (x.thunkable.com)
> 
> \*\*Additional context\*\*
> To turn Thunkable into the fantastic commerical project (vs. educational toy) that it can be, "code" reuse is a critical feature. This would make my Thunking much more efficient.

The more Thunkable hears from users like us who desire that feature, the more likely it is to get implemented.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 3, 2022, 9:56pm UTC](https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645/3 "2022-03-03T21:56:39Z")

</div>

It is unfortunate that Thunkable does not have the concept of **Global Functions** but in the other hand, it allows for function names to be the same in every screen.

What I do is use one of the screens that I only add functions to it. Then whenever I need a function in another screen I copy the function from the `Functions Screen` and paste it to the intended one. It will maintain the same name.

Not ideal but it works for now.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:13pm UTC](https://community.thunkable.com/t/creating-a-function-usable-across-screens/1765645/4 "2024-11-08T13:13:24Z")

</div>


