Author Topic: MasmBasic  (Read 253864 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
StrLen timings
« Reply #240 on: April 10, 2015, 08:25:48 AM »
Version 2 - I've added CRT strlen and the "safe" version strnlen:
Code: [Select]
Comparing MasmBasic Len(), crt_strlen and Masm32 len()
Total bytes:
401700900 in  36 ms Len
401700900 in 229 ms crt strlen
401700900 in 428 ms crt strnlen
401700900 in 259 ms Masm32 len

401700900 in  37 ms Len
401700900 in 229 ms crt strlen
401700900 in 419 ms crt strnlen
401700900 in 261 ms Masm32 len

401700900 in  36 ms Len
401700900 in 227 ms crt strlen
401700900 in 419 ms crt strnlen
401700900 in 263 ms Masm32 len

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

P.S.: Version 10 April fixed a minor incompatibility with JWasm (the xlsPixels2Points macro used in the DDE demo \masm32\MasmBasic\Res\Masm2Excel.asc assembled fine with ML 6.15 .. 10 but choked with JWasm).
« Last Edit: April 10, 2015, 09:33:42 AM by jj2007 »

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #241 on: April 11, 2015, 01:46:49 AM »
error line (??)
the specified procedure could not be found

xp sp3

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #242 on: April 11, 2015, 03:39:28 AM »
Yep, I just verified with my old machine: strnlen is not available on XP... :(

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Sound command
« Reply #243 on: April 25, 2015, 05:10:19 PM »
I know feature overkill is a big problem, but I couldn't resist :redface:

Sound
  Sound "880:200"           ; plays 880Hz for 200 ms; separator can be space, tab, / or :
  Sound 111                 ; plays a wav resource with ID 111 (rc file: 111 WAVE "hello.wav")
  Sound "hello.wav"         ; plays a file directly (wav only)
  Sound "hello.mp3"         ; plays a file in its associated player
  Sound "大桥在混乱的水.mp3"  ; Unicode names are allowed


Download version 25 April 2015

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6718
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: MasmBasic
« Reply #244 on: April 25, 2015, 10:57:37 PM »
Use the unsafe version, from memory its faster and you just use it correctly.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Farabi

  • Member
  • ****
  • Posts: 969
  • Neuroscience Fans
Re: MasmBasic
« Reply #245 on: April 26, 2015, 01:38:10 AM »
That is impressive Mr. Jochen  :t
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Re: Sound
« Reply #246 on: April 26, 2015, 03:05:36 AM »
Thanks, Onan :icon14:

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Two-dimensional string arrays
« Reply #247 on: May 02, 2015, 11:55:18 AM »
The MasmBasic update of 23 May concerns basically string arrays with two dimensions, e.g. for use with spreadsheets. Example:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Dim My$(tab)      ; create a two-dimensional string array using tabs (csv: commas) as separators
  For_ row=0 To 7
      Let My$(row, 0)=Str$("Row %i", row)
      For_ col=1 To 7
            Let My$(row, col)=Str$("Col %i", col)
      Next
      Delete My$(row, 6)      ; cut out all even columns
      Delete My$(row, 4)
      Delete My$(row, 2)
  Next
  For_ row=0 To 7
      PrintLine My$(row)
  Next
  Exit
EndOfCode


Output:
Code: [Select]
Row 0   Col 1   Col 3   Col 5   Col 7
Row 1   Col 1   Col 3   Col 5   Col 7
Row 2   Col 1   Col 3   Col 5   Col 7
Row 3   Col 1   Col 3   Col 5   Col 7
Row 4   Col 1   Col 3   Col 5   Col 7
Row 5   Col 1   Col 3   Col 5   Col 7
Row 6   Col 1   Col 3   Col 5   Col 7
Row 7   Col 1   Col 3   Col 5   Col 7

EDIT: version 3 May adds the corresponding Insert command:

  Dim some$(tab)      : same for some$(csv)
  Let some$(0)=cfm$("rc00\trc01\trc02\trc03\trc04\trc05\trc06")
  Let some$(1)=cfm$("rc10\trc11\trc12\trc13\trc14\trc15\trc16")
  Insert some$(0, 3)
  Let some$(0, 3)="NEW r0c3"
« Last Edit: May 03, 2015, 09:07:04 AM by jj2007 »

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Bug warning
« Reply #248 on: May 05, 2015, 10:32:12 AM »
MasmBasic version 5 May 2015 fixes two bugs:
- Csv2Tab (converts an array loaded from a *.csv file to tab-delimited) had problems with malformed files;
- mov esi, some$(row, column) could produce garbage in loops with many thousand iterations (Let esi= was not affected; mov must be used only for read-only pointers).

Some new functions for the simplified GUI have been added:
output:


source:
GuiParas equ "Hello jj2007", x100, y100, w300, h180, b0F0F0A0h
GuiMenu      equ @File, &Open, &Save, -, E&xit, @Edit, Undo, Copy, Paste
include \masm32\MasmBasic\Res\MbGui.asm
MakeFont hFontSmall, Height:15, Weight:FW_SEMIBOLD, "Arial"
MakeFont hFontBig, Height:36, "Script MT Bold"
MakeBrush hRed, RgbCol(255, 64, 64)            ; light red
MakeBrush hGB, RgbCol(0, 160, 64)            ; dark green
Event Menu
  MsgBox 0, Str$("You clicked menu #%i", MenuID), "Hi", MB_OK
Event Paint
  m2m ecx, 3            ; just to demonstrate how to use scaling
  GuiTextStyle font:hFontSmall, bcol=RgbCol(255, 255, 160), fcol RgbCol(0, 0, 255)
  GuiLine 70, 15, ecx*90+10, ecx*5      ; start x+y, end x+y
  GuiLine 280, 120      ; end x+y
  GuiLine 70, 120
  GuiLine 70, 15
  GuiSetFill hRed      ; use the red brush
  GuiEllipse 236, ecx*7+4, 40, 20      ; x, y, radius x, radius y
  GuiSetFill hGB
  GuiCircle ecx*80-4, 25, ecx*5      ; x, y, radius
  For_ ct=0 To 7
      GuiText 4, ct*15+4, Str$("Line %i ", ct+1)
  Next
  GuiTextBox "Добро пожаловать", ecx*4+75, ecx*2+20, ecx*4+250, ecx*2+120, font:hFontBig, bcol:0f0f0a0h, fcol:RgbCol(0, 255, 0)
GuiEnd

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Simple GUI app with toolbar
« Reply #249 on: May 19, 2015, 09:26:40 AM »
This one needs MasmBasic version 19 May 2015 (works with Unicode tooltips, too):

GuiParas equ "Editor demo", x40, y40, w900, h666
GuiMenu equ @File, &New, &Open, &Save as
include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyEdit, "richedit", y=0+37, h=1000-35, text "No valid commandline found"
  GuiControl MyTb, "Toolbar", resid 111
  SetGlobals MyEd$="Simple editor:", CurrentFile$
  SetGlobals
  Let CurrentFile$=CL$()      ; OPT_Arg1 SimpleEditor.asc      ; RichMasm: specify a commandline for testing
  .if Len(CurrentFile$)>1
      SetWin$(hMyEdit)=FileRead$(CurrentFile$))
  .endif
Event Menu
  Switch MenuID
  Case TB0, 0      ; first toolbar button or first menu entry
      MsgBox 0, "New doc?", MyEd$, MB_OKCANCEL
      .if eax==IDOK
            SetWin$ hMyEdit=Chr$(0)
      .endif
  Case 1, TB0+1      ; 2nd toolbar button or 2ndmenu entry
      .if FileOpen$("Standard Basic=*.bas|Oxygen=*.o2bas|SdlBasic=*.sdlbas|MasmBasic=*.asc", "Open source:")
            SetWin$ hMyEdit=FileRead$(FileOpen$())
      .endif
  Case 2, TB0+2
      .if Alert("WARNING: long files will\nbe truncated at 160kBytes", MyEd$, MB_OKCANCEL)==IDOK
            .if FileSave$("Standard Basic=*.bas|Oxygen=*.o2bas|SdlBasic=*.sdlbas")
                  FileWrite FileSave$(), Win$(hMyEdit)
            .endif
      .endif
  Case 3, TB0+3
      FileOpenSetFolder FolderOpen$("Pick a folder:", MyEd$, "\Masm32\Examples")
  Endsw
GuiEnd

Rsrc
32512 ICON "\\masm32\\MasmBasic\\icons\\Disc.ico"      ; Asm, House, Keys, Globe, Hammer, Setup, Disc, Eye, ...
1 24 "\\Masm32\\MasmBasic\\Res\\XpSimple.xml"
111 10 \Masm32\MasmBasic\Res\Tb4Res\SimpleToolbar.zip
Rsrc

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: MasmBasic
« Reply #250 on: May 19, 2015, 12:10:25 PM »
glad to see you got it going   :t

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Re: MasmBasic
« Reply #251 on: May 19, 2015, 12:41:45 PM »
Well, kind of: with a stripped down manifest. It looks ok, it behaves ok - see attached exe (and source). But it doesn't use the latest version of the common controls...

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Unicode editor with multilingual user interface
« Reply #252 on: May 21, 2015, 01:32:19 AM »
Just for fun - needs MasmBasic version 20 May 2015:



Source (28 lines of code :icon_mrgreen:) included in the package: when the help file pops up, click on "Try a GUI app" in line 15.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Multilingual GUI apps
« Reply #253 on: May 23, 2015, 12:30:25 PM »
What I always missed with M$ Office (and Windows in general) was an option to switch the language of the user interface. Here is one way to do it: Instead of writing ...
Code: [Select]
invoke AppendMenu, esi, MF_POPUP, edi, chr$("&File")... you use ...
Code: [Select]
invoke AppendMenu, esi, MF_POPUP, edi, Mlg$(File)... and depending on the language chosen by the user, the menu appears as File or Fichier or Datei.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Mlg$(File:"\Masm32\MasmBasic\Res\Tb4Res\Sample.tab")      ; file:"path" loads the multilingual matrix
  For_ ct=0 To 5
      Mlg$(Language: Mid$("ENESBRITDEFR", ct*2+1, 2))      ; example: Mlg$(Lang:IT) sets Italian
      PrintLine Mlg$(LgTx), ":", CrLf$, Tb$, Mlg$(_ASM), CrLf$, Tb$, Mlg$("_BEL")
      PrintLine Tb$, Mlg$("_USA"), CrLf$, Tb$, Mlg$(_AUS), CrLf$, Tb$, Mlg$(_AUT)
  Next
  Exit
EndOfCode


Output (shortened):
Code: [Select]
English:
        American Samoa
        Belgium
        United States
        Australia
        Austria
Español:
        Samoa americana
        Bélgica
        Estados Unidos
        Australia
        Austria

Format of the tab file:
Code: [Select]
Line 0 = comment, Tb$, ID1, Tb$, Id2, ...
Line 1...n: 3 or 4 letter ID (here: understroke+ISO 3 letter code), Tb$, text, Tb$, text, Tb$, etc.
 
Do not change this line EN ES BR IT DE FR
LgTxt English Español Português (BR) Italiano Deutsch Français
_ASM American Samoa Samoa americana Samoa Americana Samoa Americane Amerikanisch-Samoa Samoa Américaines
_AUS Australia Australia Austrália Australien Australie
_AUT Austria Austria Áustria Österreich Autriche
_BEL Belgium Bélgica Bélgica Belgio Belgien Belgique
_FRA France Francia França Francia Frankreich
_USA United States Estados Unidos Estados Unidos Stati Uniti d'America Vereinigte Staaten von Amerika Etats-Unis

Example attached, requires MasmBasic of 23 May 2015

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 9747
  • Assembler is fun ;-)
    • MasmBasic
Toolbar with embedded controls
« Reply #254 on: May 29, 2015, 10:26:05 AM »
Source (ca. 70 lines) is in \Masm32\MasmBasic\Res\MiniGui.asc (MasmBasic of 29 May)