microsoft / pxt

Microsoft MakeCode (PXT - Programming eXperience Toolkit)
https://makecode.com
MIT License
2.08k stars 579 forks source link

Working with Strings (String block and concatination) #531

Closed abchatra closed 7 years ago

abchatra commented 7 years ago

A few things related to strings. 1 - I could be blind, but am not seeing anywhere to create an actual string block itself? You can easily get one from bottom of Math can can get a boolean from bottom of Logic, but can't see anywhere to get a string block? You can simply create the block itself with Javascript simply using

"Hello";

Which then creates the String block. screen shot 2016-05-24 at 22 15 40

Although I very easily could be missing something, without it you can't for example set a variable to a string? screen shot 2016-05-24 at 22 19 56

2 - Am not seeing any way to concatenate 2 strings with blocks? Scratch for example has the join block join Could either go down the road of another block (join for example), or use the addition block, given is how the code is doing it underneath anyway, using the + symbol. For example:

0 + 0;
"Hello " + "World";
abchatra commented 7 years ago

Ported from original pxt-microbit repo: https://github.com/Microsoft/pxt-microbit/issues/72

abchatra commented 7 years ago

Another request is String comparison from https://github.com/Microsoft/pxt/issues/128

pelikhan commented 7 years ago

There is a work item to support Text blocks in the block editor. For the microbit, we’ve stayed away from strings to avoid any kind of memory allocation on the student part.

From: Abhijith Chatra [mailto:notifications@github.com] Sent: Thursday, October 20, 2016 3:34 PM To: Microsoft/pxt pxt@noreply.github.com Subject: [Microsoft/pxt] Working with Strings (String block and concatination) (#531)

A few things related to strings. 1 - I could be blind, but am not seeing anywhere to create an actual string block itself? You can easily get one from bottom of Math can can get a boolean from bottom of Logic, but can't see anywhere to get a string block? You can simply create the block itself with Javascript simply using

"Hello";

Which then creates the String block. [screen shot 2016-05-24 at 22 15 40]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F833193%2F15520223%2F1dd833ac-21fd-11e6-8e00-ae65d6c4307e.png&data=02%7C01%7Cjhalleux%40microsoft.com%7Ceea5e08a40074ff6bf0b08d3f93941c5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636125996706834574&sdata=U6z3Pg4q5jSKqmhgqN8tCVu8%2BvSyR1rcCbgmHYg9FJE%3D&reserved=0

Although I very easily could be missing something, without it you can't for example set a variable to a string? [screen shot 2016-05-24 at 22 19 56]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F833193%2F15520327%2Fac099738-21fd-11e6-84fb-b655b91af50f.png&data=02%7C01%7Cjhalleux%40microsoft.com%7Ceea5e08a40074ff6bf0b08d3f93941c5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636125996706834574&sdata=oSBVzs3zjisnxf9DOeX6ARKQOPWBotz9B2XMR5fuilU%3D&reserved=0

2 - Am not seeing any way to concatenate 2 strings with blocks? Scratch for example has the join block [join]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F833193%2F15520404%2F0fccdfd2-21fe-11e6-87e1-3e26f9f6226a.gif&data=02%7C01%7Cjhalleux%40microsoft.com%7Ceea5e08a40074ff6bf0b08d3f93941c5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636125996706834574&sdata=qZOUi%2BpT9XCe8CpS%2BuHyDyoYmVq6ulZfEgylT3FaFyc%3D&reserved=0 Could either go down the road of another block (join for example), or use the addition block, given is how the code is doing it underneath anyway, using the + symbol. For example:

0 + 0;

"Hello " + "World";

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fpxt%2Fissues%2F531&data=02%7C01%7Cjhalleux%40microsoft.com%7Ceea5e08a40074ff6bf0b08d3f93941c5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636125996706834574&sdata=qTl5Se0s8%2BLZYSJhiGcaSDFn0ZKZt4wgzVbmzaT2SR8%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD-4KZkJKDPmPJdXyKkaawnIqfFMWestks5q1-x0gaJpZM4KcrXz&data=02%7C01%7Cjhalleux%40microsoft.com%7Ceea5e08a40074ff6bf0b08d3f93941c5%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636125996706834574&sdata=ZJQ5VSCCtKNlhODrmFhMGj5CiVglExix1L3t3oNUgII%3D&reserved=0.

OwenBrotherwood commented 7 years ago

Is there any thoughts as to how string initialisation, string memory allocation with possible uses in eddystone where the student may wish to change the beacon dependant on needs in a play and learn scenario? The beacon can communicate at a distance information regarding "whatever the student wishes" in "whatever they are doing"


Edit https://github.com/Microsoft/pxt/issues/938#issuecomment-267652746

whaleygeek commented 7 years ago

Just wondering if there is any update on the strings issue? We're getting a lot of teachers asking for how to do this, as string processing is part of the curriculum that they teach. Thanks

TheRedBeardedOne commented 7 years ago

Hi there, thanks @whaleygeek for keeping this topic warm.

As you see from the pictures below, the string block would come handy in the below scenario. We're not sending massive amounts of text, and right now we use the JavaScript editor to hack our way to our goal.

radioreceivednamevalue radiosendvalue

abchatra commented 7 years ago

@guillaumejenkins who is looking into building string support in blocks.

guillaumejenkins commented 7 years ago

After playing around a bit, it looks like the support is already there and working well. We just need to enable a config setting in the micro:bit target to turn it on. @riknoll has also done some improvements to the text blocks to make them easier to understand. This should be coming in to /beta very soon.

abchatra commented 7 years ago

Text blocks are enabled now.

TheRedBeardedOne commented 7 years ago

Thank you so much, we have used them in the classroom last week already!