Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 10:13 26 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Enter short text

     Page 2 of 2    
Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5901
Posted: 10:51pm 04 Dec 2022
Copy link to clipboard 
Print this post

  rea23 said  
@phil99:
It's strange, but I get the error:

[31] Print If(mvolt > 220) And (mvolt < 3100) Then   'Read letter if no buttons pressed
Error : IF is not declared

And indeed, MM Edit or the interpreter knows nothing about a command IF or ENDIF/END IF. I don't no what happens.

Edit:
False alarm: After a restart of MM Edit the program works as intended. Thank you very much.


I have noticed that a few no-break-space characters are getting into some code listings on TBS.
I also discovered that MMEdit is not always finding and squashing them.

Sending a no-break-space (chr$(160)) to your 'mite is not good and it is probably what you experienced. The PRINT keyword you saw is actually a '?' for unknown character.

I will try and post an update to MMEdit later today.

Jim
VK7JH
MMedit   MMBasic Help
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1781
Posted: 11:32pm 04 Dec 2022
Copy link to clipboard 
Print this post

Don't know if it helps but that code was copied from a TeraTerm window (Alt_C) directly into TBS CODE /CODE.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5901
Posted: 12:35am 05 Dec 2022
Copy link to clipboard 
Print this post

  phil99 said  Don't know if it helps but that code was copied from a TeraTerm window (Alt_C) directly into TBS CODE /CODE.

Thanks for that Phil
There are 17 'space' characters in Unicode that I know of.
MMEdit can filter out most of them including no-break-space.
Something strange seems to be happening when I retrieve text directly from the Windows clipboard which cause MMEdit to miss the no-break-space.

I can't investigate further for a few days but I have done a patch which seems to have worked.

It looks like the lines you have added to the code were given the no-break-space treatment but I don't know why it was only the select few lines in your post.

Jim
VK7JH
MMedit   MMBasic Help
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1781
Posted: 07:04am 05 Dec 2022
Copy link to clipboard 
Print this post

" I don't know why it was only the select few lines "

I may have a clue about that. While using the internal editor through TeraTerm, going back and forth between F2 Run and F4 Edit at one point only half of the program appeared in the editor. Hit Esc to get out and tried again, same thing. F3 List showed the whole program was still there so un / re-plugged USB and all seemed back to normal. After finishing editing, F3 then copy and paste into TBS.
Perhaps I bumped a wrong key somewhere in all that adding a non-printable character or two.

Next time I will paste into Notepad first then copy from that. I don't think it saves non-printable characters.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5901
Posted: 08:54am 05 Dec 2022
Copy link to clipboard 
Print this post

  phil99 said  
Next time I will paste into Notepad first then copy from that. I don't think it saves non-printable characters.


Not so easy. The later Notepad is Unicode so the troublesome characters will still be there.
I will have to update "clipclean" and see if there is more interest than last time.

Jim
VK7JH
MMedit   MMBasic Help
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 10:05am 05 Dec 2022
Copy link to clipboard 
Print this post

  TassyJim said  
I will have to update "clipclean" ....

Jim

I noticed the unknown keywords in something I copied from TBS about a week ago. I remembered clipclean and have it as an item under the Action Menu. Just select all, copy to clipboard, run the Action/Clipclean and paste it back.
Latest F4 Latest H7
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5901
Posted: 10:37am 05 Dec 2022
Copy link to clipboard 
Print this post

  disco4now said  
  TassyJim said  
I will have to update "clipclean" ....

Jim

I noticed the unknown keywords in something I copied from TBS about a week ago. I remembered clipclean and have it as an item under the Action Menu. Just select all, copy to clipboard, run the Action/Clipclean and paste it back.


Or,
Under the Program menu,
run "remove non_ASCII characters".
But update MMEdit first.

Clipclean is missing a few of the Unicode characters that appear at times.

Jim
VK7JH
MMedit   MMBasic Help
 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 01:04pm 05 Dec 2022
Copy link to clipboard 
Print this post

I think it is now the elegant solution that was sought. Thanks to all who have helped.
Hans


' ***************************************
' Text input with poti (TimD and phil99)
' ADC0, 1k-10k-1k gives (measured):
' 0.2790...3.0080 V over poti
' Switch down on lower R1k: 0.0130 V
' Poti works ok ==> shows A...Z
' Newname: long press on last letter
' With ABC... and cursor lines
' 5.12.2022: Just fine
'****************************************

