Thread for Picomite MMBasic issues

I’ve been dealing with the differences in BASIC since my TRS-80 Model I and Commodore PET days, so I just work around the ones I find.

1 Like

Webmite ‘WEB ntp’ time fetch command.

Is there a way to make this execute silently within a program instead of printing the darn ntp address and response ??

UPDATE found it…

Option console none
~
Option console screen

1 Like

MMBasic 6.00.02

Command to position the cursor?

I know we can print to a certain x, y pixel coordinate, but using the LOCATE or CURSOR command in other BASIC dialects allows you to position the cursor without printing. This means subsequent INPUT commands also generate the prompt at that desired position. Am I missing a command, or is the workaround an empty print to X, Y and then INPUT$?

Print @(x,y);

Where x&y are screen pixel coordinates (0-319). Zero being top left.

1 Like

Nope. You aren’t missing anything. There is no way to place the cursor without printing. You simply print nothing to the location you want to print at.

Note that this is the same as how Microsoft BASIC did it on the TRS-80.

1 Like

A new issue appears. Or maybe just pebkac. The clipboard contents don’t seem to persist after ending the editor. An explanation of what I’m trying to do, in case there is a better way to accomplish it.

Using the MMBasic editor, I would like to copy a subroutine to a different program. I marked the subroutine in question, exited the editor to open my target program and hit F5 to paste. Sadly, the clipboard is empty. Should I be using a different method to go about this?

I’ve often wondered about this too, sadly a feature of the editor…

1 Like

On Webmite 6.00.03 is it possible to send to a TCP client without expecting a response? I am trying to control test equipment over an ethernet to serial link. I can send requests that generate a response but when I send a command, with no response expected, I get an error: “No response from server”. This is not an error, it is the expected behaviour. The Webmite documentation has very little to say on the matter.

Got you, thank you for posting useful staff in here

Sadly, the Webmite commands seem to be mostly an afterthought to support a specific project on TheBackShed and are fairly limited. Doesn’t seem like the functionality will ever be expanded, either. That said, there may be a way to make this work though I haven’t tried it in this sort of situation. Check the docs for ON ERROR SKIP.

You may want to set the optional timeout value to something low too. (I didn’t check but hopefully it supports 0, but if not, then maybe 1, 10, or 100.milliseconds.) Looks like the default is 5 seconds.

The idea being that:

ON ERROR SKIP
WEB TCP CLIENT REQUEST “query text“, inbuf%(), 0

will still cause the error, but it will not be shown, or stop program execution. While it shouldn’t be necessary, you could also add ON ERROR CLEAR after the WEB TCP CLIENT REQUEST to make it clear errors are handled as normal after this line. If you have multiple requests in sequence you could add a value to the end of the skip line so it skips past multiple “errors”.

For debugging purposes MM.ERRNO and MM.ERRMSG$ could be checked/shown just to verify that the only “error” happening is the one you are expecting.

I ended up using the ON ERROR SKIP command for something else that was not really an error, but couldn’t be handled properly in MMBasic. I forgot the details, but it worked, so hopefully it will here too.

1 Like

I had considered the ON ERROR route but had hoped there was a nicer solution. :frowning: I have looked at the source and it’s a fairly deep rabbit hole so it I guess that is the only way for now. It’s early days so maybe someone with more patience than me may unravel the code and provide a more useful implementation :crossed_fingers:. Thanks for the reply.

If anyone else is considering using serial over IP (Telnet without the bells an whistles) then the following code does work:

Dim buf%(256 / 8)
Const addr = "192.168.1.200"
Const port = 4196
Const eol = Chr$(13) + Chr$(10)

Function Query$(Q$)
  WEB OPEN TCP CLIENT addr, port
  WEB TCP CLIENT REQUEST Q$+eol,buf%()
  l% = Min(LLen(buf%()), 256)
  Query$ = LGetStr$(buf%(), 1, l%)
  WEB CLOSE TCP CLIENT
End Function

Sub Send Q$
  WEB OPEN TCP CLIENT addr, port
  On Error Skip
  WEB TCP CLIENT REQUEST Q$+eol,buf%(),1
  WEB CLOSE TCP CLIENT
  On Error Clear
End Sub

Print Query$("*IDN?")
Send "SYST:REM"
Pause 2000
Send "SYST:LOC"

These commands request an HP multimeter to identify itself, enter remote control mode and then drop back into local control mode. This should work for any test equipment using the SCPI protocol and is a nice way to automate testing or record measurements over time.

The output from the above is shown below:

> run
Connected
HEWLETT-PACKARD,34401A,0,11-5-2

Connected
Connected
>

1 Like

