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

Oliver Scantleberry

Quote from: jj2007 on December 12, 2015, 11:28:29 AM
MasmBasic update 12 Dec 2015 features a major change under the hood: GetFiles returns now UTF-8 file names. This has no effect on file names using only Ansi characters, but it is a major improvement for those who use Russian, Chinese or Arabic file names (and that is quite a lot of people...). . .

If I ever decide to program in assembly using Russian, Chinese, or Arabic, I will definitely give MbasicBasic a try. I'm right on top of Russian and Chinese but I need a little more work with Arabic. I keep reading it left to right.

jj2007

MasmBasic update of 23 December 2015 improves and simplifies the use of Unicode & UTF-8 encoded charsets. This example shows recent sources in a listbox, and you can open them by double-clicking on an entry (source & exe attached):

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyLb, "listbox", y60, h940
  GuiControl MyEd, "static", text "Double-click to open a file - Дважды щелкните, чтобы открыть файл", h50
  GetFiles *.as?|*.rc      ; asc, asm, rc
  SortFiles                 ; latest files on top
  SetListbox Files$()      ; Fill the listbox with UTF-8 encoded file names
Event Command
  If_ NotifyCode==LBN_DBLCLK Then uShEx LbSel$   ; open selected file with ShellExecuteW (u=assume UTF-8 for LbSel$)
GuiEnd


Second example (screenshot below, source attached) shows three edit controls: Scintilla, ordinary "edit" and RichEdit. The program is resizable, and the controls adjust their sizes proportionally based on this simple syntax:

  GuiControl MySci, "scintilla", h500, x250, w300, text "... initial text ..."
  GuiControl MyEdit, "edit", y500, h500, x250, w300, text "..."
  GuiControl MyRich, "richedit", x550, w450, text "..."
  GuiControl MyListbox, "listbox", w250


MyEdit, for example, is positioned at x=25% of client area, y=50%, 30% wide and 50% high.
MyListbox is positioned at default x+y positions, i.e. top left, full height and 25% width.

guga

All i can say is WOW !!!!!

How you managed to hide the code from the rtf on right click ?

And the sinus example ! Loved it !
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Grincheux

I launched NewSources and it told me

Quote

0 files found. Newest files:

---- hit any key ----

Does not like Frenchies this program!!!

The two others programs run OK.
Kenavo (Bye)
----------------------
Help me if you can, I'm feeling down...

jj2007

Thank you, Guga, that was a nice feedback :P

But what do you mean with "hide the code from the rtf on right click" ?

guga

Hmm...I found this feature while reading MasmBasic guide. The feature is the same behaviour as in Radasm.

In Radasm, when you click on a token or a macro ("If" macro or the ones marked with a "+" sign), the text is hidden. Ex:

If eax = 5
   mov eax 1558
End_If


When you click in the "If" string, the text is hidden and it displays only this:


If eax = 5
End_If


Yours interface is different then in Radasm, but the behaviour is similar. What i liked on yours is the way we can actually read things on the richedit control. The ability to read the hyperlinks is great, and the way the help is displayed on certain mouse clicks, such this "hidden" of part of the text, or when you click on a string that may be a defined token and shows up a sort of help of what it is

On yours, I did this...before clicking on the word "Init"

include \masm32\MasmBasic\MasmBasic.inc
;   hit F6 to assemble, link & run the Hello World example
  Init
  ; to test examples, replace the white line with your test code and press F6
  MsgBox 0, "Wow, it works!!!!", "Hi", MB_OK ; It worked? Use a template, or try 90+ snippets
  Print CrLf$, "OK - press any key" ; It choked? Read below about JWasm.
  Exit
end start


