From rev 15
1. Many fixes for bugs from changes from past revisions.
Because of a new faster stack object for group internal struture, two properties are forgotten to implement these functions was broken member$(), member.type$() and Valid(@GroupobjectA as GroupobjectB). So now these fixed.
global group e {
long alfa=50
dim k%(10)
}
for i=1 to group.count(e) {
Print member$(e, i),member.type$(e, i)
}
list
2. Minor works in Forms, especial for modals forms (older versions like 8.2 they work pretty good with this example). We can select XX=0 to open all as non modal. A modal window disable the user action to form (forms can show anything, and moved also by software). So from this revision also fixed.
\\ An example of modal show
\\ When we open then msgbox we have 5 modal windows,
\\ one after the other, without stopping the background task
\\ Modal Show (with parameter 1), open window disabling others,
\\ but each level of modal window know which window is for enabling again
\\ until we close them
Global XX=1
Declare Simple(5) form
dim Visible(5)
For i=0 to 4
Method Simple(i), "FontAttr", "Arial Black", 18
With Simple(i), "Visible" as Visible(i)
Layer Simple(i) {
Linespace 30
Window 12, 10000,8000
Cls 1,0
Form 30,20 \\ make 30X20 chars*lines calculating new font size.
Cursor 0,3
Print width, height
Print "01234567890123456789"
}
Next i
function simple.unload {
if XX<>0 then exit
read new index, &cancel
method Simple(index), "Hide"
cancel=true
}
k=0
\\ this is the background task
Thread {
k++
Print k
refresh
} As anything
Function simple.click {
Threads
Read New index
Select Case index
Case 0
{
After 50 {
Method Simple(1), "Show" , XX
Layer { Print "end case 0" }
}
}
Case 1
{
After 50 {
Method Simple(2), "Show" , XX
Layer { Print "end case 1" }
}
}
Case 2
{
After 50 {
Method Simple(3), "Show" , XX
Layer { Print "end case 2" }
}
}
Case 3
{
After 50 {
Method Simple(4), "Show" , XX
Layer { Print "end case 3" }
}
}
Case 4
{
after 500 {
Print Ask("ok")
Layer { Print "end case 4" }
}
}
End Select
Threads
}
thread {
Print visible(0), visible(1),visible(2), visible(3), visible(4)
If visible(0)=0 then thread this erase
refresh
} as main
After 500 {
thread anything interval 50
thread main interval 100
Method Simple(0), "Show", 1
}
wait 1000
A$=Key$
Print "Finish"
Threads Erase
Declare simple() Nothing
Show \\ set focus to M2000 console
3) New Type$(). Rewrite Type$() to handle array and inventory items too. Also we can set a path to inner objects. Some peculiar things with new revision.
group beta {
x$="1000mm"
m=100
}
\\ beta copied here
inventory alfa=1:=(list:=1,2,300:=(1,2,3,3,5,beta), 500:="ok")
dim g()
\\ beta copied here
g()=(100,beta,(1, (list:=1:=beta,2,"z":=(1,200,3,alfa), "s":="string"), "Hello there"), 500@, "ok")
g(1).m*=100
Print g(1).m=10000
link g() to g$()
Print type$(g(2), 1)="Inventory"
Print type$(g(2), 1!)="List" ' show type of inventory (list or queue)
Print type$(g(2), 2)="String", g(2)#val$(2)="Hello there"
Print g$(2)(2)="Hello there" ' using g$() a reference to g()
Print g$(2)(1)("s")="string"
Print g$(2)(1)("z")(3)(1)(500)="ok"
\\ new this also
Print g(2)(1)("z")(3)(1)(300)(5).m=100 ' multiple object opening until a group object
\\ new this also. we can get a pointer from inner group
n->g(2)(1)("z")(3)(1)(300)(5)
Print n=>m=100
n=>m++ ' increment one
Print g(2)(1)("z")(3)(1)(300)(5).m=101
Print g(2)(1)("z")(3)(1)(300)(5).x$="1000mm"
n=>x$="2000mm"
Print g(2)(1)("z")(3)(1)(300)(5).x$="2000mm"
m=g() ' we get a pointer to array ' these are not the same as the group's pointers
\\ stacks, inventories and arrays (not those we make with Dim) are pointers
\\ we can use IS operator to check two of them if show same object
z=list:=100, 150:=m, 200
Print z(150)(2)(1)("z")(3)(1)(300)(5).m=101
\\ using g() we pass a copy
\\ but anything which is a pointer (like a list, or a pointer to array) only pointer copied
\\ groups may have or may haven't pointers. Those with no pointers copied when we get an array copy.
\\ Only arrays with names with parenthesis copied. So here we get a copy of g().
z=list:=100, 150:=g(), 200
g(1).m+=100
Print g(1).m=10100
Print z(150)(2)(1)("z")(3)(1)(300)(5).m=101 ' group has a pointer/ also list is the same
Print z(150)(1).m=10000 ' group copied
n=>m++
Print z(150)(2)(1)("z")(3)(1)(300)(5).m=102
Print g(2)(1)("z")(3)(1)(300)(5).m=102
From rev 14
1) Fix for expression evaluator, from last revision (rev.14).
2) Addition for URL encoding/decoding and parsing (introduced in rev. 14 fixed in rev. 15)
Stack New {
Data "foo://example.com:8042/over/there?name=ferret#nose", "urn:example:animal:ferret:nose"
Data "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt"
Data "http://www.ietf.org/rfc/rfc2396.txt#header1", "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two"
Data "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212"
Data "telnet://192.0.2.16:80/", "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", "ssh://alice@example.com"
Data "https://bob:pass@example.com/place", "http://example.com/?a=1&b=2+2&c=3&c=4&d=%65%6e%63%6F%64%65%64"
a=Array([])
}
function prechar$(a$, b$) {
if a$<>"" then {=quote$(b$+a$)} else ={""}
}
z=each(a)
document s$="["+{
}
While z {
a$=array$(z)
s1$={ "uri": }+quote$(a$)+{,
"authority": }+ quote$(string$(a$ as URLAuthority))+{,
"userInfo": }+ quote$(string$(a$ as URLUserInfo))+{,
"scheme": }+quote$(string$(a$ as URLScheme))+{,
"hostname": }+quote$(string$(a$ as UrlHost))+{,
"Port": }+quote$(string$(a$ as UrlPort))+{,
"pathname": }+quote$(string$(a$ as UrlPath))+{,
"search": }+prechar$(string$(a$ as URLpart 6),"?")+{,
"hash": }+prechar$(string$(a$ as UrlFragment),"#")+{
}
s$=" {"+{
}+s1$+" }"
if z^<len(a)-1 then s$=" ," ' append to document
s$={
}
}
s$="]"
Report s$
Ouput:
[
{
"uri": "foo://example.com:8042/over/there?name=ferret#nose",
"authority": "example.com:8042",
"userInfo": "",
"scheme": "foo",
"hostname": "example.com",
"Port": "8042",
"pathname": "/over/there",
"search": "?name=ferret",
"hash": "#nose"
} ,
{
"uri": "urn:example:animal:ferret:nose",
"authority": "",
"userInfo": "",
"scheme": "urn",
"hostname": "",
"Port": "",
"pathname": "example:animal:ferret:nose",
"search": "",
"hash": ""
} ,
{
"uri": "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true",
"authority": "",
"userInfo": "",
"scheme": "jdbc",
"hostname": "",
"Port": "",
"pathname": "mysql://test_user:ouupppssss@localhost:3306/sakila",
"search": "?profileSQL=true",
"hash": ""
} ,
{
"uri": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
"authority": "ftp.is.co.za",
"userInfo": "",
"scheme": "ftp",
"hostname": "ftp.is.co.za",
"Port": "21",
"pathname": "/rfc/rfc1808.txt",
"search": "",
"hash": ""
} ,
{
"uri": "http://www.ietf.org/rfc/rfc2396.txt#header1",
"authority": "www.ietf.org",
"userInfo": "",
"scheme": "http",
"hostname": "www.ietf.org",
"Port": "80",
"pathname": "/rfc/rfc2396.txt",
"search": "",
"hash": "#header1"
} ,
{
"uri": "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two",
"authority": "2001:db8::7",
"userInfo": "",
"scheme": "ldap",
"hostname": "2001:db8::7",
"Port": "389",
"pathname": "/c=GB",
"search": "?objectClass=one&objectClass=two",
"hash": ""
} ,
{
"uri": "mailto:John.Doe@example.com",
"authority": "",
"userInfo": "",
"scheme": "mailto",
"hostname": "",
"Port": "",
"pathname": "John.Doe@example.com",
"search": "",
"hash": ""
} ,
{
"uri": "news:comp.infosystems.www.servers.unix",
"authority": "",
"userInfo": "",
"scheme": "news",
"hostname": "",
"Port": "",
"pathname": "comp.infosystems.www.servers.unix",
"search": "",
"hash": ""
} ,
{
"uri": "tel:+1-816-555-1212",
"authority": "",
"userInfo": "",
"scheme": "tel",
"hostname": "",
"Port": "",
"pathname": "+1-816-555-1212",
"search": "",
"hash": ""
} ,
{
"uri": "telnet://192.0.2.16:80/",
"authority": "192.0.2.16:80",
"userInfo": "",
"scheme": "telnet",
"hostname": "192.0.2.16",
"Port": "80",
"pathname": "",
"search": "",
"hash": ""
} ,
{
"uri": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
"authority": "",
"userInfo": "",
"scheme": "urn",
"hostname": "",
"Port": "",
"pathname": "oasis:names:specification:docbook:dtd:xml:4.1.2",
"search": "",
"hash": ""
} ,
{
"uri": "ssh://alice@example.com",
"authority": "alice@example.com",
"userInfo": "alice",
"scheme": "ssh",
"hostname": "example.com",
"Port": "",
"pathname": "",
"search": "",
"hash": ""
} ,
{
"uri": "https://bob:pass@example.com/place",
"authority": "bob:pass@example.com",
"userInfo": "bob:pass",
"scheme": "https",
"hostname": "example.com",
"Port": "443",
"pathname": "/place",
"search": "",
"hash": ""
} ,
{
"uri": "http://example.com/?a=1&b=2+2&c=3&c=4&d=%65%6e%63%6F%64%65%64",
"authority": "example.com",
"userInfo": "",
"scheme": "http",
"hostname": "example.com",
"Port": "80",
"pathname": "/",
"search": "?a=1&b=2+2&c=3&c=4&d=%65%6e%63%6F%64%65%64",
"hash": ""
}
]