2

i am using file access to input variables into my programm. text file is something like this: a b c ..

on each loop, program access file (using File Access block) and reads a new line "a" or "b" or "c" etc. and write this into a variable. I then use this variable as input for switch block. However switch block only recognized the very first character, while all others are very much all "false"

i know file access pulls out the information (i can display such input using the display block to show it..) yet for the switch block this information does not get recognized.

i tried with numeric, but i get the same problem..

Any ideas?

thanks!

input text file

code - file access read input from txt file into a variable that is then used to display it on the screen one character at a time. switch is used to change size."B" should be bigger variables are displayed but condition of the switch is always "false"

  • 1
    Welcome. Please update your post with a clear image of your code, or at least the relevant section(s) – Phil B. Jul 28 '17 at 14:34
1

It looks like you have found a bug in the file block. I am guessing that the text after the first line must have the a hidden newline character or something like that that causes it to not the switch block values.

However, I was able to get it working with numeric values.

Sample data.rtf

1
2
3
4
5

Sample code: EV3-G screenshot

I also noticed that it doesn't work unless the file has Windows line endings (CRLF). If you are using Notepad in Windows, this is not a problem.

  • thanks a lot for this David - i guess i will switch to numeric as my list of inputs although think i tried that before and it gave me same problem. Did you use usual windows notepad editor to create your data.rtf? – user9030 Jul 30 '17 at 7:35
  • I tested on macOS using Visual Studio Code for my text editor. It allows you to select which type of line endings to use in the file. – David Lechner Jul 30 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.