After waiting 2 seconds, the mouse pointer changed to a question mark and  it displayed this on a different color. (Also, the new text that shows can be scrolled. I simply loved that !:


include \masm32\MasmBasic\MasmBasic.inc
;   hit F6 to assemble, link & run the Hello World example
  Init
------------------------------------------------------------------------------------------------- <-------- This showed and it can be scrolled
Init This is perhaps the smallest possible complete Masm application:
include \masm32\MasmBasic\MasmBasic.inc
Init
Inkey "Hello World"
Exit
end start
Rem - the Init macro inserts the following two lines:
-------------------------------------------------------------------------------------------------<-------- This showed and it can be scrolled

  ; to test examples, replace the white line with your test code and press F6
  MsgBox 0, "Wow, it works!!!!", "Hi", MB_OK ; It worked? Use a template, or try 90+ snippets
  Print CrLf$, "OK - press any key" ; It choked? Read below about JWasm.
  Exit
end start



How you managed to do that on a richedit control ?????
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

Quote from: guga on December 24, 2015, 11:02:08 AMAfter waiting 2 seconds, the mouse pointer changed to a question mark and  it displayed this on a different color. (Also, the new text that shows can be scrolled. I simply loved that !:
..
How you managed to do that on a richedit control ?????

Well, two richedit controls ;-)

When you hover over a keyword, e.g. GetFiles *.asm, and you right-click when the cursor changes to ?, RichMasm displays, overlapping the main control, a second borderless richedit control containing the MbGuide.rtf content. If you are fast enough, you can even left-click into that content and actually copy the example code. I use that several times a day, it's much easier than typing the stuff... try it with SortFiles ;-)

Btw inserting a hyperlink is very easy: copy the URL, select a word in the comment area, hit Ctrl K, OK.

jj2007

This year's last MasmBasic version does not only care for an exotic bug in the JWasm and AsmC assemblers (or is ML wrong? who knows  ::)), it also adds an interesting feature to the QSort string sort: You may use an index array to keep track of a string's original line number. Note this is not my idea, GfaBasic had it already in the mid-eighties; but MasmBasic is a bit faster: in case-insensitive mode, skipping leading spaces and using an index array, the routine sorts a Million strings in roughly one second on my Core i5 8)

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals c1, c2, c3
  Init                  ; ## create a dynamic string array and sort it ##
  Dim My$()
  xor ecx, ecx
  PrintLine "line", Tb$, "random string"
  .Repeat
      Let My$(ecx)=Str$("String %i", Rand(20)+1000)
      PrintLine Str$(ecx), Tb$, My$(ecx)
      inc ecx
  .Until ecx>=10
  QSortMode cis, sls, MyKeys()      ; case-insensitive, skip leading spaces, use an index array
  PrintLine CrLf$, "line", Tb$, "sorted string", Tb$, "was line"
  QSort My$()            ; sort all elements allocated so far
  For_ esi=0 To ecx-1
      PrintLine Str$("%i\t", esi), My$(esi), Str$("\t%i", MyKeys(esi))
  Next
  For_ esi=0 To ecx-1
      Rand("A", "Z", c1)      ; create three
      Rand("a", "z", c2)      ; random
      Rand("a", "z", c3)      ; chars
      Let My$(esi)=Chr$(c1, c2, c3, "_")+Mid$(My$(esi), 6)      ; rewrite string
  Next
  QSort My$()            ; sort all elements allocated so far
  PrintLine CrLf$, "line", Tb$, "resorted string", Tb$, "was line"
  For_ esi=0 To ecx-1
      PrintLine Str$("%i\t", esi), My$(esi), Str$("\t%i", MyKeys(esi))
  Next
  Inkey "OK?"
EndOfCode


Output:
line    random string
0       String 1009
1       String 1001
2       String 1002
3       String 1017
4       String 1013
5       String 1016
6       String 1004
7       String 1015
8       String 1000
9       String 1010

line    sorted string   was line
0       String 1000     8
1       String 1001     1
2       String 1002     2
3       String 1004     6
4       String 1009     0
5       String 1010     9
6       String 1013     4
7       String 1015     7
8       String 1016     5
9       String 1017     3

