|
Forum Index : Microcontroller and PC projects : PicoMite V6.02.00 release candidates - Structured types
| Author | Message | ||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 5599 |
![]() PicomiteVGA PETSCII ROBOTS |
||||
| Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 5599 |
deleted Edited 2026-01-09 00:46 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3540 |
Considering this program which uses STRUCT SORT and STRUCT(FIND ...), it appears that STRUCT(FIND ...) will return the first instance of the found value. Is that the case? Is a binary search used and then backing up to find the first instance? Type indx Recnum As string length 4 KeyVal As string length 2 End Type Dim KeyRec(15) As indx Dim integer i,j,k,l,m,n Dim string States(4)=("PA","VA","MA","CA","WA") For i=0 To 9 KeyRec(i).Recnum=Format$(i,"%4g") KeyRec(i).KeyVal=States(Int(Math(RAND)*5)) Next i Struct sort KeyRec.KeyVal,4 For i=0 To 9 Print Str$(i+1)+" "+KeyRec(i).Recnum+" "+KeyRec(i).KeyVal Next i Print "" i=Struct(find KeyRec().KeyVal,"PA") If i<>-1 Then Do While KeyRec(i).KeyVal="PA" Print KeyRec(i).Recnum+" "+KeyRec(i).KeyVal i=i+1 Loop EndIf > RUN 1 8 CA 2 4 CA 3 2 MA 4 6 MA 5 1 PA 6 3 PA 7 5 PA 8 0 PA 9 9 VA 10 7 WA 1 PA 3 PA 5 PA 0 PA > RUN 1 0 CA 2 9 CA 3 6 CA 4 5 CA 5 4 MA 6 7 MA 7 8 PA 8 2 VA 9 3 WA 10 1 WA 8 PA > RUN 1 6 CA 2 5 CA 3 7 CA 4 0 MA 5 4 MA 6 8 MA 7 3 PA 8 2 PA 9 1 WA 10 9 WA 3 PA 2 PA > PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10828 |
Linear search but remember find has an optional start parameter that allows you to iterate through the matches. Doesn't require sorting Type indx Recnum As string length 4 KeyVal As string length 2 End Type Dim KeyRec(15) As indx Dim integer i,j,k,l,m,n Dim string States(4)=("PA","VA","MA","CA","WA") For i=0 To 9 KeyRec(i).Recnum=Format$(i,"%4g") KeyRec(i).KeyVal=States(Int(Math(RAND)*5)) Next i 'Struct sort KeyRec.KeyVal,4 For i=0 To 9 Print Str$(i+1)+" "+KeyRec(i).Recnum+" "+KeyRec(i).KeyVal Next i Print "" i=0 Do i=Struct(find KeyRec().KeyVal,"PA",i) If (i<>-1) Then Print KeyRec(i).Recnum+" "+KeyRec(i).KeyVal Inc i EndIf Loop Until i=-1 Edited 2026-01-09 01:50 by matherp |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3540 |
Ok, thanks. With my version, including sort, .69ms with 4 "PA" instances. Your version, .68ms with 4 "PA" instances (.32ms with only one). I wonder how they will compare with larger arrays, e.g., 500 records. This is a terrific new feature, very fully implemented. Thanks for all you do. With 500 records, my version 11.704, your version 12.245ms (may depend on how many instance of "PA" there were in each run. ~ Edited 2026-01-09 01:55 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10828 |
The final release will also have the option to use a regular expression as the search term same as instr. This will, in the same way, use an extra parameter "size" to indicate the term is a regular expression. i=Struct(find KeyRec().KeyVal,"^[Pp].$",i,size) Edited 2026-01-09 01:56 by matherp |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3540 |
While continuing work on structures; any idea why this might be and how fixed? > xmodem s Error : Not enough Heap memory > memory Program: 7K ( 2%) Program (265 lines) 309K (98%) Free Saved Variables: 16K (100%) Free RAM: 0K ( 0%) 0 Variables 3K ( 0%) General 360K (100%) Free > I reloaded the program and XMODEM S worked. ~ Edited 2026-01-09 02:18 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10828 |
What version? This should be fixed in the later RC |
||||
| lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3540 |
Ah, PicoMite MMBasic RP2350A V6.02.00RC0. I've got to catch up. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
| JanVolk Senior Member Joined: 28/01/2023 Location: NetherlandsPosts: 282 |
Test PicoMiteHDMI MMBasic USB RP2350A Edition V6.02.00RC3 When I first go to EDIT, the color scheme on the bottom two lines is incorrect on the HDMI output. It is correct with TeraTerm. Pressing PgDn once resets it to the correct color scheme on the HDMI output. Another small observation: after playing a game like BLOCKS, the audio tape speed is sometimes incorrect (too slow) and returns to normal after a hard reset. I need to investigate further why this occurs. It's certainly the case with the PicoMiteHDMI MMBasic USB RP2350A Edition V6.02.00RC0. Perhaps this has happened to one of you as well? > option list PicoMiteHDMI MMBasic USB RP2350A Edition V6.02.00RC0 OPTION SERIAL CONSOLE COM1,GP0,GP1 OPTION SYSTEM I2C GP20,GP21 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION DEFAULT COLOURS GREEN, BLACK OPTION MOUSE SENSITIVITY 1.0000 OPTION KEYBOARD US OPTION HEARTBEAT OFF OPTION RESOLUTION 640x480 @ 252000KHz OPTION DEFAULT MODE 2 OPTION DISPLAY 30, 53 OPTION HDMI PINS 1, 3, 7, 5 OPTION SDCARD GP22, GP6, GP7, GP4 OPTION AUDIO I2S GP2,GP5', ON PWM CHANNEL 11 OPTION RTC AUTO ENABLE OPTION MODBUFF ENABLE 192 OPTION F5 PLAY MP3"b:/mp3-bestand/" OPTION F6 PLAY NEXT OPTION F7 PLAY STOP OPTION F8 FLASH RUN 1 OPTION PLATFORM Olimex HDMI USB I2S OPTION DEFAULT FONT 7, 1 Kind regards, Jan. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10828 |
What resolution and what mode are you in when you type EDIT Yes, I know about this one but had forgotten about it and haven't tracked down what causes it. When you play audio with a lower sample rate it sometimes doesn't reset. If you can let me have the audio track from blocks I can use it to test. What are you doing after blocks that runs slow? Edited 2026-01-09 18:51 by matherp |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |