Author Topic: mid$ statement  (Read 2099 times)

jcfuller

  • Sr. Member
  • ****
  • Posts: 394
    • View Profile
mid$ statement
« on: February 29, 2020, 08:52:00 AM »

  This is probably a bit anal but the mid$ statement accepts a literal as the mainstring$.
There is no way a compiler can detect an issue so it has to be done with the translator. I am not very good when it comes to following the Stk$[], Ndx code.
  I know it's not a big concern but my ocd tells me a procedure should not get a literal when it wants a char*

James



 

Robert

  • Hero Member
  • *****
  • Posts: 1145
    • View Profile
Re: mid$ statement
« Reply #1 on: February 29, 2020, 02:53:34 PM »

  This is probably a bit anal but the mid$ statement accepts a literal as the mainstring$.
There is no way a compiler can detect an issue so it has to be done with the translator. I am not very good when it comes to following the Stk$[], Ndx code.
  I know it's not a big concern but my ocd tells me a procedure should not get a literal when it wants a char*

James


Code: [Select]

 DIM tmp$
 DIM anal$
 tmp$ = "s'not OCD!"
 anal$ = MID$(tmp$, 3, 3)
 PRINT anal$


MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1896
    • View Profile
Re: mid$ statement
« Reply #2 on: February 29, 2020, 03:55:01 PM »

  This is probably a bit anal but the mid$ statement accepts a literal as the mainstring$.
There is no way a compiler can detect an issue so it has to be done with the translator. I am not very good when it comes to following the Stk$[], Ndx code.
  I know it's not a big concern but my ocd tells me a procedure should not get a literal when it wants a char*

James

If you attach pain to a lesson, the lesson will be more fully learned.

MID$("What does this accomplish?",1) = "This just proves the point ... "

jcfuller

  • Sr. Member
  • ****
  • Posts: 394
    • View Profile
Re: mid$ statement
« Reply #3 on: February 29, 2020, 04:07:54 PM »
Robert,
  Nice Mid$ FUNCTION demo.

Kevin,
  I know, but all you need do is check for a DQ  in the midstr$ parsing and throw an error.
noob suzy coder (who did RTFM MID$ but stopped at the function and didn't make it to the statement) would be very thankful :)

James

Robert

  • Hero Member
  • *****
  • Posts: 1145
    • View Profile
Re: mid$ statement
« Reply #4 on: February 29, 2020, 04:27:26 PM »
Robert,
  Nice Mid$ FUNCTION demo.

Kevin,
  I know, but all you need do is check for a DQ  in the midstr$ parsing and throw an error.
noob suzy coder (who did RTFM MID$ but stopped at the function and didn't make it to the statement) would be very thankful :)

James

DQ midstr$ example?

Robert

  • Hero Member
  • *****
  • Posts: 1145
    • View Profile
Re: mid$ statement
« Reply #5 on: February 29, 2020, 04:36:48 PM »
Robert,
  Nice Mid$ FUNCTION demo.

Kevin,
  I know, but all you need do is check for a DQ  in the midstr$ parsing and throw an error.
noob suzy coder (who did RTFM MID$ but stopped at the function and didn't make it to the statement) would be very thankful :)

James

DQ midstr$ example?

Never mind. This thread is too stupid to even to begin to comprehend.

Robert

  • Hero Member
  • *****
  • Posts: 1145
    • View Profile
Re: mid$ statement
« Reply #6 on: February 29, 2020, 04:42:37 PM »
Robert,
  Nice Mid$ FUNCTION demo.

Kevin,
  I know, but all you need do is check for a DQ  in the midstr$ parsing and throw an error.
noob suzy coder (who did RTFM MID$ but stopped at the function and didn't make it to the statement) would be very thankful :)

James

DQ midstr$ example?

Never mind. This thread is too stupid to even to begin to comprehend.

Maybe better, is "Never mind, I'm too stupid to even to begin to comprehend this post."

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 1896
    • View Profile
Re: mid$ statement
« Reply #7 on: February 29, 2020, 04:53:40 PM »
I added one line to help Suzy Coder.  My earlier one-liner now throws this error:

BCX BASIC to C/C++ Translator (c) 1999 by Kevin Diggins
Version 7.4.7 (BETA)
Error!
test.bas
MID$ statement string argument cannot be a literal at line 1 in Module: test.bas

Original line
MID$("What does this accomplish?",1) = "This just proves the point ... "
==============
Current Tokens
==============
  1 midstr
  2 (
  3 "What does this accomplish?"
is a STRING LITERAL
  4 ,
  5 1
  6 )
  7 =
  8 "This just proves the point ... "
is a STRING LITERAL
===============
Original Tokens
===============
  1 MID$
  2 (
  3 "What does this accomplish?"
is a string literal
  4 ,
  5 1
  6 )
  7 =
  8 "This just proves the point ... "
is a string literal



There remains numerous other ways for Suzy Coder to blow her foot off.