News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MasmBasic

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

Previous topic - Next topic

jj2007

Quote from: LordAdef on April 25, 2017, 09:03:16 PMIf you select some code and build (while the code is still selected) it generates an error. I found this by chance when selecting some code, F4 and build. The commented bit must be unselected now in order for the build to be successful.

It's not a bug, it's a feature :lol:

Insert this somewhere in one of your sources:if 0
include \masm32\MasmBasic\MasmBasic.inc
  Init
  Inkey "Current time is ", Launch$("cmd /c time /t")
EndOfCode
endif


The if 0 ... endif comments it out, so it won't disturb building your source. But if you select the lines inside and hit F6, then only the lines include ... EndOfCode will be used for the assembly. Useful for testing little snippets, but I will add a warning to the output window explaining why there was an error...

LordAdef

Updated as instructed! :dazzled:

jj2007

MasmBasic update 11 May features several improvements of Unicode handling. Inter alia,
- you can write strings in any language directly in the editor;
- file names can be in any language, too;
- find & replace is now Unicode aware.

The snippet below is a full-fledged Windows application. Please test in particular the FileOpen() feature.

GuiParas equ "严重的软件应该使用Unicode!!!!", h400      ; in RichMasm, hit F6 to build this application
GuiMenu equ <@File, Open, Save, Save &as, E&xit>     ; requires MasmBasic
include \masm32\MasmBasic\Res\MbGui.asm
  MakeFont hFont, Height:24
  GuiControl MyEdit, "RichEdit", font hFont, wCat$("The commandline passed was"+CrLf$+wCL$())

Event Menu
  Switch_ MenuID
  Case_ 0            ; first menu item has index 0
      .if wFileOpen$("богатый источник=*.asc|Poor sauce=*.asm|资源=*.rc", "богатый источник")
            SetWin$ hMyEdit=wFileRead$(wFileOpen$())
      .endif
  Case_ 1, 2:      MsgBox 0, "Saving not implemented, sorry", "Hi", MB_OK
  Case_ 3:         invoke SendMessage, hWnd, WM_CLOSE, 0, 0            ; yes, you can use pure assembler ;-)
  Endsw_
GuiEnd


Demo attached. To test it, extract to \Masm32\MasmBasic, then drag the file with the exotic name over \Masm32\MasmBasic\UnicodeIsEasy.exe

LordAdef

Quote- find & replace is now Unicode aware.

Since you mentioned find & replace, let me report this one for FYI sake:

"find" now finds key words in INCLUDE files (with Capital letters) and shows them in the find window. But "Replace" can't replace them in the include files. So the replace doesn't run if everything is selected to be replaced.

I can understand why, I'm just letting you know for development sake.
Cheers Alex

jj2007

Quote from: LordAdef on May 11, 2017, 09:03:47 PM"find" now finds key words in INCLUDE files (with Capital letters) and shows them in the find window. But "Replace" can't replace them in the include files.

Thanks, Alex. Version 12 May has a warning now, please let me know if that is the right choice. It would be technically possible to replace strings in the include files, but updating include files is not something I would support - too risky.

Among the other changes:

- By holding Ctrl and moving the mousewheel, the RichEdit control can zoom the display. At my age and my eyesight, I need 110%, but there may be people who have brilliant eyes and want to see more code. Pressing Alt Z saves the current zoom level; this is a global setting, i.e. RichMasm remembers this when opening any document (it also affects the font in the Find listbox, but only after restarting RichMasm).

- introduced a new Event variable VKey2:

Event Key
  Switch_ VKey2
  Case_ VK_LEFT:      wAddWin$ hMyEdit=" текст", 44       ; insert Unicode text at position 44
  Case_ VK_RIGHT:      AddWin$ hMyEdit=" missed", 50, 57  ; insert Ansi text at position 50, overwrite 7 bytes
  Case_ VK_UP     
            Let My$=FileRead$("UnicodeIsEasy.asc")
            wAddWin$ hMyEdit=My$
  Case_ VK_DOWN:      <wAddWin$ hMyEdit=wRec$(cfm$("\nВведите\nтекст\nздесь\n"))>  ; append & use cfm$ for \n escapes
  Endsw_


Until now, VKey was available to test for e.g. VK_SPACE or whatever; and the rule was that a positive VKey comes from the main application, a negative one (.if VKey==-VK_SPACE) from the riched control. Now you can catch a keypress independently of whether the control has the focus or not. Full example attached.

The snippet above also demonstrates new optional arguments for AddWin$:
AddWin$ hRichEdit="Text" [, startpos][, endpos]

The online doc for AddWin$ says it's normal edit controls only, but that is wrong. I should update that page...

LordAdef

QuoteThanks, Alex. Version 12 May has a warning now, please let me know if that is the right choice. It would be technically possible to replace strings in the include files, but updating include files is not something I would support - too risky.

ok JJ.
One other issue for you, still on the Find:
  .Once I make a change in the include file and save it,
  . come back to Main source code and
  . search for something...
  . the result in the Find is not updated for the include files, and still shows the old expression

jj2007

Version 29 May is online. As usual, you can just reinstall the package, no need to delete old files or backup your own sources.

Pens and brushes can now be created to arrays. This creates 100 random circles in random colours (attached):

