Basicprogramming(.org) > Community news and announcements

MasmBasic

<< < (6/7) > >>

jj2007:
MasmBasic got updated, see download and installation. Inter alia, many standard Windows controls are now easily accessible via the GuiControl command:
--- Code: ---include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyEdit, "richedit", NoTag$(FileRead$("http://retrogamecoding.org/board/index.php?board=17.0"))
GuiEnd
--- End code ---

This is sufficient to create a full-fledged Windows application. Here is a more elaborate example of an application with 18 controls, like edit, static, richedit, syslink, date & time, progressbar, trackbar, etc.


Btw with 5319 characters in 80 lines, the source for this demo would have fit into the 100 Line-of-Code Programming Language Competition:

--- Quote from: B+ on June 17, 2017, 07:27:02 PM ---The limit is 255 characters X 100 lines = 25500 characters, that is a clear limit.
--- End quote ---

jj2007:
News from the MasmBasic subforum:



The source (requires the Masm32 SDK plus the MasmBasic library):

GuiParas equ "Plot sinus & cosinus curves", x600, y100, w600, h500, bRgbCol(192, 255, 255)
include \masm32\MasmBasic\Res\MbGui.asm
  Dim MySinus() As REAL4                       ; REAL4 precision is enough ...
  Dim MyCosinus() As REAL8                     ; ... but REAL8 is ok, too
  For_ ecx=0 To 359
        SetFloat MySinus(ecx)=Sinus(ecx)       ; fill an array
        SetFloat MyCosinus(ecx)=Cosinus(ecx)   ; you may use ArrayRead for reading data from a file
  Next
  MakeFont hHorzFont, Height:18, Weight:FW_SEMIBOLD, Italic:TRUE
  MakeFont hVertFont, Height:18, Weight:FW_SEMIBOLD, Escapement:900, Italic:FALSE
  MakePen hPenAxis, RgbCol(255, 0, 0)
  MakePen hPenGrid, RgbCol(255, 255, 222), width 2
  SetAxisX "degrees", s 0, d 15.0/3, grid 1, penx hPenAxis, peng hPenGrid, font hHorzFont, format "%i" ; s=start value, d=difference between gridlines
  SetAxisY "sinus & cosinus", s -1, d 0.2/5, grid 2, font hVertFont, format "%2f"
  $Data "Plotting an array of points is very easy: All you need is the array itself, plus a Paint event that draws it."
  $Data "The axes can be set using SetAxisX and SetAxisY, taking arguments as shown in the source. Now resize this window to see how it behaves"
  Read desc$()                          ; read a string array from $Data
  Event Paint
  ArrayPlot MySinus(), RgbCol(255, 222, 160), 2, 00000110h, 0, -1, 1    ; red sinus, 2px wide; use margins left top right bottom, min0, max-1, filled=1 ArrayPlot MyCosinus(), RgbCol(0, 0, 255)             ; plot the cosinus array in blue, same margins as previous plot
  ArrayPlot exit, 0150006028# "Sinus & Cosinus"        ; finish with a title; optional: xxxxyyyyFF#: x, y pos, font size
  GuiTextBox 12, 100.0-80, 440, 66, Join$(desc$(), " "), bcol RgbCol(192, 255, 192)
  GuiEnd

Project attached. To build it, open the *.asc file in \Masm32\MasmBasic\RichMasm.exe and hit F6.

jj2007:


Source (67 lines of code) and data are attached; building requires MasmBasic version 2 April 2019 or later, plus the Masm32 SDK

