Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:38 01 Aug 2025 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 : How to send control characters in hex

Author Message
Canada_Cold
Regular Member

Joined: 11/01/2020
Location: Canada
Posts: 42
Posted: 09:43pm 18 Feb 2023
Copy link to clipboard 
Print this post

Hi,

I’m programming a picomite to communicate to another processor via the com1 and send control characters in hex.  I’ve tried Print #1, CHR$(0A), CHR$(0D) but that gives me an error msg.
I did do a search on the manual, but did not find anything re sending hex characters.  Any help would be great.
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 579
Posted: 09:54pm 18 Feb 2023
Copy link to clipboard 
Print this post

A = 10 so send chr$(10) and so on
Plasma
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:06pm 18 Feb 2023
Copy link to clipboard 
Print this post

You need to use an &h prefix, it's in the manual somewhere:

Print #1, CHR$(&h0A), CHR$(&h0D)


Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 10:08pm 18 Feb 2023
Copy link to clipboard 
Print this post

If you want to send actual hex codes then send CHR$(&H0A).
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
ElectroPI
Newbie

Joined: 27/04/2012
Location: Australia
Posts: 37
Posted: 10:18pm 18 Feb 2023
Copy link to clipboard 
Print this post

Just remember what happens with the PRINT command. If you print variables and put commas in between then the command inserts spaces between the numbers printed. I haven't tried it with control characters but I assume the same. So you should use semi-colons instead.
So let's say you need to send ESC followed by the characters S1 followed by cr then lf, the command would be
PRINT #1, CHR$(27);"S1";CHR$(13);CHR$(10);

Of course the 27, 13 & 10 could be replaced with &H1B, &H0D and &H0A.

Note the ; at the end of the line to suppress sending an extra cr/lf.
 
Canada_Cold
Regular Member

Joined: 11/01/2020
Location: Canada
Posts: 42
Posted: 11:02pm 18 Feb 2023
Copy link to clipboard 
Print this post

Thanks, that works great.
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025