Character function like CHR (ascii_code_number)

No need to apologise! All good…

Thank you.

You just call it from your app via the API connector.

https://wt-nigel_godfrey-gmail_com-0.run.webtask.io/ascii2string?ascii=65

1 Like

I lookup for API connector but nothing related Bubble … Can you show me an example, how to register to Bubble an API created with Webtask and how to use it in Bubble ?

It is a plugin. Look on the menu on the left. Seach for “API Connector” and install it.

Then set up something that looks like …

And “Initialise call”.

1 Like

Thank so much. Let me try now.

I tried several times but I got only this message: “Invalide webtask code”.
I have this function: CHR(code) in file CHR.js
This function I have tested on NodeJS and it work well.
The url is: https://wt-cb4dba3213c5cb2ad86a8b940fd4f0a5-0.run.webtask.io/CHR
I don’t know, where is the error.

Looking at the message, the code you have running in the webtask cannot be valid, has a typo or error, or is missing something.

You can only see this code.

“Supplied code must return or export a function.”

My function is only for learning and it is very simple:

module.exports = {
CHR : function(code) {
return String.fromCharCode(code);
}
};

I change the function to:

module.exports = function(context, cb) {
cb(null, String.fromCharCode(context.query.code))
}

It’s OK then. In the Bubble Editor for a Text element, if I choose “Get data from external API” then I can see “Char - Code” in dropdown menu. When I choose this, I think I can assign a code for this function, but I got only “Char - Code’ 0”. I don’t know why.

I just edit my function as you advised and I have approved the API Connector.
But I can’t use this function in the Bubble Editor yet. Show me what to do next, please.

1 Like

Thank you so much !

Thank to instructions of NigelG, now I can build a simple function and then use it in the Bubble Editor.
As I have tested: 2 javascript functions String.fromCharCode(code) and Char_16bits.charCodeAt(0) now work well with code in range 1 - 65355. For my opinion, it is enough for our needs now.
I know that’s a walk around only and this solution take much more time than built-in functions.
I hope that you will soon implement these functions: CHR(charcode) and CODE(char_16bits) so we can use them directly in Bubble Editor.
For the number data we will have for example :converted to UTF16 character and for string data we will have 's UTF16 code
These functions are necessary for me now and I think they will be useful for every developer. Thank you for excelent Bubble Editor, the future of web programing !

I would like to thank you once more for your instructions. I hope I will learn from you more knowledges about Bubble Editor and visual progaming.
As I see, API connector take more time than I expected. Is there another faster solution to implement my character functions above for Bubble applications?

Yes, as I said above, if what you are trying to do is have the entire “history” of a thread of messages that relate to each other stored on a single record, then this method of doing the relational data as a list of characters is very clever but I think it overcomplicates the problem in the “object” world of bubble data.

I see where you are coming from. If you just have a parent > child hierarchy, it is going to be a pain to get all the related messages, so you need to get the parent, and then the next, and then the next etc.

But bubble will allow you store ALL the related messages in a list field.

So we have our data type Message. And then we can define a field MessageHistory and give it a type of Message.

Each time we create a child message, instead of updating this complex composite key each time, we do the SAME thing in the “MessageHistory”. We take the contents of this field from the Parent (which contains all ITS ancestors) and add on the parent.

1 Like

Thank you for your advise. With this solution we need much more space to store mutlilevel duplicates of IDs list. I don’t know, why my solution overcomplicates the problem in the “object” world of Bubble data. If Bubble Editor has these character functions built-in, everything I need with relational data will be very simple. But meantime I think I will use the list field as you advised, because the API connector is very slow.
Do you think that Emmanuel will implement that character functions as built-in functions for the next Version of Bubble Editor? Have they planned when the next Version will be?

Then I’ll leave you to it then.

The @Bubble team are constantly improving and adding features to the platform. Keep your eyes open to the Announcements section for the main feature releases, or to the https://bubble.io/release_notes page.

Thank you. I am a newbie, you know …