Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pragma to define MID (instruction) behaviour #1071

Open
poppichicken opened this issue Dec 6, 2024 · 2 comments
Open

Add pragma to define MID (instruction) behaviour #1071

poppichicken opened this issue Dec 6, 2024 · 2 comments
Labels
-done- Done beta Candidate for BETA enhancement New feature or request
Milestone

Comments

@poppichicken
Copy link

poppichicken commented Dec 6, 2024

hi Marco.

BITMAP ENABLE(320,200,4)
BORDER WHITE
CLS BLACK
DEFINE KEYBOARD ASYNC

a="ugBASIC"
MID(a,3,1)=""
PRINT "a=";a

To me, this seems as though it shouldn't do anything to string a.
However, it actually removes the B from ugBASIC.
I know that replacing the B with an empty string would conceptually remove the B, but it seems odd than an empty string would do anything at all to string a.

Not sure.
Maybe it's ok as it is.
:)

image

@spotlessmind1975 spotlessmind1975 added wontfix This will not be worked on enhancement New feature or request and removed wontfix This will not be worked on labels Dec 6, 2024
@spotlessmind1975 spotlessmind1975 added this to the future milestone Dec 6, 2024
@spotlessmind1975 spotlessmind1975 changed the title MID (instruction) behaviour (CPC) Add pragma to define MID (instruction) behaviour Dec 6, 2024
@spotlessmind1975
Copy link
Owner

Hi @poppichicken , and thank you for your kind bug report!

The behavior is correct. However, so is your doubt. So we are faced with a behavior of MID that can be different, depending on whether it is interpreted as a change (therefore: with a variation of the length of the string) or as a replacement. For this reason, I believe it is necessary to introduce a pragma (i.e. a directive) that allows you to define which of the two behaviors you want.

The pragma will be OPTION MID REPLACE if you want MID to behave as you expect, that is, with an empty string (or in any case: with a string of length less than that indicated by the parameter) it does not alter the characters that are beyond the minimum value between the length of the string and the length given as a parameter.

The pragma will be OPTION MID INSERT if, instead, you want to maintain the current behavior, therefore with an insertion "in place of" the string in question.

Thank you again!

@poppichicken
Copy link
Author

Sounds great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-done- Done beta Candidate for BETA enhancement New feature or request
Projects
Status: In progress
Development

No branches or pull requests

2 participants