is it possible to convert a text to a list using APP Inventor ?

1,085 views
Skip to first unread message

Sebastian Rueda

unread,
Jul 12, 2017, 4:42:28 PM7/12/17
to MIT App Inventor Forum
Hi to everyone.

I'm sending sharing serial information between my Android device and a micro-controlled device. In my protocol i use frames to send and receive this information. At this point i want to use a text box and a Button to complete the frames: 

I mean, the user writtes in the text box, when the button is pressed, this data is converted to a list, the checksum is computed for all the frame, the checksum is added to the list (frame) and through the use of "BluetoothClient1 - Send bytes" the list is sent.

i have been having several difficulties because i don´t know how to convert the string on the text box to a list of the decimal representation for each of the letters (it must be on decimar representation because that is the way my XOR function works) 

To clarify a little more. Lets say that the user wrote "TAG1" on the text box i want a list from that with the individial decimal representation:
List [1 ]= 84
List [2 ]= 65
List [3 ]= 71
List [4 ]= 1
The attached picture shows the same but with colors :P

Thanks in advance to everybody

Sebastián 
convert.PNG

SteveJG

unread,
Jul 12, 2017, 9:14:32 PM7/12/17
to MIT App Inventor Forum
You want to do  convert the ascii character represented as Dec.  

App Inventor does not have a function to do that.  A simple way to convert would be to use two Lists as a conversion lookup table and then use the pairs block.to convert each character to dec.
 Here is a similar discussion in the forum.  https://groups.google.com/forum/#!topic/mitappinventortest/mQ5wxI1pF3Y   however the images in it are stale.

char       Dec
LIst1      List2
A           65
B           66
C           67
D           68
..
Z           90
0           48
1           49
2           50
..
9         57
  

Another way would be to use a Procedure like this perhaps




where the join blocks look like this  


0,1,2,3,4,5,6,7,8,9,
:,;,<,=,>,?,@,
A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z                The characterList is a List created from a simple csv text file (this is the join block)

You can convert the other way if you make the companion Procedure    DecToChar .

I am not sure where you go from here;  Is TAG1 supposed to be  8465711 ?   If so more work will be required to get this in the form you require.  You would probably 'read' each character separately using the red Text blocks, convert the character to a Dec value and save it to a checksum string ( the numerical string 8465711) and add that to a list of check sums that you want to save and perhaps print?     Or something else. ?

Regards,
Steve
Reply all
Reply to author
Forward
Message has been deleted
0 new messages