To be honest, I’m afraid of messing with any of the code related to WebMite. In general, I prefer not to make too many changes from the main PicoMite/Webmite sources, to keep the fork cleaner. Peter, the official PicoMite dev seems to make radical changes from time to time, and trying to keep things in sync would be a headache. It’s not been “easy” from the start, but things are at a point now where the PicoCalc modifications are more isolated and minmal, and in parts of the code that dont’ seem to change that often. The Webmite functionality in particular is something Peter seems unwilling to work on based on posts he’s made on TheBackShed, which makes me think it’s rather fragile. It also seems to depend on very specific timing peculiarities for the Pico modules.

I’ve been toying with the idea of adding some other, non-PicoCalc specific things, but if I do I want to keep it simple. (For instance, I personally find some of the command line functionality to be awkward, like not accepting “cd”.) There have been a number of ideas and bug reports or feature requests posted to this forum too, and some of them were things I’ve noticed and not liked as well. The editor has all kinds of usability issues, like being unable to copy/paste from one file to another since the entire environment is dumped when the editor is exited. I’m not sure if it will be possible (or wise) to try to make that work, but I’ve been thinking I might sneak in some extra PicoCalc related key combos to make things like searching for text in the editor a bit easier.

Personally, I’d love to see the Bluetooth/BLE functionality exposed and available to MMBasic, but I know that’s not something Peter would ever consider as any additional wireless functionality requests on the BackShed have been shut down rather quickly. Even having support for SSL and being able to use https addresses seems like a sensible and almost required feature, but that too isn’t going to happen in the official builds. To do anything truely useful with wireless functionality, I think machiKania/phyllosoma may be the only way to do it with BASIC. It’s possible to hack around and get WebMite to do some simple stuff though. But accessing any modern APIs that use SSL isn’t really possible unless you set up your own passthrough server.

For what it’s worth, I’ve always been using WebMite to test builds, and that’s what I use on my device for everything. It’s slower than running PicoMite, but I like the wireless for NTP since I haven’t added an external RTC (and probably won’t), and also since it’s slower it means anything I get running on the thing at a reasonable speed should also work on PicoMite, at least on a Pico2.

2 Likes

From reading the backshed posts I think the issue with HTTPS (TLS) is the sheer scale of the code required to implement the various encryption algorithms. Early versions of the Webmite did support HTTPS but it only worked on some sites and needed resource like 32Kb of System heap to run.

Also note there are no examples in either the sdk or pico-examples of how to do any of this stuff.

From AI

how many underlying encryption mechanisms are used in https. Do all site use the same?

Great question — HTTPS isn’t a single, fixed encryption mechanism. It’s a protocol stack that can use different underlying algorithms depending on configuration and negotiation between your browser and the server.

Here’s how it works:

1. Layers of encryption in HTTPS

HTTPS = HTTP + TLS (Transport Layer Security)
TLS itself uses multiple cryptographic mechanisms at different stages:

  1. Key exchange / handshake

    • Used to agree on a shared secret key between client and server.

    • Common algorithms:

      • RSA (older, less common today)

      • Diffie–Hellman (DH), Elliptic Curve Diffie–Hellman (ECDHE) (preferred today for forward secrecy)

  2. Authentication

    • Usually via digital certificates (X.509, signed with RSA, ECDSA, or EdDSA).

    • Confirms the server (and optionally the client) is who it claims to be.

  3. Bulk data encryption (symmetric)

    • Once the session key is agreed, actual web traffic is encrypted with a symmetric cipher (fast).

    • Examples:

      • AES (in modes like GCM or CBC)

      • ChaCha20-Poly1305 (popular on mobile devices)

  4. Message authentication / integrity

    • Ensures the data hasn’t been modified in transit.

    • Done via AEAD (Authenticated Encryption with Associated Data), e.g. AES-GCM or ChaCha20-Poly1305 include this automatically.


2. Do all sites use the same mechanisms?

No. Sites can (and do) differ:

  • Cipher suites (the combination of key exchange + encryption + integrity) vary depending on what the server supports and what the client (browser) supports.

  • During the TLS handshake, both sides negotiate the best mutually supported cipher suite.

  • Example:

    • One site may use ECDHE + RSA + AES-256-GCM

    • Another might use ECDHE + ECDSA + ChaCha20-Poly1305

    • An old or misconfigured site might still use weaker ones (e.g., RSA key exchange, AES-CBC, or even deprecated 3DES).

Next Issue -

I’m using Windows MMBasic 5.05.05 There has to be a better way to round a decimal number off to a fix number of places to the right of the point. Here is how I’m doing it now: Example: to round off 3.14159 to two places I multiply by 100 (3.14159 X 100 = 314.159) then I use Cint (Cint(314.159) = 314) then I devide by 100 (314/100 = 3.14) What is the right MMBasic function I should be using? Thanks!

I’d use the STR$ command:

n=VAL(STR$(3.14159,15,2))

The second number is the field length but isn’t important when using the VAL function.

In addition to not properly rounding the number, wouldn’t this likely be slower than doing what @UtahPilot is doing?

I was wrong about the rounding. It does round properly. As far as speed, multiplication and division are among the slowest operations in MMBasic. String truncation should be faster. You could always write a benchmark to time them.