Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:30 03 May 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 : File Manager for PicoMite

     Page 14 of 17    
Author Message
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 03:09pm 02 Apr 2025
Copy link to clipboard 
Print this post

Hello Javavi,

I don't want to develop my own version but I would like to support yours!
My first idea would be, to replace the "print @()" commands in the main code with a sub(). Only positioning values will stay for the moment. Are you interested?
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 436
Posted: 03:45pm 02 Apr 2025
Copy link to clipboard 
Print this post

  dddns said  My first idea would be, to replace the "print @()" commands in the main code with a sub(). Only positioning values will stay for the moment. Are you interested?

Yes, this is an interesting idea and a possible way to unify with the console.
All actions on output should be done in one universal procedure.
It may of course slow down the work a little when quickly switching through the list of files.
I need to try it..
Edited 2025-04-03 01:48 by javavi
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 03:51pm 02 Apr 2025
Copy link to clipboard 
Print this post

Exactly. So we should think and agree on the syntax.
When ending a line with a semicolon, a flag is maybe necessary and may be other things, I can't see.
Suggestions?


And if you accept some help I want to make clear, that it stays your work and I don't want to be even named! ..I could maybe do the ugly search and replace? :))
Edited 2025-04-03 02:00 by dddns
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 04:16pm 02 Apr 2025
Copy link to clipboard 
Print this post

The plan I see seems to be not so hard:
It's disabling the local screen for console output. see "option console"  
The printing routine formats for "text" and "print @" with according escape codes
The user decides per config if output is serial/screen/both

Printing with "text" to screen could be faster.
Disabling one or the other because its not needed makes it faster

Thoughts?
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 436
Posted: 04:43pm 02 Apr 2025
Copy link to clipboard 
Print this post

  twofingers said  I think it would be good to work further on merging the two panels into one code with a two-dimensional array. You've already started. I tried it twice and failed due to the limitations of MMBasic.

Hi Michael,
I also encountered a problem when using two-dimensional arrays. For example, the sorting function takes a one-dimensional array as input, and I don't want to reload a large array of data from a two-dimensional array to a one-dimensional one, since I was trying to limit the use of RAM.
Would there be a way to declare a reference to half of a two-dimensional array?
By the way, would it be good to have a mechanism for assigning references to variables not only when passing names to subroutines and functions, or does it already exist?
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1520
Posted: 05:49pm 02 Apr 2025
Copy link to clipboard 
Print this post

  javavi said  ... Would there be a way to declare a reference to half of a two-dimensional array?...


> list
Dim a$(1)=("atest0","atest1")
Dim b$(1,1)=("test0.0","test0.1","test1.0","test1.1")
btest(b$(0,1))
Print
btest(b$(0,0))
Print
End

Sub btest(in$())
 Print in$(0,0)
 Print in$(1,0)
 Print in$(0,1)
 Print in$(1,1)
End Sub
End


Output:
test1.0
test1.1
atest0
atest1

test0.0
test0.1
test1.0
test1.1