include \masm32\MasmBasic\Res\MbGui.asm
  Dim Pens() As DWORD
  Dim Brushes() As DWORD
  For_ ct=0 To 99
      MakePen Pens(ct), Rand(-1), width 10      ; use random colours
      MakeBrush Brushes(ct), Rand(-1)      ; also for the fill
  Next
  MakePath      123, Circle(200)      ; ID, type circle: radius 20%, i.e. n/1000 of window rect
Event Paint
  For_ ct=0 To 99  ; ID       pen/brush          x        y     scaleX      scaleY
      GuiDraw 123, <Pens(ct)/Brushes(ct)>, <Rand(850).>, <Rand(850).>, eax, <Rand(900)>      ; ScaleX is eax, same as scaleY
  Next
GuiEnd



Quote from: LordAdef on May 13, 2017, 02:39:46 AMthe result in the Find is not updated for the include files, and still shows the old expression

Sorry, Alex, no time to fix that right now. You can reload, though: Shift F5

Good news: RichMasm works on Windows XP. Again. It had stopped working due to a hilarious Windows bug, see
Code pages and batch files - fun with XP.

As a side effect, I had to write a new macro:

include \masm32\MasmBasic\MasmBasic.inc
      Init
      Print Str$("This is Windows version %i", MbWinVersion()), Str$(".%i", ecx)
      void MbWinVersion()
      Print Str$(", build %i", dx)
EndOfCode
Rem      returns major version in eax, minor version in ecx, and build in dx


Output: This is Windows version 6.1, build 7601

Note this is the real Windows version, not what you declare via "compatibility settings".

Btw when building a project in RichMasm, the environment variable is accessible via  ifidn @Environ(oWin), <5>
MsgBox 0, "Built on XP", "Hi", MB_OK
  endif

jj2007

Drag an avi file over the exe, for example Mikl's demo file - see Uncle Remus tales:#37a Animation.

GuiParas equ "SysAnimate32 demo", w452, h374, bRgbCol(255, 255, 160)
include \masm32\MasmBasic\Res\MbGui.asm            ; part of MasmBasic
GuiControl Avi, "SysAnimate32"
invoke SendMessage, hAvi, ACM_OPEN, 0, CL$()
invoke SendMessage, hAvi, ACM_PLAY, -1, 0FFFF0000h
GuiEnd


I was surprised how easy it is, but its usage is rather limited: no sound :(

jj2007

Quote from: LordAdef on May 13, 2017, 02:39:46 AM. the result in the Find is not updated for the include files, and still shows the old expression

Implemented in version 31 May - please reinstall the whole package, there was also a bug in the Ansi version of FileOpen$().

Let me know if it's OK like that, Alex. In contrast to the current version, the "external" matches now respect also the "case" and "fw" checkboxes, i.e. case-sensitive and full word mode are working correctly for the include files now.

LordAdef

Quote from: jj2007 on May 31, 2017, 09:21:38 AM
Quote from: LordAdef on May 13, 2017, 02:39:46 AM. the result in the Find is not updated for the include files, and still shows the old expression

Implemented in version 31 May - please reinstall the whole package, there was also a bug in the Ansi version of FileOpen$().

Let me know if it's OK like that, Alex. In contrast to the current version, the "external" matches now respect also the "case" and "fw" checkboxes, i.e. case-sensitive and full word mode are working correctly for the include files now.

Great update Johen. I'm downloading it tonight when I get back home.

jj2007

Version 13 June fixes an exotic bug in RichMasm - it choked if many uppercase INCLUDE files were found.

New feature: Console input with character limit as discussed here:

  .Repeat
      Print At(5, Locate(y)) " "
      Let esi=Input$("Go ahead, edit that string: ", "123456789012345678", max20)
      PrintLine "                       you typed [", esi, "]"
  .Until Len(esi)<5


Attached is a beta, exe only, that plays media files. Drag an audio or video file over the exe, if the codec is installed it will play. Cursor left, space, cursor right are relevant keys. Hold Ctrl for fast forward, Shift for slow back+forth.

jj2007

Minor update 11 July (download):

jd@150 equ KernelBase                               ; a little hack for a missing WinAPI,
j@VirtualProtectFromApp equ jbNextApi/150:s1111     ; may be refined in the near future
...
  mov r12, rv(MessageBoxA, @address)    ; address of MessageBoxA in the DLL


This is a rather exotic function needed for 64-bit code when you need the true address of a function in its DLL. Full example here.

Plus, RichMasm produces now better formatted output for this forum.

jiucenglou

Wow ! Such a wonderful project !
Would you recommend which debugger to use if MasmBasic dialect is used together with ML.exe ? (I mean, VS seems to provide a really decent and productive debugger for C/C++ or even MASM.)

jj2007

Quote from: jiucenglou on July 15, 2017, 11:27:36 PM
Wow ! Such a wonderful project !
Would you recommend which debugger to use if MasmBasic dialect is used together with ML.exe ? (I mean, VS seems to provide a really decent and productive debugger for C/C++ or even MASM.)

Thanks ;-)
Re debugger, many of us here use Olly.

jiucenglou

Thank you for your recommendation very much ! I will try OllyDbg 2 :t