jj2007:
MasmBasic version 8 May 2019 features some improvements under the hood, plus more comfortable working with maps. Below a screenshot, these 14 lines of code are the source:

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyMap, "canvas", w660
  GuiControl TheManual, "richedit", res:92, x660, w340, bcol RgbCol(255, 255, 222)
  GuiControl Sbar, "statusbar", bcol RgbCol(255, 0, 0), wRec$("Click into a country / Нажмите в страну / 點擊進入一個國家 - this toolbar uses common controls version "+ComCtl32$()), font -16:FW_SEMIBOLD
  ArrayLoadMap 0, 90                    ; Europe.dmi and Europe.map in resources
  MapColours(0, "abcdefghiabcdefghiabcdefghiabcdefghiabcdefghiabcdefghi")      ; set colours to map 0 (a=red, i=green)
Event CanvasPaint
  ArrayPlot RgbCol(0, 240, 255)         ; init and set background colour
  PaintMap RgbCol(127, 127, 127), lines=2       ; map with grey borders 2px thick
  ArrayPlot exit, "Europe"
  GuiTextBox 99.0-120, 52.0, 120, 60, "This program requires the file Europe.map", bcol LiteGreen, font -18:FW_NORMAL
Event Message
  If_ uMsg_==WM_MAPCLICKED Then <SetWin$ hSbar=If?(MapRegion ge 0, "You clicked on "+MapRegion$, Time$)>
GuiEnd

jj2007:
The new MasmBasic version of 20 August 2019 features an improved sort algo. Case-sensitive sorts are now over 20% faster, case-insensitive sorting is now almost a factor 3 faster.

--- Code: ---Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz

sorting 1000000 lines case-insensitive took 504 ms
AAaAHZybMJfIBMDPTlGpjvUIKUAUarYYBhwoQzXDbBiAcpCJBdWibuPGKXCeSrAcOsQVouKGLUtXF
aAABoYraUmtdbUjgRDbugWslpjAUIKuszBiOYgbGgDwawBsyfUTodDuktDyLUCdtDSYqIFfwxoBlKDfbiuHQ
aaadeaEoIYWvHUzkSOtliXprvQLwLRmQtZnACEWprRsosQEBCExqPRkIFHyxbkWHovUZtDOKw
...
ZZzyzetRGgWITClgQOTutTCdCiuHMxPNPuxGIsUFqStMIuIRPqlWpHdzyckcajQMCgNTbYzilNuy
zzZzcsrZGTHbiajufJIMXwWdbKFncznEBmlSLCGJBKFTHoixDzzNgeXSRohyfJHAQreI
zZZzToOoFStspcNrVaEIfjsxTNFZWUIwVWqxrzppJBjnxhbFgXmoCjUQxitzjpsLsmkTJefTDsKUKDj

sorting 1000000 lines case-sensitive took 444 ms
AAAJkbfOkQBObDHcbTIwHpqfZhoeEAOdznaOpVJqBwanparynNfGQbaMfZwqeWVzuereGocrnKWbAx
AAAKDBqCLIvtYhNOwRHDkUdYhtCnqVlAtRxBIyOmZtyRTJmmduoLcogeGKDYzS
AAANyurgtXuGMSDjUiphJpjDEIXsqWblivOefMURODFFRLEmyNHboCtnRgrrGsTpQXBZ
...
zzzMNTYBXQesyiSPhDSnEMllmqJyPOetjQASwTjPPdMGALxaTsXIBwpiDnRqaG
zzzWKRnlAPdJrfgIgiHjbJTvoMgrRnxVAukqhhjMqshOgVAuaGceqItZADoDlNBtykFZjwKyKuMhTJeu
zzzYZAgWBUtSZfUmlAWnFFRpDcGgwdOFndrhSJZcyMsgkvLnTOTRmUtwjKvNKJndDYagMFDBnZQduJzTADOTbIsyx
--- End code ---

P.S.: A fat text file for testing sort algorithms is here. To test them, extract the exe attached below to a folder, then open a DOS prompt and run it e.g. as MbSortText.exe RandSheet.tab

The example text files are tab-delimited, so that they are useful to test the sort-by-column feature of QSort(). With sort algos that do not have such a feature, they behave like a normal text file, i.e. the tabs will be ignored.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version