Κυριακή 13 Ιανουαρίου 2019

Revision 28 Version 9.6

Many new things, plus some changes for compatibility issues.

All read only variables (M2000 identifiers) can be used as variables when defined with DEF statement (which make local variables, one time only - raise error in second pass).

We can change all internal functions with custom (also the change work for specific module/function)

\\ Def can be use one time for each identifier, in a module or function
\\ Inkey$ is read only variable (read keyboard)
Def Inkey$="?", memory=100
\\ Print is a statement
Print=10

\\ we can use @ to access original
Print++
@Print Print, inkey$, memory
While @inkey$="" {
      @Print inkey$,
}
\\ we can use Print, without operator, so Interpreter call the statement
Print
Print "ok", @memory
Print cos(45)
Def cos(x)=cos(round(x*180/pi))
Print cos(pi/4)


Functions we can change using standard definition Function {} and Lambda definition. In the code bellow we have Print as variable too. (statements can be change except for some identifiers which used for flow control)

time$=lambda$ (x)->str$(x,"hh:nn:ss")
Print time$(now)
Print=100
function kappa {
      list
      Print time$(now), Print
}
Call local kappa()
Print time$(now)


Update for Math internal library (is a com object, inside M2000, which provide methods for advance maths). I have to make a separate post for this.
a=(-1,-0.8660254, -0.7071068, -0.5, 0, 0.5, 0.7071068, 0.8660254,1)
b=(pi, 5*pi/6, 3*pi/4, 2*pi/3, pi/2, pi/3, pi/4, pi/6, 0 )
declare math math
z=each(a)
f=each(b)
while z, f
      method math, "ArcCos", array(z) as ret
      Print Type$(ret), ret, Round(array(f),13)
      method math, "ACos", array(z) as ret1
      Print Type$(ret1), ret1, Round(array(f),13)
End While

method math, "cos", pi/4 as ret
Print ret

Declare math nothing

' we can omit Declare Nothing, because at the end of module execution. variables dereferenced automatic.

Info about Objects for user:

There is also an Application object which we can pass to another script language for calling back:
Declare M2000 application
Print type$(M2000)
global z=100
Method M2000, "eval", "12*45+z" as k
Print k=640


