![]() |
Forum Index : Microcontroller and PC projects : PicoMite V6.00.02 release candidates - all versions
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
I accidentally edited my answer. ![]() causality ≠ correlation ≠ coincidence |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7464 |
Bear in mind how big string arrays tend to get. They can use a lot of RAM. Adding two string arrays to make a third means finding space for all three. You would like some programming space left, wouldn't you? ;) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
Hi Mick, it's not the job of Array ADD to combine two arrays into a third. It's analogous to MATH ADD in(), num ,out() This adds the value 'num' to every element of the matrix in() and puts the answer in out(). Works for arrays of any dimensionality of both integer and float and can convert between. Setting num to 0 is optimised and is a fast way of copying an entire array. in() and out() can be the same array. Array ADD in$(), Str$, out$() should add a string to each element of an array and store it in a new (or the old) array. Additionally, it would be a quick way to copy (STR$=""), delete (?), and fill (?) a string array. Regards Michael causality ≠ correlation ≠ coincidence |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10000 |
I've updated RC18 if you want to download Improves error detection in MID$ command Improves error detection in INC command when using strings Adds new command ARRAY ADD in(), data, out() Supports integers, floats AND strings |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
Peter, you scare me! ![]() ![]() ![]() Thanks a lot! causality ≠ correlation ≠ coincidence |
||||
electricat![]() Senior Member ![]() Joined: 30/11/2020 Location: LithuaniaPosts: 288 |
HDMI/USB/2350 RC17 @Peter, Did not tested latest RC18 but as I found it in EDITOR it might be still here.Try this to replicate: Inside editor type in any text. But at least one underscore '_' must be used. asadasfsd_asdasasf Now move using left or right arrows but you must pass that underscore '_' and you`ll notice underscore just dissapears. With more underscores even more fun effect It`s only visual thing, does not saves F1. Restores on screen redraws etc. My MMBasic 'sand box' |
||||
bfwolf Regular Member ![]() Joined: 03/01/2025 Location: GermanyPosts: 68 |
Passing an array by reference to a subroutine works. This allows you to switch between arrays without having to copy the elements. Same for simple variables. This would eliminate the need for an "ALIAS": Option Explicit Sub AddArrVal(byref arr%() As integer) Local i As integer For i=1 To Bound(arr%()) arr%(i) = arr%(i) + 3 Next End Sub Dim MyArr%(10) As integer Dim MyAr2%(10) As integer Dim i% As integer For i=1 To Bound(MyArr%()) MyArr%(i) = i Next For i=1 To Bound(MyAr2%()) MyAr2%(i) = i + 2 Next AddArrVal(MyArr%()) AddArrVal(MyAr2%()) Print "Works as expected:" For i=1 To Bound(MyArr%()) Print MyArr%(i), Next For i=1 To Bound(MyAr2%()) Print MyAr2%(i), Next Print "Fails as expected:" Dim MyA2%(10,10) As integer AddArrVal(MyA2%(1,)) End Saved 596 bytes > run Works as expected: 4 5 6 7 8 9 10 11 12 13 6 7 8 9 10 11 12 13 14 15 Fails as expected: [34] AddArrVal(MyA2%(1,)) Error : Dimensions > @Peter, Question: Wouldn't an array anyway have been passed implicitly "byref," so that the "byref" could be omitted? Of course, it's clearer and cleaner to enforce "byref" explicitly! And to be clear: I don't expect that a multidimensional array, e.g. MyA2%(10,10), can be passed as a one-dimensional array (vector) by writing MyA2%(1,) (i.e., leaving the last index empty) - that was just an idea, because that's how it would work in C - but I expected it to be forbidden and generate an error message! But perhaps MMBasic already has a builtin solution for this? Edited 2025-04-25 21:49 by bfwolf |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
Regards Michael causality ≠ correlation ≠ coincidence |
||||
bfwolf Regular Member ![]() Joined: 03/01/2025 Location: GermanyPosts: 68 |
For the avoidance of doubt - this will never happen Regards Michael Was that referring to my previous post? ![]() Didn't you read my paragraph at the end?: It was pretty clear to me that it doesn't work, and I don't expect it to work (in the future) either! I also read Peter's post, which you quoted again, and I share his opinion. I tried it "just for fun" to see if it might work "accidentally." But I figured out a workaround myself beforehand: ![]() Option Explicit Sub Add2nDimArrVal(byref arr%() As integer, byref ix%() As integer) Local i As integer, nD As Integer = 0, nDims As integer = 0 Local ptr As integer i = 1 Do nD = Bound(arr%(), i) If nD <> 0 Then nDims = nDims + 1 : i = i + 1 EndIf Loop Until nD = 0 'Print nDims For i=1 To Bound(arr%(), nDims) Select Case nDims Case 1 ptr = Peek(VARADDR arr%(i)) Case 2 ptr = Peek(VARADDR arr%(ix%(1), i)) Case 3 ptr = Peek(VARADDR arr%(ix%(1), ix%(2), i)) End Select ' Print ptr, Poke integer ptr, (Peek(integer ptr) + 3) Next End Sub Dim i As integer, j As integer Const MyAD% = 2 ' nDims of MyA2% Dim MyA2%(10,10) As integer Dim MyAI%(MyAD%) As integer Print "Works as hoped: :-D" ' Set index values of all dimensions before last dim: MyAI%(1) = 5 ' : MyAI%(MyAD%) = 0 For j=1 To Bound(MyA2%(),1) For i=1 To Bound(MyA2%(),MyAD%) If j = MyAI%(1) Then MyA2%(j, i) = i + 10 Else MyA2%(j, i) = 0 EndIf Next Next Add2nDimArrVal(MyA2%(), MyAI%()) For i=1 To Bound(MyA2%(),MyAD%) Print MyA2%(MyAI%(1), i), Next End > run Works as hoped: :-D 14 15 16 17 18 19 20 21 22 23 > Regards, bfwolf |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
![]() I was just worried that Peter might get the impression that they wanted to push the topic further. I think Peter put a lot of effort into it. I appreciate your research! I don't have the opportunity to test everything at the moment, but I'm glad that the topic is being approached from different perspectives. Basically, IMHO, Vadim's question (see FileManager thread) was about partially passing partial string arrays to a sub-routine for example, to be able to sort them there. There seems to be agreement that arrays can only be passed by reference, how else? By the way, the first parameter passed to a subroutine is never optional, but the others are. Best regards Michael causality ≠ correlation ≠ coincidence |
||||
bfwolf Regular Member ![]() Joined: 03/01/2025 Location: GermanyPosts: 68 |
Yes, I also know the big work, Peter is investing. And I think, one shouldn't blow up the language too much, if there is no "real need" for new language elements. Basically, IMHO, Vadim's question (see FileManager thread) was about partially passing partial string arrays to a sub-routine for example, to be able to sort them there. Thx! ![]() And by playing with this, I found out, that with "ptr=Peek(VARADDR var)", "val=Peek(<TYPE> ptr)" and "Poke <TYPE> ptr, val" the C pointers can nearly completely substituted.. ![]() Yes! And this should remain, as is. Passing big arrays by value(s) leads to ugly performance and stack overflow danger! Thx again! ![]() Regards, bfwolf Edited 2025-04-26 03:06 by bfwolf |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10000 |
I've just updated RC18 to include the new command ARRAY SET data,array() This works the same as MATH SET (see manual) but also now supports strings e.g. dim s$(9,9) length 20 array set "Whatever", s$() ? s$(8,8) array set "", s$() ? s$(8,8) Together with ARRAY ADD, ARRAY SLICE, and ARRAY INSERT you now have fast commands for doing most likely bulk manipulations with strings. In all cases see the equivalent MATH commands in the manual for details Edited 2025-04-26 18:28 by matherp |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1519 |
I am very happy! Thanks! ![]() Michael causality ≠ correlation ≠ coincidence |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 383 |
Since updating to 6.00.xx, the Del function on my I2C keyboard no longer works. Shift-Del does go to the end of the line but Del by itself doesn't work. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10000 |
Which I2C keyboard? |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 383 |
Which I2C keyboard? The one onboard the PicoCalc. Since Del worked in MMBasic v 5.xx and doesn't in 6.xx I was wondering if there was a change in keyboard handling. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10000 |
Nothing I can help with. The solderparty keyboard which is the supported version works perfectly on V6.00.02RC17 - just tested |
||||
homa![]() Guru ![]() Joined: 05/11/2021 Location: GermanyPosts: 451 |
I'm back from my short holiday. And I'm looking forward to testing again. If there are still so many great additions, will the textbuffer layer be added after all? ![]() |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 383 |
Thanks for checking, anyway. I finally figured out that a typical keyboard returns 0x7f for DEL but the PicoCalc returns 0xd4. It seems like the maker of PicoCalc patched the files to account for that but the people who are continuing the PicoCalc releases didn't |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4244 |
Hi Peter, Not sure what has happened here, but I believe it is a regression: > option list PicoMite MMBasic RP2040 Edition V6.00.02RC18 OPTION SYSTEM SPI GP6,GP3,GP4 OPTION COLOURCODE ON OPTION CPUSPEED (KHz) 252000 OPTION LCDPANEL CONSOLE OPTION DISPLAY 20, 40 OPTION LCDPANEL ILI9341, RLANDSCAPE,GP2,GP1,GP0 OPTION TOUCH GP5,GP7 GUI CALIBRATE 0, 407, 267, 897, 677 OPTION SDCARD GP22 OPTION AUDIO GP20,GP21', ON PWM CHANNEL 2 OPTION MODBUFF ENABLE 192 OPTION PLATFORM Game*Mite > list "wtf.bas" Print de_format$("rtrue") Function de_format$(a$) Local p, s$ s$ = " " p = Len(a$) + 1 Print "'" a$ "'" Print "'" s$ "'" Print p Cat s$, Left$(a$, p - 1) de_format$ = s$ End Function > run "wtf.bas" 'rtrue' ' ' 6 [10] Cat s$, Left$(a$, p - 1) Error : String too long Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |