All about Text Blocks! Classified Berkian Information!

Welcome to another guide! This one I made because in all the guides about beginner coding, (and advanced), there hasn’t been a lot of talk about text blocks, and I’m not talking length of and the normal set texts, I’m talking about first occurrences and sub-strings. But, for the sake of the guide, I’ll include all the blocks. We can break this down into 2 different sections, the Beginner and Advanced. We’ll start with the beginning first.

Wiki editing rules

Please don’t make any of the edits violate the TOS or FAQ, remember, anyone can see who edits a wiki and what part they edit.
Please be responsible!
Everyone, please don’t edit when it is being edited.
Ask before editing and tell me what you’re going to add.
Add yourself to the credits if you edited it and added something.
Don’t make credits using @ since you can only do that 10 times in a post.


Table of Contents

  • Set Text
  • Create Text
  • Length Of
  • Convert Numbers To Text (With Commas)
  • Get Sub-string letter# to letter#
  • Get letter#
  • Find first occurrence
  • Variable Concatenation

Set Text
This is the most common block used, obviously, I won’t have to explain much because even beginner coders can catch up pretty quickly on this. You store strings
[1] in this block. Usually, without using the block itself, (i.e. the text that is offered by notifications and pop-ups), text appears a lot, but the times where the block is used, is probably used when you concatenate strings, or in actually form, use Template Literals, which I actually explained before. Text blocks can be a value for properties also! They can also be manipulated, as explained in the other text blocks.


Create Text
A still very common block, create Text can conjoin multiple pieces blocks to make a whole string. An interesting thing about this is numbers, now, if you’ve used blocks before, you know it’s possible to convert numbers to strings (with commas), and text can do that! However, there appears to be certain restrictions. When you try broadcasting using numbers, say, the property of something is set to a number, 1234, and you want to broadcast on a concatenated string 1234h, well, I tried this out and it didn’t work, meaning that when broadcasting, it can’t convert numbers to string automatically, the best way to do this might be using the converted text to numbers (using commas), but if it’s a normal concatenation, like:

set text: item 1: get property propertyName
          item 2: set text: "Whatever you wish!"

It works!


Length Of
Pretty self-explanatory, right? The “length of” block basically gives you the length of a string, and I did a test, it’s not 0-based, meaning it starts at index 1, I can’t fully remember which data types start at index 1, pretty sure though arrays and objects are 0-based .


Convert Numbers To Text (With Commas)
Now, this one is pretty simple, but small warning, remember the Create Text section?
Just to be sure, when I mean (using commas) I don’t mean putting a comma after every number, I mean adding the comma at every 3 digits. For example, 1234, use the converter and you get 1,234. So you would also need to be wary to add the commas when needed in your broadcasts. There are 2 obstacles when using this block. One, for example, if you’re storing a string in a variable via the convert text to numbers(with commas) block[2] and you want to use an if statement to check if the variable is equal to another string, you have to make sure to remember that commas are involved now. The second obstacle, although a bit… superfluous, is that you can only have up to 3 decimals when converting with this block. There is a bypass to this here.

That pretty much sums it all up.


Now we’re moving on to advanced! These blocks are not as used and have more specific uses


Get Sub-string ____ to ______
This part of it cuts out pieces of text from the string. For example.

string: "This is an example";
sub-string: letter6 to letter18

You would get “is an example”. Now, to let you know, the letter6, it includes the letter, and not the next one. To explain, the 6th letter is “I”, so it includes it, not go to the next letter, which is “s”.
But there are more options than just letter# !
For both input option[3] you can also use “letter # from end”. Letter# from end can be used in either input option. Letter # from end can be used if you’re looking at the text backwards. For example:

string: "This is another example"
sub-string: letter# from end 8 to letter# from end 1

This returns the string “example”. If you look at the text backwards, it would be “elpmaxe rehtona si sihT” so it looked for the 8th letter from this position which is “e” and then the 1st letter from this position which is [also] “e”. But, instead of returning the text backwards as well, it returns it in normal position. A good thing to note about this is that you can’t combine this with the letter# option. If you did, say, “Get substring from letter# 1 to letter# from end 5”, then nothing is returned since it’s not possible to return anything.
For just the first input option, the “first letter” option is great for saving a block or 2 and is very simple! If you’re ever going to start at the first letter of the string, instead of doing get letter# 1, you can use this. For the first letter option, there is no available space to input anything since it’s not taking in a number or variable.
For just the second input option, the “last letter” option is also great for saving a block or 2! It’s very simple as well and is just the inverse of the “first letter” option.