Using Declare M2000Form application form we can get the console Form as an object. Also hWnd is a read only variable which return the window handler for current layer (Layers are the console layer (a named DIS, as a picturebox in main Form, the background - is the main form, plus 32 layers above DIS, used as players or separate consoles inside Form, plus a layer for each User Form (window)).



There is also a Mutex internal object which works for all instances of M2000 Interpreter (is a proper mutex). Run twice Interpreter and place this script in each one to a module say A. Run one and don't press yet any key. Now run the same script to other instance, and we see that the Try block exit, with no code execution. When the first finished, the second can take ownership of mutex.

Declare M Mutex
try {
      Method M, "CREATE", "ALFA"
      Print "Do Something"
      a$=key$
      Print "Done"
      Method M, "DESTROY", "ALFA"
}


Last is the OSINFO

Declare OsInfo INFORMATION
With OsInfo, "OSName" as Osname$, "Edition" as Editon$
Print Osname$, Editon$
Print Type$(OsInfo)
Declare OsInfo Nothing


We can use other libraries, like the vbRichClient5. Here we create a basic window, a toolbox, and when we click on basic window we get 5 modal windows (the last one on top of others). We can receive Form1 as an object WithEvents. So interpreter make the proper object for callback, and link it to this specific module (say module A). Here the com events connected to functions which have a "_eventname" postfix. These are not exactly functions. They are called in the same namespace as the module (say A), but in another "execution object" (so this object may have own static variables, and a new stack for values in each call). So from these event routines we have same scope as the Module. All arguments are passed by reference here. We can't make a reference twice, so we make new variables. When the event service function end, erase all new variables/functions/modules.

When we click on basic form 6 threrads start with After statement. Each one make a new form and event object (sink), which call the same event handler. Threads are part of module where defined, and never erase anything they do. May have own static variables and also they have own stack of values.

We don't use the provided EnterMessageLoop, but a main.task thread, which check the window handler of main Form1 (of vbRichClient5), if become zero, to exit.

When we move a window from this library, threads paused for little time. (this not happen with M2000 user forms), but it is the same with the Visual Basic forms. To bypass this problem, M2000 forms are bare VB6 forms with simulated headers, so we can move any window using internal code, which not block execution of threads.

Έγιναν διοθρώσεις στις FormΧ_Move όπου Χ 1, 2, 3. Στις νεότερες εκδόσεις του διερμηνευτή δεν διαβάζουμε με αναφορά & (πχ &Χ, &Υ) εκεί που στέλνει ByValue το γεγονός Move.


clear
Title
Declare AppForm Application Form
Declare New_c "{CAECC935-9C70-4176-8BED-C39B2E33B31F}"
Method New_c, "Cairo" as Cairo
With Cairo, "WidgetForms" as Cairo.WidgetForms
Method Cairo.WidgetForms, "Create", 1,"My Main-Form Caption, Click Me!" withevents as Form1

Print type$(Form1)
vbYellow=65535
vbRed=255
vbFixedDialog=3
vbSizableToolWindow=5

Print Type$(Form1)
With Form1, "WidgetRoot" as Form1.WidgetRoot, "visible" as visible
Print type$(Form1.WidgetRoot)
With Form1, "hWnd" as Form1.hWnd
With Form1.WidgetRoot, "BackColor", vbYellow
          
Method Cairo.WidgetForms, "Create", vbSizableToolWindow, "MyToolWindow - Resize Me!", -1, 800, 600 withevents as Form3
Method Form3,"SetMinMaxDimensions", 200, 400, 300, 600
With Form3, "visible" as Form3.visible
\\Form3.visible=true

mClicks=0
\\ events use underscore for event name
Function Form2_Click {
      Drop
      Read new form111
      mClicks++
      With form111, "Caption", "Click-Count so far:" +Str$(mClicks)+str$(appvisible)
}
Function Form1_Move {
      Read New X, Y
      Print "Form1", X, Y
      refresh
}
Function Form2_Move {
      Read New X, Y
      drop
      Read new form111
      Print "Form2", X, Y
      If X<100 then With form111, "left", 100
      refresh ' console form
}
Function Form3_Click {
      appvisible=not appvisible
}
Function Form3_Move {
      Read New X, Y
      Print "Form3", X, Y
      If X<100 then After 20 {With Form3, "left", 100}
      refresh
}
Function Form1_Click {
      Refresh
      \\ After start a new thread after 100 msec, and run once
      for i=1 to 6 {
      After 100 {
            Report "First we show a modal Dialog-Window, and count the Clicks on it"
            Method Cairo.WidgetForms, "Create", vbFixedDialog,"MyDialog ... Click Me!",-1 , 800, 600 withevents as new Form2
            With Form2, "WidgetRoot" as new Form2.WidgetRoot
            With Form2.WidgetRoot, "BackColor", vbRed
            Refresh
            Method Form2 "Show", 1
            Refresh
            Report format$("The Dialog was clicked {0} times.", mClicks)
            Report {Now we show a non-modal ToolWindow, which remains in the ForeGround of this Form
                              and will close itself automatically, when the MainForm is destroyed
                              }
            Print
            refresh
            Declare Form2.WidgetRoot Nothing
            Declare Form2 Nothing
      }      
      }
     
}
Thread {
try {
      If pos>0 then print
      Print now, visible
      }
      refresh
} as alfa interval 100
Print Visible
With AppForm, "visible" as appvisible
Method Form1, "Show", 0, AppForm
Method Form3, "Show", 0, Form1
Method Form1, "move", 100,100
Method Form3, "move", 100,100
appvisible=false
Print Visible
\\\  not used here Method Cairo.WidgetForms, "EnterMessageLoop"
Task.Main 100 {
      if Form1.hWnd else exit
}
aaa:
Threads erase
Declare Form1.WidgetRoot Nothing
Declare form1 nothing
Declare form3 nothing
Declare cairo nothing
declare New_c nothing
Show  \\ to get focus to M2000 console



We can use all of them, but there is a little of documentation (the code also is hidden).

Declare cCircleBreaker "{3F339D70-6FDD-4154-A826-64CE7A1BD04F}"
Declare cCollection "{7B758397-89C0-4A5B-882C-7B28A1C853E8}"
Declare cConstructor "{CAECC935-9C70-4176-8BED-C39B2E33B31F}"
Declare cCrypt "{49BC4DC6-30ED-49FD-BFA0-D170193E429C}"
Declare cColumn "{0AFA29AF-5F0D-44F1-A752-8DC60ACEB5F7}"
Declare cColumns "{C1A40FD6-0E0C-4A4D-970F-263695E6F5D4}"
Declare cCommand "{FE8E8CBC-C76D-40D8-8D5C-E650AA1CB605}"
Declare cConnection "{E71C0E12-8F07-40DF-87E9-82775B8E22B9}"
Declare cConverter "{DF0B681D-50B8-4472-BDDE-F5FE31AC12A1}"
Declare cDataBase "{6A7B007F-155D-4D03-AE1C-B94B05999AA1}"
Declare cDataBases "{DC66459A-451A-4009-B427-2E8C83E851E3}"
Declare cField "{FCBE2214-A97C-4C28-86F6-FB0204D563A8}"
Declare cFields "{C1FF048D-5EFC-4271-B980-074707545A3F}"
Declare cIndex "{3B7B9A04-966A-431E-A76F-E395B8BD0396}"
Declare cIndexes "{E9B4BDF1-2DDA-4297-BF30-08CB972BF385}"
Declare cRecordset "{1305534D-72BC-4D88-9C24-14FAC8327C01}"
Declare cSelectCommand "{EB40DF58-4744-422F-96FB-859C5965555B}"
Declare cTable "{C686653C-BBFB-4D35-8D59-69768BB91CA5}"
Declare cTables "{FFE55F10-1038-477E-86B7-A689F2B820B3}"
Declare cTrigger "{68764D8F-85A8-4D87-93DA-26C0EA6CD152}"
Declare cTriggers "{325D6C3E-47DF-4EA1-AB25-BDEE27342C18}"
Declare cUDFMethods "{EBFAB5EE-FF4C-45A6-A4ED-5117E7B1A476}"
Declare cView "{9952FE48-3E48-4C2B-911C-848B891242BD}"
Declare cViews "{FE607306-510C-43E5-BB3F-5F7EE4C717B6}"
Declare IAggregateFunction "{757D29C3-8013-448B-9979-551795C60D86}"
Declare ICollation "{D678B30E-263D-4319-AD6D-2A8A793EA7CB}"
Declare IFunction "{53FF9E24-A6D1-4820-AEAF-38E833CC045D}"
Declare cEventCollection "{9D1E2F62-1B8E-4EDE-9271-74B08080336A}"
Declare cEventInfo "{128422D8-766A-4364-9380-8405CD08D784}"
Declare cFactory "{EEAE345B-9984-4988-A6AA-5D26BE59BC44}"
Declare cFormula "{BD5574F6-32D3-4A21-B05D-0F4A5415EBF1}"
Declare cRegFree "{81C8A908-B73F-49B0-85A3-02FC27F13716}"
Declare cSortedDictionary "{A184203F-2F23-409D-9F26-5FA5545D17C3}"
Declare cStringCompare "{443CDB58-13DB-473C-90D2-97FA54289CB2}"
Declare cTimer "{E4C7EFC7-DE20-440D-A579-5AF869A57A56}"
Declare cDC "{6D6BE2EC-14C0-4A06-8DB4-2F8A8E414C0C}"
Declare cDDB "{C991EE4F-79A4-4330-B8D7-9723299880FA}"
Declare cDIB "{ED2FAAFE-4A62-4BF3-B749-1CA15B332507}"
Declare cReportDocument "{A7477B63-093A-4861-9AF1-E98316CF8BC1}"
Declare cReportPage "{C846FFC3-BA85-42B9-9140-28F5904098F1}"
Declare cTCPClient "{C483925C-9E12-4027-A883-878EB8D0B3E5}"
Declare cTCPServer "{6BCAD532-4455-49ED-B983-DDAA4CD27BD6}"
Declare cUDP "{8358D2C3-2793-495C-983C-AD4E08E36E2E}"
Declare cOOActionApproval "{0D30901B-11BC-46AD-8E31-E261A0860E48}"
Declare cOOEmbed "{7D470B35-068E-48D4-A339-B7FEFFE0D6C9}"
Declare cOOEventListener "{18ADB502-0D9A-404C-B33E-BD10E4E4CA72}"
Declare cDBAccess "{AD1D461D-3950-40ED-875D-456EBF0A1B72}"
Declare cRPCClientInfo "{8CEC5219-01FC-4438-885B-20FA5DF42FC8}"
Declare cRPCConnection "{40BE39F8-38C3-4231-A097-0D041DBF33E4}"
Declare cRPCListener "{AC3DE4F0-94D6-414A-AF8F-9FF489D1890E}"
Declare cRPCListenerThread "{B16C3CA9-3325-492B-A8E7-62021824F97D}"
Declare cRPCStatusInfo "{48F71BDB-AE56-46E5-91A2-BCCAA4E15D8C}"
Declare cServerCommands "{47EC871A-2755-4F15-9F58-E4EBABD7D322}"
Declare cThreadHandler "{141036DB-64B2-4797-9856-6E6B71729FB8}"
Declare cThreadInit "{656DD8F8-2ACB-4948-994F-072A90336066}"
Declare cThreadMethods "{11C7C550-321D-4043-8B85-C70FB077C455}"
Declare cThreadProxy "{47B5FAE7-6DDD-413D-8D05-909EA7EE4D6B}"
Declare cAttribute "{6014736A-DE25-498A-9FF7-F1523CAD1C88}"
Declare cAttributes "{E77BB0E8-8E06-4BAA-87CA-E90B116348DE}"
Declare cCodePageMapping "{2E44F8B3-87F6-45C9-BF94-2278AF699399}"
Declare cElement "{21EA408B-1087-493A-A910-ED2ED971511E}"
Declare cElements "{9F8812DF-12FE-4838-BEF4-B9B345A50682}"
Declare cSimpleDOM "{B4D99F73-D6A3-4E62-BD37-9E7E92A37C81}"
Declare cSimpleSax "{A6B960A9-E5BE-41A0-86B1-6D1586636624}"
Declare cpBoxShape "{F517FDAF-E3AA-4F0E-885C-36F5A427FCD8}"
Declare cpCircleShape "{67F72848-CACB-4FB5-8DE2-3DB2FF57A2B7}"
Declare cpConstraint "{240884AC-20F7-4671-B1D9-6799F6FFCFD1}"
Declare cpDampedRotarySpring "{1D827C63-1D99-4E33-A80C-70F6499AEB04}"
Declare cpDampedSpring "{24086CF2-442B-4E96-919D-333281B1DD87}"
Declare cpGearJoint "{E6BD66ED-ADEB-4645-94D3-58222E2905B8}"
Declare cpGrooveJoint "{4AA25F11-BE86-4938-8054-6116F523819A}"
Declare cpPinJoint "{7B9A2ED7-4FFF-4892-A80D-543C2EA0A56C}"
Declare cpPivotJoint "{0324016E-EB60-4DBB-B9CD-4BE30330A976}"
Declare cpPolyShape "{ECFAC056-DC96-4E7F-9A9B-C7A20DC86016}"
Declare cpRatchetJoint "{8B94EB8B-CAF4-4C2A-BAF3-3599253EC435}"
Declare cpRotaryLimitJoint "{D3E56596-A285-4711-B1C5-BF1B090A1C38}"
Declare cpSegmentShape "{5C84BA92-AB49-411E-BB6B-F3779BCBA295}"
Declare cpShape "{5F6E1904-ACF2-4407-93FA-ED162EC05D14}"
Declare cpSimpleMotor "{0FAB3DB4-8781-4C29-81CA-00687AF87817}"
Declare cpSlideJoint "{F004863B-E7F2-4607-9EB1-11EB7E50CFC3}"
Declare cCairoPattern "{B5F25B66-FDA6-4EAE-86CC-C6AB68E87CC6}"
Declare cCairoSurface "{E4122B22-E662-4C0A-9C4C-AE3D55470D26}"
Declare cControlPoint "{B601F1DE-7234-48AB-9140-FAC012AC315F}"
Declare cControlPoints "{E31BD13C-536B-4DAB-B529-E2200A464236}"
Declare cDisplay "{248A59B9-084C-4281-B742-290EAFFFBAF7}"
Declare cDisplays "{5B4C7F59-8E98-40B6-84BA-F6EF644C0AE7}"
Declare cImageList "{64966621-70CD-487E-8738-57BDFF8A2A1D}"
Declare cJPG "{4F2838B9-8671-4960-A948-29A77D53BEE7}"
Declare cKeyWatcher "{E81C6BC7-26A6-4E51-80DB-362773010156}"
Declare cOneShotTimer "{ABA55CA9-96B2-4FA1-B18E-67D5DF1298D1}"
Declare cSubClass "{63DF9A9D-B912-47D7-8D6E-C97C0CFC98B9}"
Declare cSVG "{A7760509-4A0E-44A1-91D8-B475ADB58EFF}"
Declare cWidgetBase "{3C81F88B-5381-4038-8679-E83D6824CC60}"
Declare cWidgetForm "{C5EC4374-D98C-4985-B146-8A336CA3F2C9}"
Declare cWidgetForms "{A1C49966-053F-49B0-B14D-6F70A4628FFA}"
Declare cWidgets "{4BA9B94B-BD40-4742-9AF5-727038FE912A}"
Declare cCairo "{DA3EABB6-54CE-4E08-88D0-5580B57EAF26}"
Declare cCairoContext "{62282848-A98A-4C93-9D3A-942F823FDDEE}"
Declare cCairoMatrix "{299D4EFF-9E66-4A6D-90CC-0F5196077B9A}"
Declare cCairoPath "{69F20E5A-5AAA-4AD2-8C4E-D43FCF634344}"
Declare cPhysicsEngine "{EC36E24F-E93E-4FC7-BFAE-19FBE4F8244B}"
Declare cpSpace "{C9D8DAF1-505D-4ECC-BB65-09A7B93FBB32}"
Declare cpBody "{9EC0CD1A-3E36-486E-BE8C-8DE9ADF4DC6C}"
Declare cpSegmentShapeCollection "{4FED773F-6C6A-49EE-9BE4-9C703409E90E}"
Declare cWidgetRoot "{E7A87A32-8E0B-4CC0-8C94-EC290907A4DB}"
Declare cTheme "{1512E9C3-A9B5-432E-BB00-2F7114495CDC}"
Declare cAuthEntry "{AA1B74C4-B234-47D8-A9BD-ED3B64DFB1CC}"
Declare cElementInfo "{41196DEE-CF33-4B2D-B768-63C367985221}"
Declare cNavigationInfo "{0948BFBA-58D9-4976-9351-38C914512313}"
Declare cWebKit "{29408AC1-8E09-4F1F-A30F-4189A5EB5AE8}"
Declare cFSO "{A7D866D2-1858-4347-A5DC-E6BD0F966E31}"
Declare cDataObject "{47B5F09E-4711-4A8D-992E-6E06B720032D}"
Declare cDataObjectFiles "{74AAEA37-02C8-4A1E-A5F7-3AD27E67D5AA}"
Declare cDirList "{B0C089E7-FC4C-4C27-9F94-CA2A4051F761}"
Declare cTextShapeResults "{B5790AA6-1C5C-4C7E-AF85-3A4969CD18F1}"
Declare cTaskBar "{18B2128A-3932-4882-BD1E-D91E2FF0A244}"
Declare cStringBuilder "{9C80CE11-B427-4D61-8344-CD623ABB82C4}"
Declare cWebServer "{74EED829-D3FF-4247-B93A-4E28C163B7F7}"
Declare cWebRequest "{71AE5962-4112-4F5D-90B6-DE8223923903}"
Declare cWebResponse "{990769CD-59AC-4F6C-82CB-0950956D65DC}"
Declare cProperties "{CFE2E41E-739D-4C1C-8781-47D12A15FA02}"
Declare cProperty "{9F37CBD3-E7CB-4DE7-BB01-5CAB7D33B678}"
Declare cDownloads "{AF6A8EB6-7EE1-42FD-9E7D-B0DABB26F495}"
Declare cDownload "{911018A7-EDCD-4DE1-B837-C2BF17FEB1C8}"
Declare IWidgetLoader "{4565946A-3A40-4FE2-B976-86D3D85E19F3}"
Declare cStream "{AC48A46C-54BD-4DA4-9C03-D44B58681100}"
Declare cSMBScan "{CA26E7C1-98C4-4974-8640-81250D4E19D6}"
Declare cShellLink "{A28FB3C4-0C81-46B3-9F01-A1CA5076069F}"
Declare cWebArchive "{76E77EE7-5475-4A53-B4BB-D6AE784A5A5D}"
Declare cfLayoutView "{CB7FA237-4377-438E-89B8-F2C3A3E8A239}"
Declare cPanelLayout "{E4AD470F-B2E6-4151-9F6E-24389A50B2EF}"
Declare cPanelDef "{62AF60DB-0F39-46FD-A876-84E1CFE1E39F}"
Declare cDataSource "{AD574C4A-7977-4A45-BF6F-9CCFE69247AE}"
Declare cDataSourceDisp "{E54F8C36-B15D-4E52-A0BE-8E7514060EFA}"
Declare cMemDB "{99FFFBEF-E3FA-444A-BD75-C3AD3F5ABCAE}"
Declare IXMLWidgetStore "{AAEA7565-806E-4CFA-8A38-501B8819B883}"
Declare cGestureConfigList "{2FF762CC-6F87-42B8-A8E3-97A8BC9BE7B8}"
Declare cGestureInfo "{3E2A992B-A6D8-4CC2-87F3-81E9E6A8CD23}"
Declare cTouchInfo "{37E277B2-C9BE-48F2-B206-C4AB472DF75A}"
Declare cUniClipBoard "{94F8290C-A5EA-4029-87F9-BFB71FAA75CE}"
Declare cArrayList "{54D03009-F8E2-41A8-B9E0-799DD94FEBB8}"
Declare IComparer "{5DC5928D-1849-4B60-814B-E0BB625A898F}"
Declare cVBDraw "{4F13F4A0-F8AC-4BD0-A1F4-87626F3BB08D}"
Declare cMenuItem "{FB17BB6F-A5FD-4012-AD9F-843F4536BF57}"
Declare cAudioCaptureClient "{E895E1B6-DECD-4F0F-AF78-DB95B5D888D9}"
Declare cAudioClient "{D0B82222-12C3-4B9A-A163-35EF5F154CD6}"
Declare cAudioInputSelector "{5CB1FFDE-D8A5-4FA5-84BB-B4444A590DFD}"
Declare cAudioMeterInformation "{CC1EC3C9-43B4-41DD-A1E1-1E82F625DA2F}"
Declare cAudioRenderClient "{96BC69A2-9429-4294-B8A3-28AF0167C063}"
Declare cAudioStreamVolume "{ECC92044-D706-4289-91C1-C18111DE27F5}"
Declare cChannelAudioVolume "{3A755B99-186F-4201-9BEA-A88BB6DB706E}"
Declare cConnector "{541359EC-F289-47EA-825D-643D24DCE408}"
Declare cControlInterface "{E90D544F-83B0-4F43-908B-74F9040B6CC3}"
Declare cDeviceTopology "{7A0FD946-C455-4987-A0ED-5B0E9885FBE0}"
Declare cMMDevice "{281225F2-90C5-4EB1-9E9A-87C5DE75C5FF}"
Declare cMMDeviceCollection "{5D97BCA4-69D6-4DF8-B50B-CA427E833E87}"
Declare cMMDeviceEnumerator "{D9ED6391-2751-4B6B-8A73-7A9ED72F3A22}"
Declare cMP3Resource "{7ED5EC75-FCFE-4EBE-9CF7-5B61364A1CA4}"
Declare cPart "{709F05F0-EDFC-4E1A-AC69-93260D9586C8}"
Declare cPartsList "{167D850D-DF78-4DEE-B7EE-14903BD579D8}"
Declare cPropertyStore "{0BB860E7-3582-4EF8-B233-525AE1B60457}"
Declare cSimpleAudioVolume "{687E43BB-230D-4CA4-B831-909EBE09FF85}"
Declare cTDD "{652DFBA9-A142-446F-945A-120A4DA97B8F}"
Declare cTDDResult "{504652B7-0FA8-4B48-BB38-BAC049C5F54D}"
Declare cGlobal "{C8512CFC-5EED-49F4-BE76-5D347416C287}"
Declare IEnumerable "{BCC0C207-F84E-445C-AEAE-AE1890DDFBCA}"



Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.