SetPin GP26, AIN                      'ADC0 at pin31
' !! inverted colors because of "false" driver for LCD!! Take RGB values
Const black_= RGB(255,255,255)        'black inv.
Const green_= RGB(255,127,255)        'green inv.
Const yellow_= RGB(0,0,255)           'yellow inv.
Dim letter As string length 1         'letter for name
Dim newname As string
Dim z, no, fini, t as Integer                'counter, number, flag, toggle
abc$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"   'choice of letters
dx = 12                               'spacing
ytxt = 60                             'y-position of text
dy = 20                               'distance cursor to text
no = 13                               'number of letter/cursor position

CLS black_                            'display black, iRGB of (0,0,0)
Font 2, 1
text 4, ytxt, abc$,,,, green_, black_ 'ABCDE...Z
text x, ytxt+dy, "^",,2,, yellow_, black_

Again:
Do
 NewLetter = 0 : finished = 0
 Box 0,0,320,240,1, yellow_
 text 1, ytxt+dy, "                          ",,2,, yellow_, black_
 text 2, ytxt+dy, "                          ",,2,, yellow_, black_
 mvolt=Int(1000*Pin(31))             'millivolt
 If (mvolt > 220) And (mvolt < 3100) Then   'Read letter if no buttons pressed
   diff=3008-279                     'measured min/max
   du=diff/25                        '26-1 between
   no=Int(mvolt/du)-1                'first # should be 1
   letter=Chr$(no+64)                'A is chr$(65)
   text (newno-1)*dx+4, ytxt+dy, " ",,2,, yellow_, black_    '???????
   text (newno-1)*dx+4, ytxt+dy, "^",,2,, yellow_, black_
   Text 4, 100, "Letter is: " + letter,,2,, yellow_, black_  'is ok, A...Z
   Pause 100
 EndIf
 If mvolt < 220 Then                  'lower button pressed add current letter
   Timer = 0
   Do
    mvolt=Int(1000*Pin(31))           'millivolt
    If Timer > 1000 Then Finished = 1
   Loop While (mvolt < 220) And (finished = 0) 'wait for button release
   NewLetter = 1
 EndIf
newno=no  
Loop Until (NewLetter = 1) Or (Finished = 1)      'leave the loop

newname = newname + letter
Text 4, 16, "New name is: " + newname,,2,, yellow_, black_
If Finished = 0 Then GoTo Again
Text 4, 200, "Saved name is: " + newname,,2,, yellow_, black_

End

 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 03:27am 06 Dec 2022
Copy link to clipboard 
Print this post

A couple of years old, yet...
Picking Letters
Visit Vegipete's *Mite Library for cool programs.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5901
Posted: 04:33am 06 Dec 2022
Copy link to clipboard 
Print this post

RE the case of the unwelcome no-break-space characters.

It appears that any code that is indented by one space, Firefox will interpret it as a no-break-space when copying to the clipboard. An indent of two spaces gets it right.
Edge browser gets it right for all indents and copies it as a standard space.

I haven't tried Firefox on Linux yet.

Once it is in the clipboard, some programs will translate it into a space for you. TeraTerm seems to do just that when I pasted into the pico's editor.

TeraTerm has lots of choices for code bases so your mileage may vary.

What happens in Notepad when you save depends on the character format choice.

Why MMEdit didn't find the no-break-spaces is still a mystery which I will investigate in a few days when I get back home.

I haven't tried it yet but apparently, in Word, you can do a global replace space with space and hey presto - strange spaces are converted to 'normal' spaces.

To quote a former Australian PM "life wasn't meant to be easy"

Jim
VK7JH
MMedit   MMBasic Help
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 892
Posted: 07:16am 06 Dec 2022
Copy link to clipboard 
Print this post

  rea23 said  @matherp:
Yes, we have to define what happens if mvolt < 220 (switch down).
But if I insert a line "IF mvolt < 220 THEN letter=letter" at the end inside the loop, the same behavior can be seen.

@phil99:
It's strange, but I get the error:

[31] Print If(mvolt > 220) And (mvolt < 3100) Then   'Read letter if no buttons pressed
Error : IF is not declared

And indeed, MM Edit or the interpreter knows nothing about a command IF or ENDIF/END IF. I don't no what happens.

Edit:
False alarm: After a restart of MM Edit the program works as intended. Thank you very much.

there is no Print at this line in the Code
If (mvolt > 220) And (mvolt < 3100) Then  'Read letter if no buttons pressed

'no comment
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1781
Posted: 07:25am 06 Dec 2022
Copy link to clipboard 
Print this post

If I understood Jim, there is an invisible character acting as a space. MMEdit queries it, replacing it with "?" which MMBasic reads as PRINT.
 
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 07:57am 06 Dec 2022
Copy link to clipboard 
Print this post

That is exactly what happened. As I see now, should have mentioned that with the "?".
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024