Forum Academy Marketplace Showcase Pricing Features

Character function like CHR (ascii_code_number)

I need a function to get a character from ASCII table LIKE this:

letter = CHAR (ascii_code_number)

For example with code number 65, the function must return character “A”.
How can i do it? Thank a lot,

It would be tedious, but could you build a database thing where one field is the ASCII number and another field is the letter? Then you could just search for one to get the other.

1 Like

What is the use case here?

This function will be usefull for several interesting features. As a very simple example:

  • In the contact list every contact will have a Character Code. For example 1 Contact will have code as “B”.
  • His wife (Her husband) will have Character Code: “BA”. His (Her) children will have character codes: “BC”, “BD” …
  • We can use this to determine relation bettween Persons in Family, in the Office … and many other very important cases.
  • Other case can be: parent-child relation of multilevel messaging replies. Character code of one Reply will be created as the Code of the parent message adding a letter more. So with just one Select command we can get whole story with all messages related to just one message from the database. We can also list all replies of a specific message with only one Select command. In this case we need unicode characters (64 bits) for the Code, because the number of messages will be very big.

I hope this function will be able to use very soon in some way. Thank so much in advance.

Thank you for your advise. But a function will be better. Your solution will cause many tasks with the Server and the application will work very slowly.

Webtask.io - it is a built in Node.js function.

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

You can use the Webtask editior to create and run the API, you no longer need to load Node on your machine (I just did this on a Chromebook).

It does seem a little odd creating a external serverless node function when Bubble itself runs on Node !

1 Like

@ NigelG
Thank you for your advise. I am but a newbie on NodeJS. Could you please show me an example on Bubble, how can I use this function directly?
I also hope that Emmanuel will show us the way to use this function as a bult-in function of Bubble. It will be great!

Why can’t you assign a character code to a contact using a random string? In your example (“Contact will have code as “B”.”), I don’t see where the char -> number happens (or the other way around).

Char -> number happens here:

  • In the first level of a multilevel chat: first message will have character code “A”, the second => “B” …
  • In the second level, replies of the first message (with code “A”) will have codes: “AA”, “AB”, “AC”, … corresponding to order numbers 1, 2, 3 …
    Replies of the second message (with code “B”) will have codes: “BA”, “BB”, “BC”, “BD”, … corresponding to order numbers 1, 2, 3, 4 …
  • One message with the code “BZHTAC” is the reply to this message with the code “BZHTA”
  • With this rule: with just one SELECT command we can get all the messages from the first level to current message “BZHTAC”: “B”, “BZ”, “BZH”, “BZHT”, “BZHTA”.
    Replies to this current message “BZHTAC” will have codes with 7 characters: with “BZHTAC” adding one letter more (starting with “A” for oder number 1 …)

So the CHR() function will be very important for me and I think it will be useful even for other developers.
I think you can do this for number data, similarly as “:formated as …” for example “:converted to character”
I hope you will help me soon. Thank so much.

Why do you need this ? Is this something you have created ? Or is it from another application ?

How does being about to convert ASCII 65 into A help here ?

I think, I said clearly above:

  • With this function I can assign character code for every message with the rule that a reply to message X will have exactly the CHARACTER CODE of message X, adding just ONE MORE character.
  • The first reply adding “A”, the second adding “B” … and we can have how much replies we want if we use 64 bits character.
  • For the reply with order number N, we will add CHR(64+N) character to CHARACTER CODE of message X.
  • Now with ONLY one SELECT command (Search for messages for Data source of the Repeating group), for specific message Y at level M, we can retrieve just related messages from level M until level 1, every level just one message. And it is a whole story related to this message Y.

By the way, if you have better solution for this issue I hope you will instruct me. Thank you in advance.

Thank you so much.
I have used Webtask.io to create an API: Char with 2 functions CHR(Code) & ASC(Char).
I have test with NodeJS: It worked perfect.
I have created also my Bubble plugin “Char” but I don’t know how to install to my app.
Could you help me, please !

I get the feeling that the design is a bad idea. What happens the first day you run out of relationship characters for a given slot?

You would be better to simply stick to a more traditional unique identifier, and stick to proper relational referencing between the entities.

Thank for your response.
My opinion is: with 64 bits character, you can’t run out.
With traditional unique indentifier ? Can you display just only related messages (every level 1 message) as a whole story ?

You could put all the previous messages into a list. That is easy, when you create the child you set the list to parent list :plusitem parent.

ASCII isn’t 64 bit though.

You could run out, basic ascii is 128 options, of which the first 32 are non-printable characters. if you are talking about doing something like NAD for 3 layers deep, with only 128 options per tier, then depending on what you are doing you ‘could’ run out of options.
http://www.asciitable.com/

I think, you need to read this : http://stackoverflow.com/questions/463786/what-is-an-easy-way-to-call-asc-and-chr-in-javascript-for-unicode-values.

I will consider more about your opinion.
Anyway, I also need to learn, how can I create Bubble plugin base on API functions from Webtask.io and how can I use the API plugin in my app. Could you help me?

I technically don’t need to read anything, but since you asked…

What the link you posted talks about is UniCode, what you asked about in your first post was ASCII these are two completely different things.

"I need a function to get a character from ASCII table LIKE this:

letter = CHAR (ascii_code_number)"

Not once did you mention using the UniCode character set through your posts above, only Ascii.

I am sorry, my english isn’t very good. I want to affirm that I allways respect you.

1 Like