I think it looks good. You just need to pass the first element of the second dimension (here: btest(b$(0,1)). Remember, you're actually only passing the initial addresses!

  javavi said  By the way, would it be good to have a mechanism for assigning references to variables not only when passing names to subroutines and functions, or does it already exist?

I don't understand. Can you give me an example?
Regards
Michael
Edited 2025-04-03 04:01 by twofingers
causality ≠ correlation ≠ coincidence
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 06:02pm 02 Apr 2025
Copy link to clipboard 
Print this post

  Quote  
Printing with "text" to screen could be faster.
Disabling one or the other because its not needed makes it faster


Because "print @" is made for console so it prints to it. But console is bound to the speed in which it is setup.

@twofingers
Have you tried setting the console to "option baudrate 921600" and the same on PC with a usb converter? -..action guaranteed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10008
Posted: 06:43pm 02 Apr 2025
Copy link to clipboard 
Print this post

Here is code that is translated from the C from my playing with the FRAME command - uses a couple of MM. variables that aren't in RC9 but will be in RC10. This should be pretty much all that is needed (perhaps some cursor on/off as well but the idea will be the same, also either line wrap or line truncate for write and writeat)

MM.DISPLAY - tells you if there is a connected physical display VGA/HDMI or TFT
MM.HEIGHT gives the number of characters down the physical display with the current font
MM.WIDTH gives the number of characters across the physical display with the current font

  Quote  Option explicit
setcolour RGB(red),RGB(blue)
clearscreen
writeat 30,24,"Hello World"
'
Sub resize 'Set the serial console to the same size as the screen
Option console serial
Print Chr$(27)+"[8;"+Str$(MM.HEIGHT)+";"+Str$(MM.WIDTH+1)+"t";
Option console both
End Sub
'
Sub cursor x%,y% ' move the cursor to the x%,y% character positions (not pixel)
Option console serial
Print Chr$(27)+"["+Str$(y%+1)+";"+Str$(x%+1)+"H";
If MM.DISPLAY Then
 Print @(x%*MM.FONTWIDTH,y%*MM.FONTHEIGHT)"";
EndIf
Option console both
End Sub
'
Sub writeat x%,y%,t$ 'write text at the character position specified
Option console serial
Print Chr$(27)+"["+Str$(y%+1)+";"+Str$(x%+1)+"H"+t$;
If MM.DISPLAY Then
 Text x%*MM.FONTWIDTH,y%*MM.FONTHEIGHT,t$
EndIf
Option console both
End Sub
'
Sub write t$ 'write text at the current cursor position
Option console serial
Print t$;
If MM.DISPLAY Then
 Text MM.HPOS*MM.FONTWIDTH,MM.VPOS*MM.FONTHEIGHT,t$
EndIf
Option console both
End Sub
'
Sub setcolour f%, b% ' set the colour of both the screen and the console
Local integer fr=f%>>16,br=b%>>16,fg=(f%>>8) And &HFF,bg=(b%>>8) And &HFF,fb=f%
And &HFF,bb=b% And &HFF
Option console serial
Print Chr$(27)+"[38;2;"+Str$(fr)+";"+Str$(fg)+";"+Str$(fb)+"m";
Print Chr$(27)+"[48;2;"+Str$(br)+";"+Str$(bg)+";"+Str$(bb)+"m";
Option console both
Colour f%,b%
End Sub
'
Sub clearscreen 'clear both the display and the console
Option console serial
Print Chr$(27)+"[7"+Chr$(27)+"[2J"+Chr$(27)+"[H";
If MM.DISPLAY Then
CLS
EndIf
Option console both
End Sub
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 436
Posted: 06:59pm 02 Apr 2025
Copy link to clipboard 
Print this post

  twofingers said  I think it looks good. You just need to pass the first element of the second dimension (here: btest(b$(0,1)). Remember, you're actually only passing the initial addresses!

Yes, it looks impressive!
But the SORT command I use doesn't accept this, it only needs a one-dimensional array.
Dim string A$(1,1)=("D","C","B","A")
Sort A$()
Error : Invalid variable


  twofingers said  I don't understand. Can you give me an example?

For example, I need in the program to make a choice at the beginning which variable to use and assign a reference to it, and then the algorithm would work with this reference.
As is now possible when passing the variable name to the subroutine.
But sometimes I need such a reference to the selected variable in the program body.
Edited 2025-04-03 05:09 by javavi
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 09:53pm 02 Apr 2025
Copy link to clipboard 
Print this post

  matherp said  Here is code that is translated from the C from my playing with the FRAME command


Many thanks!
 
BarryH

Newbie

Joined: 05/01/2025
Location: Australia
Posts: 9
Posted: 10:35am 03 Apr 2025
Copy link to clipboard 
Print this post

@twofingers
I'm struggling to understand what is happening in this piece of code.
Could you please explain the mechanics (how/why) of it in more detail - eli5
thanks

> list
Dim a$(1)=("atest0","atest1")
Dim b$(1,1)=("test0.0","test0.1","test1.0","test1.1")
btest(b$(0,1))
Print
btest(b$(0,0))
Print
End

Sub btest(in$())
 Print in$(0,0)
 Print in$(1,0)
 Print in$(0,1)
 Print in$(1,1)
End Sub
End


Output:
test1.0
test1.1
atest0
atest1

test0.0
test0.1
test1.0
test1.1


  Quote  You just need to pass the first element of the second dimension (here: btest(b$(0,1)). Remember, you're actually only passing the initial addresses!

BarryH
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1520
Posted: 11:06am 03 Apr 2025
Copy link to clipboard 
Print this post

Hi Vadim, hi Barry,
forget it! I've checked again. There doesn't seem to be a "legal" and clean way to pass a partial array. Perhaps Peter can change that someday. A string array copy and a string array reset would also be good and useful. So far, the only ways I've come up with for deleting a string array are re-dimensioning (Erase/Dim) or a looping solution.
Regards
Michael
causality ≠ correlation ≠ coincidence
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 11:27am 03 Apr 2025
Copy link to clipboard 
Print this post

  Quote  
I'm struggling to understand what is happening in this piece of code.


maybe with this line:

Dim b$(1,1)=("test0.0","test0.1","test1.0","test1.1")

This initializes and fills a 2 dimensional array b$() with 2 elements for column and row
Array numbering starts with 0  

In the brackets are listed values for all elements of row 0 AND THEN all elements of row 1 and so on.
Number of elements given in brackets must exactly match the definition of the array with the dim statement.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7471
Posted: 11:32am 03 Apr 2025
Copy link to clipboard 
Print this post

Just a thought...
You know the address of the array. Why not overwrite its header to set its dimensions to zero? You could probably do all sorts of strange things like this.
Mick

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

Joined: 02/06/2014
Location: Germany
Posts: 1520
Posted: 11:39am 03 Apr 2025
Copy link to clipboard 
Print this post

  Mixtel90 said  Just a thought...
You know the address of the array. Why not overwrite its header to set its dimensions to zero? You could probably do all sorts of strange things like this.

Hi Mick,
  Quote  ... There doesn't seem to be a "legal" and clean way to pass a partial array. ...


Regards
MIchael
causality ≠ correlation ≠ coincidence
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 12:04pm 03 Apr 2025
Copy link to clipboard 
Print this post

  Quote  
I'm struggling to understand what is happening in this piece of code.


One would call it a feature others would call it a bug


edit:
If it is used as intended, it works and is an enrichment
Edited 2025-04-03 22:17 by dddns
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1121
Posted: 09:51pm 03 Apr 2025
Copy link to clipboard 
Print this post

MATH SLICE and MATH INSERT can copy single array dimensions out of/in to multi-dimension arrays.
Visit Vegipete's *Mite Library for cool programs.
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1520
Posted: 09:11am 04 Apr 2025
Copy link to clipboard 
Print this post

  vegipete said  MATH SLICE and MATH INSERT can copy single array dimensions out of/in to multi-dimension arrays.

Hi Pete, this is about string arrays. Can you tell us how this works for string arrays?
It's also about passing part of a two-dimensional string array to a subroutine.

This works:

Dim A$(200)
sub dosomething (a$())
sort a$()
...
...
etc.
end sub


We want to find a way to make this work:
Dim A$(200,1)
sub dosomething (a$(,1))'Pass only the second part of the array
end sub


And all this without any contortions or slow copying in loops.
This isn't about the functionality of the program; it works without this (to pass a partial array); it's more about saving memory, speed, aesthetics, and elegance!

Regards
Michael
causality ≠ correlation ≠ coincidence
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10008
Posted: 09:25am 04 Apr 2025
Copy link to clipboard 
Print this post

  Quote   Can you tell us how this works for string arrays?


It doesn't. The clues in the command name "MATH" == numbers
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 215
Posted: 09:37am 04 Apr 2025
Copy link to clipboard 
Print this post

  Quote   it's more about saving memory, speed, aesthetics, and elegance!


Memory is the point for me. But I think it could look elegant as well, two use a pair of single dimension arrays.
I'm not sure but I cannot imagine that this will ever work due to the internal management of memory allocated for multi dimensional arrays.
 
     Page 14 of 17    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025