line    resorted string was line
0       Ebw_g 1017      3
1       Kia_g 1015      7
2       Ojo_g 1000      8
3       Olr_g 1002      2
4       Qgd_g 1001      1
5       Tvx_g 1010      9
6       Vdf_g 1009      0
7       Vny_g 1016      5
8       Xjo_g 1013      4
9       Ype_g 1004      6


Source + exe attached, plus an extended example showing how to use GuiImage:

include \masm32\MasmBasic\Res\MbGui.asm
Event Paint
  GuiImage "\Masm32\examples\exampl04\car\car.jpg", fit      ; fit to window mode
GuiEnd

jj2007

Inspired by Pelles C, I have written a plugin for RichMasm that zips the current source (including .rc, .inc etc if in the same folder) and copies the name of the zip file to the clipboard. It requires some zipper, e.g. 7-Zip, and a recent MasmBasic installation.

The attachment contains:
- a new version of RichMasm.exe, to be extracted as \Masm32\MasmBasic\RichMasm.exe
- ZipTheProject.dll and the source, to be extracted to \Masm32\MasmBasic\Plugins\ZipTheProject.dll

The plugin appears as last item in the System & plugins menu. For now, I have tested it with my 7z installation, and it works fine. Unicode file names work, too, but the name of the zip file will be e.g. ~tmpFile_12Jan.zip because 7z doesn't like UTF8 in the name of the archive.

Note that with 7-zip you can also use the extension .7z, with much better compression.

Work in progress, use at your own risk etc, feedback welcome 8)

jj2007

#309
First MasmBasic update this year features some improvements under the hood, plus new GdiPlus functions, see screenshot below and attached executable. The source is in \Masm32\MasmBasic\Res\GuiPieExcel.asc; inter alia, there is a conditional flag allowing to extract the data for the pie straight from M$ Excel.

P.S.: More recent versions of MasmBasic require that line 3, MyPie=100 gets deleted or commented out.

HSE

Why Read R1C1:R6C2 notprocessed?
Equations in Assembly: SmplMath

Grincheux

It is not MasmBasic but RichBasic :badgrin:
Kenavo (Bye)
----------------------
Help me if you can, I'm feeling down...

jj2007

#312
Quote from: HSE on February 26, 2016, 02:45:02 AM
Why Read R1C1:R6C2 notprocessed?

No idea. The request is StringToArray xlsRead$("R2C1:R9C2"), x$(), tab, and it works fine with my versions of Excel, i.e. Office 2003 and Office Starter 2010.

If you see this error string, it means you arrived at the connected state; which implies that the communication to Excel is working in principle.

If you comment out the xlsClose command, what do you see in Excel? Does Excel open the file?

If the Excel part is not interesting for you, here is an alternative:

  if 1                        ; 1 for testing, 0=use Excel to read from file
      ; Data "Asset      percent"            ; no header row
      Data "Gold      20"
      Data "Stocks      15"
      Data "Bonds      35"
      Data "ETFs      15"
      Data "Options      7.5"
      Data "Cash      7.5"
      Read x$(tab)      ; create and read a dynamic array of tab-delimited strings
  else
      xlsConnect            ; no args=System
      .if !Zero?              ; errors are returned via the Zero? flag
            xlsOpen esi            ; example from C++
            .if !Zero?
                  xlsConnect "PieData"            ; tell Excel to which sheet you want to talk
                  .if !Zero?
                        StringToArray xlsRead$("R2C1:R9C2"), x$(), tab
                  .endif
                  ; xlsClose
                  xlsDisconnect
            .endif
      .endif
  endif

HSE

The file is open in the correct sheet when the message appear (just to test I saved it open in a different sheet), and later close normally. Perhaps some request format problem (realated with languaje?).

I don't say before but, of course, using the table the screen is magnificent.
Equations in Assembly: SmplMath

jj2007

If your language is espanol, try using "F2C1:F9C2"
With Portuguese, it should be L2C1:L9C2 (more - look for row and column)

I attach the exe for Spanish.