Get Letter#
For this, it works virtually the same as the letter# to letter# except for one thing, it instead gets you the letter index. For example, using our example above, lets pick letter2, well, we would get “h” if we wired this to a notification or pop-up. I’m not entirely sure why it wasn’t made to go all the way to the end of the string, but maybe it was so that you could get more specific letters to build together with. (reminds me of when your typing on your phone and some words appears that match what you’ve began typing for some reason). In this block, you have all the same input options (letter#, letter# from end, first letter, last letter) as the “get substring” block except there is one new option! It’s called the “random letter” option and instead of getting a specific letter from the string, you get a random letter. For example:

String: This is a new example
Block: Get random letter

And this would return any letter in the following array [t,h,i,s,a,n,e,w,x,m,p,l]. This can be SUPER helpful when creating randomizers because you can get rid of all those if statements that take up a ton of blocks and just use 2 blocks instead!


Find First Occurrence
And, now, the most important for last, and the reason I made this Guide, the occurrence block. Now, what this does is that it finds the occurrence, like the find button shortcut. Now, this isn’t all it does, and there’s a secret thing that people might not know about if you don’t experiment, it also tracks the number of occurrences, even before the thing is triggered. Now, I discovered this during my Battleship game, the goal for the occurrence was to identify if an updated property had the word “Enemy”. I triggered 3 “Enemy” buttons that updated the property, and then ran the trigger, getting a notification of ‘3’, the same amount of triggers I triggered with “Enemy” in it. What I assume is that the updated properties are stored somewhere and that the occurrence block goes through those updates, and while it does activate since the property already has “Enemy” in it, it also stores the total amount of times “Enemy” was stored. Just saying, I would suggest asking Blackhole to explain more about this part, since they literally are [4] the best coders in the forums, (that might be Clic-Clac though), they could help clear this part out. One of the main things you would use this for is as an input for get letter#/get substring blocks.

String: "This is a cool example!"
Block: In text string Get letter#,  In text string find first occurrence of text "!"

The block’s value would now be “!”.


Variable Concatenation
First of all, if you don’t know what concatenation is, I suggest viewing this guide!
After lots of exploration recently, I found out a few neat things about using variables to concatenate text and strings and some other stuff.
Starting out with the simplest, as listed above, you can store a string in one variable, and a number in another and concatenate them together!

Set var a to "String "
Set var z to 1
Set var con to var a + var z
Return con

In this example, I stored to variables with different data types(string and num) and then created a 3rd variable that stored the 2 variables added up. After that, I returned[5] the value of the variable “con”[catenate] in which I would get: String 1. This may not be important since there’s the “Create text with” block, but this can come in handy in some situations.


And that’s it! While the most important part was the occurrence part of it, I did want to explain all the text blocks, so that I could explain it to them. Hope this helps, signing off, Friends of Berk!

Lemme know if I missed anything, or have a suggestion on what to add!

Credits

Toothless
Unit_72
Kosm0-o

(Hopefully others soon!)

17 Likes

great Guide @Toothless !

3 Likes

Thanks!

3 Likes

You should add about the subtypes of letter# blocks like last letter, first letter, etc.
You should also talk about some concatenation and how you can connect the find first occurrence of text block into the get letter# blocks. Great guide though! This’ll be very useful to new block coders!!!

7 Likes

This is a good guide! It should be a wiki!

3 Likes

EVE IS SO KOOL[EVE IS SO KOOLqEVE IS SO KOOLuEVE IS SO KOOLoEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOL=EVE IS SO KOOL"EVE IS SO KOOLKEVE IS SO KOOLoEVE IS SO KOOLsEVE IS SO KOOLmEVE IS SO KOOL0EVE IS SO KOOL-EVE IS SO KOOLoEVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLpEVE IS SO KOOLoEVE IS SO KOOLsEVE IS SO KOOLtEVE IS SO KOOL:EVE IS SO KOOL4EVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLoEVE IS SO KOOLpEVE IS SO KOOLiEVE IS SO KOOLcEVE IS SO KOOL:EVE IS SO KOOL8EVE IS SO KOOL2EVE IS SO KOOL7EVE IS SO KOOL5EVE IS SO KOOL1EVE IS SO KOOL"EVE IS SO KOOL]EVE IS SO KOOL
EVE IS SO KOOLsEVE IS SO KOOLuEVE IS SO KOOLbEVE IS SO KOOLtEVE IS SO KOOLyEVE IS SO KOOLpEVE IS SO KOOLeEVE IS SO KOOLsEVE IS SO KOOL EVE IS SO KOOLoEVE IS SO KOOLfEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLeEVE IS SO KOOLtEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLrEVE IS SO KOOL#EVE IS SO KOOL EVE IS SO KOOLbEVE IS SO KOOLlEVE IS SO KOOLoEVE IS SO KOOLcEVE IS SO KOOLkEVE IS SO KOOLsEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLiEVE IS SO KOOLkEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLaEVE IS SO KOOLsEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLeEVE IS SO KOOLtEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLrEVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLfEVE IS SO KOOLiEVE IS SO KOOLrEVE IS SO KOOLsEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLeEVE IS SO KOOLtEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLrEVE IS SO KOOL,EVE IS SO KOOL
EVE IS SO KOOL[EVE IS SO KOOL/EVE IS SO KOOLqEVE IS SO KOOLuEVE IS SO KOOLoEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOL]EVE IS SO KOOL
EVE IS SO KOOL
EVE IS SO KOOLDEVE IS SO KOOLiEVE IS SO KOOLdEVE IS SO KOOLnEVE IS SO KOOL’EVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLIEVE IS SO KOOL EVE IS SO KOOLeEVE IS SO KOOLxEVE IS SO KOOLpEVE IS SO KOOLlEVE IS SO KOOLaEVE IS SO KOOLiEVE IS SO KOOLnEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLhEVE IS SO KOOLaEVE IS SO KOOLtEVE IS SO KOOL?EVE IS SO KOOL

2 Likes

