add initial toString block (#1958)
This commit is contained in:
parent
b611909d99
commit
aa51b7e014
7
docs/reference/text/to-string.md
Normal file
7
docs/reference/text/to-string.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# to string
|
||||||
|
|
||||||
|
Converts a value into a text representation.
|
||||||
|
|
||||||
|
```sig
|
||||||
|
toString(123)
|
||||||
|
```
|
@ -549,5 +549,7 @@
|
|||||||
"serial.writeString": "Send a piece of text through the serial connection.",
|
"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": "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|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"
|
||||||
}
|
}
|
@ -371,6 +371,7 @@
|
|||||||
"serial.writeString|block": "serial|write string %text",
|
"serial.writeString|block": "serial|write string %text",
|
||||||
"serial.writeValue|block": "serial|write value %name|= %value",
|
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||||
"serial|block": "serial",
|
"serial|block": "serial",
|
||||||
|
"toString|block": "convert $value=variables_get(myValue) to string",
|
||||||
"{id:category}AnalogInPin": "AnalogInPin",
|
"{id:category}AnalogInPin": "AnalogInPin",
|
||||||
"{id:category}AnalogOutPin": "AnalogOutPin",
|
"{id:category}AnalogOutPin": "AnalogOutPin",
|
||||||
"{id:category}Array": "Array",
|
"{id:category}Array": "Array",
|
||||||
|
@ -53,3 +53,14 @@ namespace control {
|
|||||||
//% shim=pxtrt::runtimeWarning
|
//% shim=pxtrt::runtimeWarning
|
||||||
export function runtimeWarning(message: string) { }
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user