Three issues: Two bugs fixed and one addition:
1) The #fold() now can take object for initial value.
map=lambda (k, m as array)-> {
append m, (k^2,): push m
}
? (1,2,3,4,5,6)#fold(map, (,))
? (1,2,3,4,5,6)#fold(map, (,))#fold(map, (,))
? (4,5,6)#fold(map, (1,2,3)#fold(map, (,)))#fold(map, (,))
map2stack=lambda -> {
read k, m as stack // we can put the read statement too
stack m {data k^2}: push m
}
? (1,2,3,4,5,6)#fold(map2stack, stack) // no #function for stack
map2list=lambda (k, m as list) ->{
//using (k, m as list) is the same as Read k, m as list
append m, k^2: push m
}
? (1,2,3,4,5,6)#fold(map2list, list) // no #function for list
map2queue=lambda -> {
read k, m as queue // here we place the read statement
append m, k^2: push m
}
? (1,1,3,4,5,6)#fold(map2queue, queue) // no #function for queue
2) The bug here was the Point() as class. The Point() is an internal function (which was buggy, see 3rd issue). If we change the Class Point as Class Point1, and also change module point to module point1, and everywhere we call Point() to return an object, then the bug stayed hidden (from 40 and older revisions). Now is ok. Also see that we can use the internal Point() as @Point()
// point is an internal function.
// We can make a function with same name as an internal one
// We can call the function using @ if exist as internal and non internal
testpoint()
module abc {
class point {
X as integer
class:
module point (a as integer) {
.X<=a
}
}
dim a(10)<<point(random(1, 1000))
m=each(a())
while m
for a(m^) {
? m^, .X
}
end while
testObject()
testpoint()
}
abc
module abc1 {
class point {
X as integer
class:
module point (a as integer) {
.X<=a
}
}
function beta() {
=point(random(1, 1000))
}
dim a(10)<<beta()
m=each(a())
while m
for a(m^) {
? m^, .X
}
end while
// we can call a subroutine like was here
testObject()
// so we have to place @point() for run as internal function
testpoint()
}
abc1
testpoint()
Report @SimpleFunction()
testObject()
end
// this is a simple function
// a simple function can't change code at run time
//An we can pass a simple function by reference
function SimpleFunction()
="We can't use an internal name like Point() for simple function"
end function
sub testObject()
if module(point()) then
local a=point(100): print a.x=100
else
Report "Point() not defined"
end if
end sub
sub testpoint()
local a$
move 0,0
copy 1000, 1000 to a$
print @point(a$, 0,0)
end sub
3) The point() function was not used so there was some bugs and I found them when I solved the previous issue.
This is the 1000 twips X 1000 twips, or 67x67 pixels (when 1 pixel need twipsX=15 and twipsY=15). For 1440 parts of 1 inch, for 96 dpi, we have 1440/96 = 15 twips per pixel.
M2000 return the current dpi using 1440/twipsX (return 96)
The example use the conversion from twips to pixel using the Image.x.pixels() (Image.x() return twips). We know the size of bitmap. The statement Copy has 1000, 1000 the image width and height (but as we see we have 1005X1005 twips, divided by 15 we get 67)
At the end a clipboard a$ send the DIB (a type of bitmap) to clipboard. The a$ is a string which hold some data and the pixels of image. We can get an image using Clipboard.Image$ (or Clipboard.Image to a buffer, a memory buffer, an alternative way to store images)
Cls #005580, 0: move 0, 6000
Pen 14 // yellow
Cursor ! // get the pos, row for characters from graphic cursor
Scroll Split Row
a$=" "
Move 0,0: Copy 1000, 1000 to a$: Print Point(a$, 0, 0)=#005580
// Point return color from graphic cursor
Print Point(a$, 0, 0)=Point, Point=#005580
for i=0 to Image.x.pixels(a$)-1: old=Point(a$, i, i, #FF5580):next
Print old=Point, old=#005580, Point(a$, 0, 0)=#ff5580
Move 0,0 : image a$, 6000 // make the image X6
move 3000, 1000: image a$ // original size
clipboard a$ // send bitmap no text (read first bytes to decide)
wait 100
b$=clipboard.image$
Print image.x(b$)=1005, " type:"+type$(b$) // String
wait 200
k=clipboard.image
Print image.x(k)=1005, " type:"+type$(k) // Buffer