Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:12 01 Jan 2026 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 : <img border=

Author Message
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 515
Posted: 12:00pm 30 Dec 2025
Copy link to clipboard 
Print this post


> option list
PicoMite MMBasic RP2040 V6.01.00
OPTION COLOURCODE ON
OPTION CONTINUATION LINES ON
OPTION CPUSPEED (KHz) 200000
OPTION DISPLAY 40, 80
> list
Dim integer s(9)=(1,2,3,4,5,6,7,8,9,10), t(9)
Array Insert t(),s()
> run
[2] Array Insert t(),s()
Error : Argument count
>

Question: What is the easiest way to copy one array into another? Without using a loop!
Direct assignment is unfortunately not possible: t()=s()
“Array Insert” is only for multidimensional arrays?!
Or am I missing something here? “Array Insert t(), ,s()” doesn't work either.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10768
Posted: 12:06pm 30 Dec 2025
Copy link to clipboard 
Print this post

manual page 139
  Quote  MATH SCALE in(), scale,out()
This scales the matrix in() by the scalar scale and puts the answer in out().
Works for arrays of any dimensionality of both integer and float and can
convert between. Setting b to 1 is optimised and is the fastest way of copying
an entire array.
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 515
Posted: 12:15pm 30 Dec 2025
Copy link to clipboard 
Print this post

Thanks, works! I hadn't even considered MATH ...
Read it right away :-)
 
bfwolf
Senior Member

Joined: 03/01/2025
Location: Germany
Posts: 103
Posted: 04:38pm 30 Dec 2025
Copy link to clipboard 
Print this post

Found an other way in the manual (but didn't try):
  Quote  ARRAY ADD in(),value,out()

This adds (or appends for strings) the value 'value' to every element of the
matrix in() and puts the answer in out(). Works for arrays of any
dimensionality of strings and both integer and float (can convert between
integer and float). Setting num to 0 or “” is optimised and is a fast way of
copying an entire array.
in() and out() can be the same array.


This is also "more obvious" because it is also an 'ARRAY' command.
So @homa: You looked just 1 "table line" too far down..
Edited 2025-12-31 02:38 by bfwolf
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 515
Posted: 11:17pm 30 Dec 2025
Copy link to clipboard 
Print this post

Sometimes examples are more helpful than reading manuals!
@bfwolf Further exciting findings:

> list
Dim integer s(9)=(5,1,3,4,7,7,3,0,0,1),t(9)
Dim integer x,i
Math v_print s()
x=Math(max s(),i)
Print x,i
Array Add s(),0,t()
Math v_print t()
Array Add s(),-1,t()
Math v_print t()
Array Set 0,t()
Math v_print t()
Math scale s(),1,t()
Math v_print t()
Math scale s(),2,t()
Math v_print t()
> run
5, 1, 3, 4, 7, 7, 3, 0, 0, 1
7       4
5, 1, 3, 4, 7, 7, 3, 0, 0, 1
4, 0, 2, 3, 6, 6, 2, -1, -1, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
5, 1, 3, 4, 7, 7, 3, 0, 0, 1
10, 2, 6, 8, 14, 14, 6, 0, 0, 2
>
 
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 2026