# String handling

**URL:** <https://forum.clockworkpi.com/t/string-handling/16492>\
**Category:** PicoCalc\
**Created:** [April 3, 2025, 8:12am UTC](https://forum.clockworkpi.com/t/string-handling/16492 "2025-04-03T08:12:57Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@Tom](https://forum.clockworkpi.com/u/Tom)\
**Post date:** [April 3, 2025, 8:12am UTC](https://forum.clockworkpi.com/t/string-handling/16492/1 "2025-04-03T08:12:57Z")

</div>

Is any one else encountering the same problem as i am having with strings?

the statement A$=“Qt” for example which does not result in a 2 byte string, but 3 bytes  
where the first byte is a graphic character (cant input it, but it is a circlle with a small square within it) that represents the shift key!! This left shift! Right shift is the same although the graphic is different.

This character is injected each time shift is used within the assignment!

eg A$=“Qt” results in “?Qt” where ? is the graphic!!  
also A$=“Qt Nw” results in “?Qt ?Nw”

Have reported it, but no response from Clockwork yet, just wanted to see if others have seen it? Havnt yet tried updating the image yet to see if it goes away,just using the image  
on the supplied sd card!

Thanks

Tom Connell

---

<div class="post-metadata">

**Author:** ![wezm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/wezm/32/11469_2.png) [@wezm](https://forum.clockworkpi.com/u/wezm)\
**Post date:** [April 3, 2025, 8:23am UTC](https://forum.clockworkpi.com/t/string-handling/16492/2 "2025-04-03T08:23:34Z")

</div>

Typed into the PicoCalc directly I don’t see this behaviour on mine.

---

<div class="post-metadata">

**Author:** ![adcockm](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/adcockm/32/1664_2.png) [@adcockm](https://forum.clockworkpi.com/u/adcockm)\
**Post date:** [April 3, 2025, 9:10am UTC](https://forum.clockworkpi.com/t/string-handling/16492/3 "2025-04-03T09:10:55Z")

</div>

I also didn’t see this when I edited code on the PicoCalc.

If you’re editing it over serial connection, maybe something weird is going on with your software on the host?

---

<div class="post-metadata">

**Author:** ![Tom](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@Tom](https://forum.clockworkpi.com/u/Tom)\
**Post date:** [April 3, 2025, 12:38pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/4 "2025-04-03T12:38:38Z")

</div>

No I am using the picocalc standalone!!!

---

<div class="post-metadata">

**Author:** ![DigitalDreams](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/digitaldreams/32/16007_2.png) [@DigitalDreams](https://forum.clockworkpi.com/u/DigitalDreams)\
**Post date:** [April 3, 2025, 12:44pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/5 "2025-04-03T12:44:16Z")

</div>

Using the older basic supplied with the PicoCalc ?. Will say something like ‘MMBasic Version 5.09. Copyright 2024’. There is now a ‘Version 6.00. Copyright 2025’ with many bug fixes…

> [@Anybody have interesting to compile firmware for RP2350 / pico2?](https://forum.clockworkpi.com/t/anybody-have-interesting-to-compile-firmware-for-rp2350-pico2/16237/14):
>
> here is new PicoMite uf2 file for pico2 based from github issue: welcome to test if you have pico2 or pico2w

---

<div class="post-metadata">

**Author:** ![thwill](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/thwill/32/9466_2.png) [@thwill](https://forum.clockworkpi.com/u/thwill)\
**Post date:** [April 3, 2025, 1:04pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/6 "2025-04-03T13:04:00Z")

</div>

I don’t recall anyone having ever reported anything similar with the non PicoCalc versions of the PicoMite.

Best wishes,

Tom

---

<div class="post-metadata">

**Author:** ![rlauzon](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rlauzon](https://forum.clockworkpi.com/u/rlauzon)\
**Post date:** [April 4, 2025, 12:00am UTC](https://forum.clockworkpi.com/t/string-handling/16492/7 "2025-04-04T00:00:33Z")

</div>

I can’t reproduce this behavior on my PicoCalc.

```auto
a$="Qt"
print len(a$)

```

displays “2”

Now, that said, I wrote a quick test program to get the key codes for a program I was doing

```auto
a1:
a$=inkey$
if a$="" then goto a1
print asc(a$)
goto a1

```

If you run this, you will see that the shift keys have codes, which is unexpected. Ctrl and Alt do as well.

---

<div class="post-metadata">

**Author:** ![Tom](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@Tom](https://forum.clockworkpi.com/u/Tom)\
**Post date:** [April 6, 2025, 10:43am UTC](https://forum.clockworkpi.com/t/string-handling/16492/8 "2025-04-06T10:43:27Z")

</div>

Hi, Having decided this morning to revisit the picocalc I have discovered the problem has dissappeared!!!

Strings are now working normally!! Nothing has been changed except that I took it apart for a visual check and removed and replaced the board!!

Maybe something wasnt quite seated right??

Whatever it seems I am good to go!!

Thanks for the thoughts!!!

Tom Connell

---

<div class="post-metadata">

**Author:** ![white-round-square](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/white-round-square/32/10385_2.png) [@white-round-square](https://forum.clockworkpi.com/u/white-round-square)\
**Post date:** [April 6, 2025, 10:58am UTC](https://forum.clockworkpi.com/t/string-handling/16492/9 "2025-04-06T10:58:00Z")

</div>

> [@Tom](#):
>
> Thanks for the thoughts!!!

best possible approach:

> can’t reproduce, issue closed

---

<div class="post-metadata">

**Author:** ![rlauzon](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rlauzon](https://forum.clockworkpi.com/u/rlauzon)\
**Post date:** [April 10, 2025, 11:30pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/10 "2025-04-10T23:30:52Z")

</div>

So this problem bit me today when writing a program. Here’s a small program to show it off:

> input “test string”;a$:print  
> print a$  
> for i = 1 to len(a$)  
> print asc(mid$(a$,i,1))  
> next i

Enter something like “12:34”. You will see that an extra character, which looks like it represents the Shift key, is inserted into the string. It is **not** displayed in the INPUT, but is displayed in the print and shows up when the ASCII codes for the characters are displayed.

Both shift keys exhibit this “problem” and I’ve tried it with other “shift” characters too (@, #, $, etc.) with the same results.

But it seems to **only** happen when using the INPUT statement.  
A$=“Qt” does **not** exhibit the problem. Perhaps the EDITor removes them.

---

<div class="post-metadata">

**Author:** ![Toml\_12953](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/toml_12953/32/11925_2.png) [@Toml\_12953](https://forum.clockworkpi.com/u/Toml_12953)\
**Post date:** [April 11, 2025, 3:56am UTC](https://forum.clockworkpi.com/t/string-handling/16492/11 "2025-04-11T03:56:28Z")

</div>

> [@rlauzon](#):
>
> input “test string”;a$:print  
> print a$  
> for i = 1 to len(a$)  
> print asc(mid$(a$,i,1))  
> next i

I get no extra characters:

```test

12:34
 49
 50
 58
 51
 52

```

---

<div class="post-metadata">

**Author:** ![Tom](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@Tom](https://forum.clockworkpi.com/u/Tom)\
**Post date:** [April 11, 2025, 8:05am UTC](https://forum.clockworkpi.com/t/string-handling/16492/12 "2025-04-11T08:05:12Z")

</div>

OK AS I said it just disappeared for me! All I did is to open it up and made sure the pico was properly seated and checked the display cable! I am sure neither of those would have directly affected the problem, but maybe something else was not quite right and opening it up rectified it???

A mystery!!!

Tom Connell

---

<div class="post-metadata">

**Author:** ![rlauzon](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rlauzon](https://forum.clockworkpi.com/u/rlauzon)\
**Post date:** [April 11, 2025, 9:28am UTC](https://forum.clockworkpi.com/t/string-handling/16492/13 "2025-04-11T09:28:49Z")

</div>

A “Phase of Moon” bug. The worst kind.

How much do you want to bet that if I ran that same little program now, it would work fine?

---

<div class="post-metadata">

**Author:** ![DigitalDreams](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/digitaldreams/32/16007_2.png) [@DigitalDreams](https://forum.clockworkpi.com/u/DigitalDreams)\
**Post date:** [April 11, 2025, 10:38am UTC](https://forum.clockworkpi.com/t/string-handling/16492/14 "2025-04-11T10:38:25Z")

</div>

> [@Tom](#):
>
> OK AS I said it just disappeared for me! All I did is to open it up and made sure the pico was properly seated and checked the display cable! I am sure neither of those would have directly affected the problem, but maybe something else was not quite right and opening it up rectified it???
> 
> A mystery!!!
> 
> Tom Connell

We used to call that “a Murphy” 🧐

---

<div class="post-metadata">

**Author:** ![rlauzon](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rlauzon](https://forum.clockworkpi.com/u/rlauzon)\
**Post date:** [April 11, 2025, 1:18pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/15 "2025-04-11T13:18:29Z")

</div>

I would have lost my bet.

So I’ve been firing it up and running my test periodically. It’s very consistent.

On a whim, I replaced INPUT with LINE INPUT and the same thing happened.

---

<div class="post-metadata">

**Author:** ![cjstoddard](https://avatars.discourse-cdn.com/v4/letter/c/90ced4/32.png) [@cjstoddard](https://forum.clockworkpi.com/u/cjstoddard)\
**Post date:** [April 11, 2025, 2:15pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/16 "2025-04-11T14:15:44Z")

</div>

Interesting, I actually noticed this with another program I was working on a couple of days ago and was ignoring it.

 ![Untitled](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/c/c92e98c69b57d656e4b4ef5c6c516895a7c34345.png)

---

<div class="post-metadata">

**Author:** ![rlauzon](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rlauzon](https://forum.clockworkpi.com/u/rlauzon)\
**Post date:** [April 11, 2025, 2:43pm UTC](https://forum.clockworkpi.com/t/string-handling/16492/17 "2025-04-11T14:43:33Z")

</div>

```
a$ = InputString("Test string")
print a$
for i = 1 to len(a$)
    print asc(mid$(a$,i,1))
next i

function InputString(prompt$) as String
    local r$="", b$, i, m$

    print prompt$;
    input b$:print

    for i = 1 to len(b$)
        m$ = mid$(b$,i,1)
        select case asc(m$)
            ' Left shift, right shift, ctrl, alt
            case 162, 163, 161, 165
               m$=""
        end select

        r$=r$+m$
    next i

    InputString = r$
end function

```
