I am trying to create converter extension which can convert binary to string and back again with other conversions like octal. Do you need this in the same extension or separate?
- Same
- Separate
- Don't care
0 voters
I am trying to create converter extension which can convert binary to string and back again with other conversions like octal. Do you need this in the same extension or separate?
0 voters
Is this a question? Or you joking sorry but what if app inventor was made different website for designer and different for blocks? Sorry but it does not make any sense
as Italo already said
try to build an extension for something people need and App Inventor can't do with simple built in blocks.
see also the already available convert number block
http://ai2.appinventor.mit.edu/reference/blocks/math.html#convertnumber
Taifun
PS: please also do not mix your different threads... I moved your last post into the correct thread, which is this one... thank you...
I am trying to create conversions between STRING and BINARY by there is no block or that...
taken from here MIT App Inventor Math Blocks
can you provide an example of that string, which you like to convert into binary?
Taifun
PS: please keep the discussion in the community rather than sending my a PM... thank you...
AI2 lacks a string to byte list converter for use by people coding for data communication.
Likewise for the opposite direction: byte list to string.
Interesting idea.
Unfortunately byte[] can't be returned from a method in app inventor but we have list as workaround.
By byte list, I am referring to the Bluetooth data streams typified in this Ble block from
http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro
BytesReceived
– The BytesReceived
event is run when one or more byte values are received from a connected Bluetooth device. Depending on the sign
parameter of the last call to ReadBytes
or RegisterForBytes
for the given serviceUuid
and characteristicUuid
, the byteValues
list will contain numbers ranging from -128 to 127 ( signed = true
) or 0 to 255 ( signed = false
). Parameters :
serviceUuid
( text ) — The unique identifier of the service passed in the read or register call.characteristicUuid
( text ) — The unique identifier of the characteristic in the read or register call.byteValues
( list ) — A list of values read from the device. The range of each value will depend on the sign
flag previously specified in the call to read or register.Thanks to @Italo for encouraging me, I didn't want to do it as it was a little difficult.
His encouragement helped
Blocks
--
--
Downloads
Google Drive - ZIP file
Direct download - BinaryTool (6.8 KB)
Binary Tool AI2 Extension by Xoma (Kumaraswamy) is licensed under CC BY-ND 4.0
(My friend will scold me if the dint't provide link to license. )
Any suggestions or improvements are appreciated!
Thanks
Suggestion: Add a when Error occurred event. It is better than throwing a YailRuntimeError for that.
Hey, thanks for the suggestion, but do you know how to do it? I am still learning..
Also why you got that error?
For fast operations like this with one input and one output,
it would be more convenient to offer a block with input and output ports,
like a math block.
Also, offer sample input annd output examples in your tool tip docs.
I didn't understand these lines..?
What @ABG mean is you shouldn't use void
, instead you should return something directly.
I don't have any error. I am just suggesting. Use a try-catch
statement to catch the exception error, and use an event block to handle it.
Example:
@SimpleEvent(description = "Raises when error occurred.")
public void ErrorOccurred(String error) {
EventDispatcher.dispatchEvent(this, "ErrorOccurred", error);
}
@SimpleFunction(description = "Integer addition")
public int Addition(int a, int b){
try {
return a + b;
} catch (Exception e) {
ErrorOccurred(e.getMessage());
return 0;
}
}
Its throws and error that "catch" without "try"... But the code is all correct
it means you did not used try statement
No! I am used it...
Ok, lets not go offtopic here... I will learn it later.
This extension is discontinued :