3

I have the following code line:

 0DATA"-+-+-"

Here "\" and "/" are the ASC codes 205 and 206.

I get a syntax error:

?SYNTAX  ERROR IN 0
READY.

As I can remember, there was same special in the handling of the special terminal-controlling characters in strings. For example, a reverse ❤ has deleted the screen on print, but it behaved normally in the source code.

Any idea, what could be the reason?

enter image description here


Extension: my tests show it happens with all strings, not only for these. I use vice.

  • I can't reproduce the problem. Can you add a screenshot showing everything you did? – Ross Ridge Sep 17 '17 at 14:32
  • @RossRidge Tyvm! I added the screenshot. – peterh Sep 17 '17 at 14:35
  • The screenshot's line 0 is different from your transcribed line 0.. – snips-n-snails Sep 17 '17 at 19:50
  • @traal Sorry - for I've thought that it may be caused by some escaping problem, this is what I tried to test. The screenshot contains this test version. However, not this was the reason of the problem (as the accepted answer shows). I can insert it into the post (if the difference can be considered important). – peterh Sep 17 '17 at 19:53
  • @traal I synchronized the post and the screenshot (check the accepted answer - not this was the cause of the problem). – peterh Sep 17 '17 at 19:54
13

Your problem may be with your READ statement, not the DATA statement. If you have string data, make sure you read into a string variable like so:

10 READ X$

If you try to read string data into a numeric variable you will get a syntax error reported on the DATA line, even though it was the READ that triggered it. So this would give you an error:

0 DATA "A"
10 READ X
9

The problem is with the flowing line:

2 READS:X=1024:FORY=1TOLEN(S):A=ASC(MID$(S,Y,1)):POKEX,A:X=X-165+A*2:NEXT

String variables in BASIC need to suffixes with a dollar sign $. So all your uses of the variable S should be S$:

2 READS$:X=1024:FORY=1TOLEN(S$):A=ASC(MID$(S$,Y,1)):POKEX,A:X=X-165+A*2:NEXT

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.