add initial toString block (#1958)

This commit is contained in:
Joey Wunderlich 2019-04-04 13:41:51 -07:00 committed by Peli de Halleux
parent b611909d99
commit aa51b7e014
4 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,7 @@
# to string
Converts a value into a text representation.
```sig
toString(123)
```

View File

@ -549,5 +549,7 @@
"serial.writeString": "Send a piece of text through the serial connection.",
"serial.writeValue": "Write a name:value pair as a line to the serial port.",
"serial.writeValue|param|name": "name of the value stream, eg: x",
"serial.writeValue|param|value": "to write"
"serial.writeValue|param|value": "to write",
"toString": "Convert any value to a string",
"toString|param|value": "value to be converted to a string"
}

View File

@ -371,6 +371,7 @@
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial",
"toString|block": "convert $value=variables_get(myValue) to string",
"{id:category}AnalogInPin": "AnalogInPin",
"{id:category}AnalogOutPin": "AnalogOutPin",
"{id:category}Array": "Array",

View File

@ -53,3 +53,14 @@ namespace control {
//% shim=pxtrt::runtimeWarning
export function runtimeWarning(message: string) { }
}
/**
* Convert any value to a string
* @param value value to be converted to a string
*/
//% help=text/to-string weight=1
//% block="convert $value=variables_get(myValue) to string"
//% blockId=variable_to_string blockNamespace="text"
function toString(value: any): string {
return "" + value;
}