Author Topic: MasmBasic  (Read 152996 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
WM_DROPFILES handler
« Reply #195 on: August 25, 2014, 09:23:14 AM »
  CASE WM_DROPFILES
            GetFiles WM_DROPFILES      ; put dropped files into the Files$() array
            push eax
            Let esi=Str$("%i files and folders dropped:", eax)
            xor ecx, ecx
            .Repeat
                  void Rinstr(Files$(ecx), "\")      ; strip the path: Rinstr() returns absolute pos in eax (and relative pos in edx)
                  lea edi, [eax+1]
                  Let esi=esi+Str$("\n%i\t", GfSize(ecx))+GfDate$(ecx)+Spc2$+GfTime$(ecx)+Tb$+edi      ; size, date, time and filename
                  inc ecx
            .Until ecx>=stack
            pop eax
            SetWin$ hEdit=esi                 


Sample output:
7 files and folders dropped:
0       13.01.2012  19:59:15   procs
0       13.01.2012  19:59:14   tutorial
0       13.01.2012  19:59:14   tools
65536   17.08.2014  15:04:04   uniedit.exe
5598    17.08.2014  04:13:03   AllFiles.zip
22528   17.08.2014  00:40:24   topgun.exe
37376   17.08.2014  00:25:44   qeditor.exe


Full source attached, requires MasmBasic of 25 August 2014.

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #196 on: August 26, 2014, 02:08:24 AM »
Good idea, Jochen. Thanks.  :t

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic bug fixes
« Reply #197 on: September 22, 2014, 08:05:55 AM »
Version 22 Sept 14 (download):

- BUGFIX: Val("12.34.56") returns now correctly 12.34
- BUGFIX: StringsDiffer used wrong location to test the case-insensitive flag

- New feature: Now dialogs close apart from IDOK and IDCANCEL also for IDs 100...120, and return the ID

« Last Edit: September 22, 2014, 09:26:51 PM by jj2007 »

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
FileRead$("http://...")
« Reply #198 on: October 05, 2014, 12:50:06 PM »
Bugfix 5 October (download):

For a while, the FileRead$() function had "forgotten" how to read a file from the Internet - sorry :redface:

Now the snippet below works again. It downloads an attachment from this forum, checks the zip directory for the first *.asm file, and displays the first 1.8 k on the screen:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  ; assign contents of a well-known file to esi:
  Let esi=FileRead$("http://masm32.com/board/index.php?action=dlattach;topic=49.0;attach=30")
  FileWrite "tmp.zip", esi, LastFileSize      ; write contents to a temporary file
  UnzipInit "tmp.zip"      ; expects a filename, returns a comment (if present)
  .if Sign?
      Print eax      ; print an error message
  .else
      For_ ecx=0 To edx-1      ; #files returned in edx
            mov esi, Files$(ecx)
            .if Instr_(esi, ".asm", 1)      ; assembler source, plain text?
                PrintLine "## First 1800 chars of ", esi, " ################# : ", CrLf$, Left$(UnzipFile(ecx), 1800), " ..."
            .endif
      Next
      UnzipExit
  .endif
  Inkey "## Cute, isn't it? #################"
  Exit
end start

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Menus with tooltips
« Reply #199 on: October 15, 2014, 09:18:42 AM »
MasmBasic update of 15 October (download) concerns mainly improvements of the editor:

- plugins don't need to be registered in the menus.ini file, it is sufficient to build them in the plugin folder
- all menus allow now tooltips, as shown below; for plugins, they can be defined in the source using txName db "name in menu§description of\nthe plugin", 0

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Bugfix for MasmBasic
« Reply #200 on: October 27, 2014, 10:24:20 AM »
I know it's hard to believe but YES, MasmBasic had a bug: wLeft$/wRight$/wMid$ didn't work :redface:

The Ascii versions were ok but the wide (Unicode) versions returned drastically shortened strings. No idea when this regression crept in but now it's fixed. Test it e.g. with the "talk to Excel" example in \Masm32\MasmBasic\Res\Masm2ExcelCircle.asc, line 39:

      xlsFormat CF_UNICODETEXT      ; back to Unicode
      wPrint "Cur selection", wTb$, wMid$(xlsRead$(), 16), wCrLf$      ; get current selection, strip the string "Real Unicode":


Note that in order to see the Unicode strings returned by Excel properly, you need to set the console font to Lucida Console (in the console window's system menu, properties, font).

Other good news is that UnzipFile() (see \Masm32\MasmBasic\MbGuide.rtf - based on JibZ' Tiny Inflate Library) is now twice as fast (the bad news is I had to abandon Pelles C to achieve that :().

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
MasmBasic thread-safe?
« Reply #201 on: November 10, 2014, 12:52:49 PM »
Update 10 November: Launch$() is now thread-safe. This was never a problem in console apps, but GUI apps could occasionally choke. It's fixed.

Other changes:
- Dll accepts now environment variables such as %ProgramFiles% - works with non-English Windows versions, ok for Win7-64:

  Dll "%ProgramFiles%\FreeArc\Addons\InnoSetup\unarc"

- Err$() allows an optional text, and instead of throwing a runtime error, you can programmatically check the availability of a DLL or certain functions inside a DLL:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  DllRTE=1             ; 1=throw runtime error if LoadLibrary fails (default), 0=no runtime error, check eax instead
  Dll "shimgvw"        ; load the shell image view dll aka Windows Picture and Fax Viewer Library
  DecRTE=0             ; 1=throw runtime error if GetProcAddress fails (default), 0=check eax instead
  Declare void ImageView_Fullscreen, 4            ; ImageView_Fullscreen expects 4 dwords but returns nothing useful
  .if eax
      ImageView_Fullscreen(0, 0, wCL$(1), SW_SHOW)      ; we need the wide version of the commandline arg
      Err$(0, "ImgView:")            ; there is no retval - you may test here for errors
      ; Err$(0, L)            ; same but titled "Error in line xx:"
  .else
      PrintLine "Problem with procedure: [", Trim$(Err$()),"]"            ; use Err$() without args for printing
  .endif
  Exit
end start
« Last Edit: November 10, 2014, 10:48:11 PM by jj2007 »

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #202 on: November 10, 2014, 11:35:52 PM »
Jochen,

Update 10 November: Launch$() is now thread-safe. This was never a problem in console apps, but GUI apps could occasionally choke. It's fixed.

well done.  :t

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Unicode file I/O
« Reply #203 on: November 17, 2014, 12:04:39 PM »
The MasmBasic update of 17 November (download) features a number of improvements under the hood, in particular an almost fool-proof handling of Unicode filenames. Example:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Let esi=wCL$()
  .if wExist(esi)
      wOpen "I", #1, esi
      wLet edi=Input$(#1, Lof(#1))
      Close
      wMsgBox 0, edi, wCat$("Contents of "+LastFileName$+":"), MB_OK
  .else
      wMsgBox 0, esi, "No such file:", MB_OK
  .endif
  Exit
end start


Among other improvements, MasmBasic's preferred editor, \Masm32\MasmBasic\RichMasm.exe, can now build directly with non-Latin alphabets:

include \masm32\MasmBasic\MasmBasic.inc
  Init
  uMsgBox 0, "Добро пожаловать", "Hi", MB_OK
  Exit
end start

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #204 on: November 19, 2014, 04:05:05 AM »
Jochen,

your Russian is getting better and better.  :t And MasmBasic, too. That's clear.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Russian & Unicode
« Reply #205 on: November 19, 2014, 05:19:46 AM »
your Russian is getting better and better.  :t And MasmBasic, too. That's clear.

Gunther,
Thanks :P
I use Russian for Unicode demos because the font is installed on most machines (unlike Chinese, for example), but as a matter of fact, I did speak Russian when I was young. Now I've forgotten everything, since I never practised it seriously.

habran

  • Member
  • *****
  • Posts: 1116
    • uasm
Re: MasmBasic
« Reply #206 on: November 19, 2014, 07:03:39 AM »
I know the filling, I used to speak German when I was young but when I come to Australia(1992) I was mixing German with English, so I had to push the German somewhere deep in my memory and now it is hard to dig it out :biggrin:
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 3517
  • Forgive your enemies, but never forget their names
Re: MasmBasic
« Reply #207 on: November 19, 2014, 07:57:23 AM »
Jochen,

I use Russian for Unicode demos because the font is installed on most machines (unlike Chinese, for example), but as a matter of fact, I did speak Russian when I was young. Now I've forgotten everything, since I never practised it seriously.

Интересно, так что вы не говорите по-русски.

Gunther
Get your facts first, and then you can distort them.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
Callback for GetFolders() and GetFiles()
« Reply #208 on: December 06, 2014, 01:05:24 PM »
Update of 6 December:

GfCallback defines a callback function to monitor progress in GetFiles or GetFolders:

      include \masm32\MasmBasic\MasmBasic.inc
      Init      ; <<< select init and hit F6 to test this snippet
      Let esi=ExpandEnv$("%WINDIR%")      ; usually C:\Windows
      PrintLine "Searching ", esi
      GfCallback cbGetFiles      ; define a callback function
      GetFolders esi
      Print Str$("\n%i folders found\n", eax)
      Exit

cbGetFiles:
      test edx, 1023      ; file or folder counter
      .if Zero?
            Print "*"      ; console mode progress bar ;-)
      .endif
      ret
      end start


jj2007

  • Moderator
  • Member
  • *****
  • Posts: 7728
  • Assembler is fun ;-)
    • MasmBasic
ToolTips, FileRead$(), GfCallback, Dim syntax
« Reply #209 on: December 09, 2014, 11:13:46 AM »
Minor fixes in MasmBasic version 9 December 2014 (download)

- ToolTips don't use edi ebx any more, i.e. you can use them in a loop; keep away from esi, though, and note that ecx will exceptionally be trashed here.

- the GetFiles GfCallback (examples) gives access to WIN32_FIND_DATAW in ebx (edx=file counter, edi=last path of FindFirstFileEx)

- Dim MyArray() As dword will choke now, and invite you to use uppercase DWORD (or BYTE, REAL8, whatever); note also that Dim without specifying the number of elements, i.e. Dim whatever() As WHATEVERSTRUCT is perfectly legal - same for strings and other types: MasmBasic arrays are dynamic. Just make sure you assign elements incrementally starting with zero, i.e. Let My$(0)="..." or mov MyRect(0, left)=123 etc

- FileRead$() occasionally threw generic API errors when the file was not found; now it chokes correctly with "can't find thatfile.txt"