EVE IS SO KOOL[EVE IS SO KOOLqEVE IS SO KOOLuEVE IS SO KOOLoEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOL=EVE IS SO KOOL"EVE IS SO KOOLKEVE IS SO KOOLoEVE IS SO KOOLsEVE IS SO KOOLmEVE IS SO KOOL0EVE IS SO KOOL-EVE IS SO KOOLoEVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLpEVE IS SO KOOLoEVE IS SO KOOLsEVE IS SO KOOLtEVE IS SO KOOL:EVE IS SO KOOL4EVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLoEVE IS SO KOOLpEVE IS SO KOOLiEVE IS SO KOOLcEVE IS SO KOOL:EVE IS SO KOOL8EVE IS SO KOOL2EVE IS SO KOOL7EVE IS SO KOOL5EVE IS SO KOOL1EVE IS SO KOOL"EVE IS SO KOOL]EVE IS SO KOOL
EVE IS SO KOOLcEVE IS SO KOOLoEVE IS SO KOOLnEVE IS SO KOOLcEVE IS SO KOOLaEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLnEVE IS SO KOOLaEVE IS SO KOOLtEVE IS SO KOOLiEVE IS SO KOOLoEVE IS SO KOOLnEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOLdEVE IS SO KOOL EVE IS SO KOOLhEVE IS SO KOOLoEVE IS SO KOOLwEVE IS SO KOOL EVE IS SO KOOLyEVE IS SO KOOLoEVE IS SO KOOLuEVE IS SO KOOL EVE IS SO KOOLcEVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOL EVE IS SO KOOLcEVE IS SO KOOLoEVE IS SO KOOLnEVE IS SO KOOLnEVE IS SO KOOLeEVE IS SO KOOLcEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLhEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLfEVE IS SO KOOLiEVE IS SO KOOLnEVE IS SO KOOLdEVE IS SO KOOL EVE IS SO KOOLfEVE IS SO KOOLiEVE IS SO KOOLrEVE IS SO KOOLsEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLoEVE IS SO KOOLcEVE IS SO KOOLcEVE IS SO KOOLuEVE IS SO KOOLrEVE IS SO KOOLrEVE IS SO KOOLeEVE IS SO KOOLnEVE IS SO KOOLcEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLoEVE IS SO KOOLfEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLxEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLbEVE IS SO KOOLlEVE IS SO KOOLoEVE IS SO KOOLcEVE IS SO KOOLkEVE IS SO KOOL EVE IS SO KOOLiEVE IS SO KOOLnEVE IS SO KOOLtEVE IS SO KOOLoEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLhEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLgEVE IS SO KOOLeEVE IS SO KOOLtEVE IS SO KOOL EVE IS SO KOOLlEVE IS SO KOOLeEVE IS SO KOOLtEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOLrEVE IS SO KOOL#EVE IS SO KOOL EVE IS SO KOOLbEVE IS SO KOOLlEVE IS SO KOOLoEVE IS SO KOOLcEVE IS SO KOOLkEVE IS SO KOOLsEVE IS SO KOOL.EVE IS SO KOOL
EVE IS SO KOOL[EVE IS SO KOOL/EVE IS SO KOOLqEVE IS SO KOOLuEVE IS SO KOOLoEVE IS SO KOOLtEVE IS SO KOOLeEVE IS SO KOOL]EVE IS SO KOOL
EVE IS SO KOOL
EVE IS SO KOOLIEVE IS SO KOOLfEVE IS SO KOOL EVE IS SO KOOLyEVE IS SO KOOLoEVE IS SO KOOLuEVE IS SO KOOL EVE IS SO KOOLwEVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOLtEVE IS SO KOOL,EVE IS SO KOOL EVE IS SO KOOLIEVE IS SO KOOL EVE IS SO KOOLcEVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOL EVE IS SO KOOLmEVE IS SO KOOLaEVE IS SO KOOLkEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLhEVE IS SO KOOLiEVE IS SO KOOLsEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOL EVE IS SO KOOLwEVE IS SO KOOLiEVE IS SO KOOLkEVE IS SO KOOLiEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOLdEVE IS SO KOOL EVE IS SO KOOLyEVE IS SO KOOLoEVE IS SO KOOLuEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOLdEVE IS SO KOOLdEVE IS SO KOOL EVE IS SO KOOLtEVE IS SO KOOLhEVE IS SO KOOLaEVE IS SO KOOLtEVE IS SO KOOL!EVE IS SO KOOL
EVE IS SO KOOL
EVE IS SO KOOLMEVE IS SO KOOLaEVE IS SO KOOLkEVE IS SO KOOLeEVE IS SO KOOL EVE IS SO KOOLmEVE IS SO KOOLeEVE IS SO KOOLaEVE IS SO KOOLnEVE IS SO KOOLsEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOLsEVE IS SO KOOLkEVE IS SO KOOLiEVE IS SO KOOLnEVE IS SO KOOLgEVE IS SO KOOL EVE IS SO KOOLaEVE IS SO KOOL EVE IS SO KOOLrEVE IS SO KOOLeEVE IS SO KOOLgEVE IS SO KOOLuEVE IS SO KOOLlEVE IS SO KOOLaEVE IS SO KOOLrEVE IS SO KOOL.EVE IS SO KOOL EVE IS SO KOOL:EVE IS SO KOOLsEVE IS SO KOOLwEVE IS SO KOOLeEVE IS SO KOOLaEVE IS SO KOOLtEVE IS SO KOOL_EVE IS SO KOOLsEVE IS SO KOOLmEVE IS SO KOOLiEVE IS SO KOOLlEVE IS SO KOOLeEVE IS SO KOOL:EVE IS SO KOOL

7 Likes

Not from what I read…

6 Likes

Anytime but a wiki is a good idea and me love blocks.

1 Like

Ok! :+1:

4 Likes

…mini guide?
what?

this is a great guide, but a long guide, 'cause how does someone explain all this info so fast? maybe remove the mini guide part?

anyway, nice guide.

5 Likes

Awesome explanation and great overall structure, you’ve made complex concepts so accessible!
I will suggest to insert some pictures as well.
yoyleberries

8 Likes

ya it’s long not mini

2 Likes

Oh, if that’s the case, you can add that! :smile:

4 Likes

Removed the mini guide part of it!

2 Likes

@Blackhole927 could you make this a wiki for toothless?

3 Likes

Hopefully, @Blackhole927 will reply soon, because I already added the wiki stuff.

3 Likes

Should we add about limits of some of the blocks and getting past them? Although the getting past the limits is not utilizing more than text blocks.

3 Likes

Well, I wanted this guide to explain what the text blocks do, but I guess it seems okay if people mention about how to get pass them, it could become a “Everything you need to know about text blocks” kind of guide instead, which it already is sorta! If you add what you suggested, it’ll work I think!

5 Likes

I want a wiiki so bad!!! =b

4 Likes