News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

MasmBasic

Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic

jj2007

Yep, I just verified with my old machine: strnlen is not available on XP... :(

jj2007

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--

Use the unsafe version, from memory its faster and you just use it correctly.

Farabi

That is impressive Mr. Jochen  :t
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

Thanks, Onan :icon14:

jj2007

#245
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:
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"

jj2007

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

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

glad to see you got it going   :t

jj2007

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

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

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 ...
invoke AppendMenu, esi, MF_POPUP, edi, chr$("&File")
... you use ...
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):
English:
        American Samoa
        Belgium
        United States
        Australia
        Austria
Español:
        Samoa americana
        Bélgica
        Estados Unidos
        Australia
        Austria


Format of the tab file:
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

Source (ca. 70 lines) is in \Masm32\MasmBasic\Res\MiniGui.asc (MasmBasic of 29 May)

jj2007

Since I finally have a machine with Windows 8.1 installed, I managed to fix a bug in RichMasm. As of version 11 June 15 (download), MasmBasic's IDE is fit for Win 8 :t

Note that before installing MasmBasic, you need a valid Masm32 installation. One known issue with Win 8.1 is that you will see these messages several times:
- inc2l.exe: can't find ordinal 200 in windir\AppPatch\AcGenral.dll
- inc2l.exe: can't find ordinal 202 in windir\AppPatch\AcLayers.dll

Masm32 will work just fine, in spite of these error messages.

Note also that Win 8 will display a message "PC protected by Windows" saying that "SmartScreen" has stopped the launch of an unknown application. This is a nasty trick to force coders to buy signatures. Click on "more info" and "Run anyway".

dedndave

you wanna tell us about the bug ?   :biggrin: