Feature: read line from stdin
joeskeen opened this issue Β· comments
βοΈ Proposed change
EmojiCode allows printing to stdout using π, but I don't see anything in the documentation about reading input from stdin.
π€ Rationale
I'd love to be able to prompt for values at runtime, or pipe input into an EmojiCode program.
π‘βsππΌ does that.
Awesome, thanks. I wish there was an easier way to search the documentation for things like this.
Hmm... I guess I'm doing something wrong?
π¨ error: sπ‘ has no initializer π.
https://tio.run/##S83Nz8pMzk9JNfv//8P8/kaFD/N727k4P8yf0QBktk39MH/Kwg/zJzY9mjv9/Y5@IMkFVND5/39GpkJ5flFOCgA
Oh, I see... The ears color isn't right...
Do you have any way of dealing with skin tone differences? My phone's emoji keyboard only does the yellow skin tone, so I have to copy and paste, which is slightly painful. It would be interesting to have a way to alias some of those things so it doesn't matter what your skin color is π
The skin color is always taken into account with normal identifiers. Only languages constructs like π€·ββοΈ work regardless of gender and skin color.
When designing the language we have to assume that users can type all emojis, so we really donβt have any solution here.
What OS is your phone running?
I'm running OxygenOS 9.5 (Android P based) with the GBoard Google keyboard. Just did some research and discovered that you can long press the emoji to change the skin tone. That should resolve the issue.
Hello!
I'm having trouble getting user input. This current issue doesn't have any usable examples, at least for the version I have today.
I am able to compile a basic hello world program with a basic print to standard output.
I am on a Linux environment: https://repl.it/@mwilki7/emoji-language#main.emojic
Below is what I have tried.
Thanks for your help.
Method 1
Code:
π π
π π€Enter text:π€βοΈ
πβΆοΈππΌ
π π€Hello World!π€βοΈ
π
Source: https://www.emojicode.org/docs/packages/s/1f521.html#i%F0%9F%91%82%F0%9F%8F%BC
Output:
../main.emojic:10:6: π¨ error: Expected Identifier but instead found Operator(βΆ).
πβΆοΈππΌ
β¬οΈ
Method 2
Code:
π π
π π€Enter text:π€βοΈ
π·π‘π―
π π€Hello World!π€βοΈ
π
Source: https://gitter.im/emojicode/emojicode?at=56f017f58ea88c6726736366 (search for the text "input", user marcelpatrick has a similar question)
Otto Winter @OttoWinter Mar 28 2016 05:03
π― is an initializer for π‘, so you can call it with π·π‘π―; this will return you a π‘ instance which you could store with π¦in π·π‘π―
Output:
../main.emojic:12:1: π¨ error: Unexpected token BlockEnd.
πβ¬οΈ
../main.emojic:12:1: π¨ error: Unexpected end of program.
πβ¬οΈ
Method 3
Code:
π π
π π€Enter text:π€βοΈ
ππ‘ππΌβοΈ
π π€Hello World!π€βοΈ
π
Source: joeskeen's code https://tio.run/##S83Nz8pMzk9JNfv//8P8/kaFD/N727k4P8yf0QBktk39MH/Kwg/zJzY9mjv9/Y5@IMkFVND5/39GpkJ5flFOCgA
Output:
../main.emojic:12:1: π¨ error: Unexpected token BlockEnd.
πβ¬οΈ
../main.emojic:12:1: π¨ error: Unexpected end of program.
πβ¬οΈ
@michaelwilkie As this is an initializer, the correct syntax is:
π π
π π€Enter text:π€βοΈ
ππ‘βΆοΈππΌβοΈ
π π€Hello World!π€βοΈ
π
What you were looking at in the package documentation, is a declaration and not an example. You can read more about initialization syntax here: https://www.emojicode.org/docs/reference/classes-valuetypes.html#instantiation
Thanks for the quick reply. That example works.
One last question:
How would I read that value into a variable?
π π
π π€Enter text:π€βοΈ
ππ‘βΆοΈππΌβοΈ β‘οΈ someText
π π€Hello World!π€βοΈ
π
Maybe you want to look at our getting started guide here: https://www.emojicode.org/docs/guides/compile-and-run.html
That works for me. I'll read the page more closely.
Thanks for the help!