News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MasmBasic

Started by jj2007, October 06, 2009, 08:24:57 PM

Previous topic - Next topic

dedndave

that takes care of it - they can use chr$   :P

i was thinking of a case where they may assign the same string twice
then, modify one version of it for one purpose and use the unmodified version somewhere else

jj2007

... and one more update: The ArrayFill command was missing.

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; Press F6 to assemble & link
FLOATSTRUC STRUCT
f4       REAL4 ?
f8       REAL8 ?
f10      REAL10 ?
fsrect   RECT <?>
filler   WORD ?

FLOATSTRUC ENDS
.data
   TheQ   QWORD 123456789012345678
   fls   FLOATSTRUC <12.34, 12345.6789, 123456789.123456789, <12, 34, 56, 78>, 123>
.data?
   TheQ2   QWORD ?   ; create non-
   fls2   FLOATSTRUC <?>   ; initialised copies
   
Init [/color]
   Open "O", #7, "Stored.dat"   ; open for output
   Dim MyWordArray(5) As WORD   ; create an array of words in heap memory, with 5 elements
   ArrayFill MyWordArray(), 12345   ; fill the array
   Store #7, TheQ   ; store the QWORD
   Store #7, fls   ; store the structure
   Store #7, MyWordArray()   ; and the 6 elements of the array
   
Dim My$(3)
   ArrayFill My$(), "Wow, strings created on "+Date$+", "+Time$
   Store #7, My$()   ; write also the complete string array
   Close #7   ; close the file

   Dim MyWordArray2(5) As WORD   ; create another array of words in heap memory, with 5 elements
   Open "I", #5, "Stored.dat"   ; open for input
   Recall #5, TheQ2   ; get the QWORD
   Recall #5, fls2   ; the complete structure
   Recall #5, MyWordArray2()   ; and the array
   
Recall #5, MyNew$()   ; last but not least, get the strings back
   Close #5   ; close the file

   PrintLine "Recalled from file:"
   Print Str$("TheQ2=%i\n", TheQ2)
   Print Str$("fls2.f4=%f\n", fls2.f4)
   Print Str$("fls2.f8=%Gf\n", fls2.f8)
   Print Str$("fls2.f10=%If\n", fls2.f10)
   Print Str$("fls2.fsrect.left=%i\n", fls2.fsrect.left)
   Print Str$("fls2.filler=%i\n", fls2.filler)
   Print Str$("The array, #5=%i\n", MyWordArray2(5))
   For_ n=0 To My$(?)-1
      PrintLine Str$("n%i\t", n), MyNew$(n)
   Next
   Inkey "Simple, isn't it?"
   
Exit
end start
OPT_Tmp2Asm   1

Output:
Recalled from file:
TheQ2=123456789012345678
fls2.f4=12.34000
fls2.f8=12345.67890000000
fls2.f10=123456789.123456789
fls2.fsrect.left=12
fls2.filler=123
The array, #5=12345
n0      Wow, strings created on 19.01.2011, 00:33:37
n1      Wow, strings created on 19.01.2011, 00:33:37
n2      Wow, strings created on 19.01.2011, 00:33:37
n3      Wow, strings created on 19.01.2011, 00:33:37
Simple, isn't it?


Store and Recall can now handle global or local variables and structures, too.

jj2007

Update of 20 January contains inter alia a modified ToolTips macro allowing to change the text.
The attached example uses this macro to display tooltips in English, Russian, Arabic and Chinese - provided you have the language packs installed.

hutch--

JJ,

Something in the demo is using ANSI. Its probably just the label (STATIC) control that in English says "Enter Text Here". If you select any of the other languages it shows ??????. I keep the east asian fonts loaded so that is not the problem. With the text message it shows arabic and chinese fonts with no problems in the edit control but not the static control.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: hutch-- on January 22, 2011, 02:12:01 AM
JJ,

Something in the demo is using ANSI. Its probably just the label (STATIC) control that in English says "Enter Text Here". If you select any of the other languages it shows ??????. I keep the east asian fonts loaded so that is not the problem. With the text message it shows arabic and chinese fonts with no problems in the edit control but not the static control.

Hutch,

Interesting. My (old, previously posted) version works fine, although the static displays always English, by design. Attached a new version that displays the welcome in the static window in four languages. For assembly, the latest MB build of 21 Jan is recommended.

Note the SkelWinMB_rsrc.asc is for use with the RichMasm editor. The resource section is at the end of the file, and gets exported to an rc file when you hit F6 for Build & Run. This is handy because you can directly edit your resources in the main source. WordPad and MS Word can read RTF, too, but they can't export the rc, of course.

(MultiLingual.zip is the image, do not open)

jj2007

Although RichMasm is not necessary to use the MasmBasic library, the editor is part of the MasmBasic package. I polished it a little bit, and added a help feature for MasmBasic. When hovering over a Basic keyword such as wMsgBox, an excerpt from the MB Guide will be displayed below or above with a greenish background. Example:


If you click fast enough into the green area, you can actually copy an example for pasting into the main edit window.
The next major MB update will include the new RichMasm and MbGuide.rtf versions, but I post them already here in case somebody wants to test it.

Farabi

Thanks jochen your package is good for beginner.  :U
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

jj2007

#217
Quote from: Farabi on January 28, 2011, 03:06:41 PM
Thanks jochen your package is good for beginner.  :U

Thanks for the feedback, Farabi :U

In the meantime, I have added Unicode versions for Lower$/Upper$ and Left$/Mid$/Right$. Example:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; download
   Init[/b]

   ; Unicode message boxes:
   wLet esi="Hello, What Is The Purpose Of This String?"
   wMsgBox 0, wCat$(wLower$(wLeft$(esi, 5))), "hello", MB_OK
   wMsgBox 0, wCat$(wUpper$(wMid$(esi, 8, 4))), "WHAT", MB_OK
   wMsgBox 0, wCat$(wLower$(wRight$(esi, 7))), "string?", MB_OK

   ; same boxes but ANSI:
   Let esi="Hello, What Is The Purpose Of This String?"
   MsgBox 0, Cat$(Lower$(Left$(esi, 5))), "hello", MB_OK
   MsgBox 0, Cat$(Upper$(Mid$(esi, 8, 4))), "WHAT", MB_OK
   MsgBox 0, Cat$(Lower$(Right$(esi, 7))), "string?", MB_OK

   Exit
end start

The attached example contains also two 'wide' message boxes with Chinese text; it looks as if upper and lowercase exist in Chinese - can somebody confirm (or not) that the text makes sense? Thanks.

EDIT: Assembly of the attached source requires at least MB version 29 January 2011 attached to the first post of this thread.

jj2007

Unicode to console (or file) with version 1 Feb 2011:

Quoteinclude \masm32\MasmBasic\MasmBasic.inc   ; Download
   Init
   wPrint wRes$(1201), wCrLf$   ; print a Unicode string from the resource stringtable, e.g. in Chinese
   
wInkey wChr$("Hit any key")   ; of course, you don't need Unicode to print English ;-)
   [/size]Exit
end start

Output:
在這裡輸入文字
Hit any key


See MbGuide.rtf for details. Printing Unicode to the console is very tricky, see e.g. the WriteConsoleW thread... make sure to test your code not only on your own machine.

dedndave

you got it to work   :U

jj2007

Quote from: dedndave on February 01, 2011, 12:15:34 PM
you got it to work   :U

Well, kind of. DOS prompt and launch from RichMasm work properly, and I just checked from Start/Run and Explorer and - surprise, surprise! - it worked. The previous version didn't ::)

Unicode with controls works always, with CreateWindowExW of course.
Quote         invoke CreateWindowExW, WS_EX_CLIENTEDGE, wChr$("edit"), NULL,
            WS_CHILD or WS_VISIBLE or WS_BORDER\
            or ES_LEFT or ES_AUTOHSCROLL or ES_MULTILINE, 0, 0, 0, 0,
            hWnd, IdEdit, hInstance, NULL
         mov hEdit, eax                     ; we have created an edit window
         sm eax, WM_SETFONT, hButFnt, 1      ; you may choose the small font here
         invoke SetWindowLongW, hEdit,      ; we subclass the edit control
         GWL_WNDPROC, SubEdit
...
         wSetWin$ hEdit=wRes$(123)

dedndave

Jochen,
i have been reading documentation regarding resource files - trying to learn stuff   :P
i was reading the section about the "langID" and "charsetID" parameters of the VERSIONINFO block, when your boggle came to mind
maybe proper version info would make the results more reliable   :U

http://msdn.microsoft.com/en-us/library/aa381058%28v=vs.85%29.aspx

(scroll down to about half the page)

you might also look into the resource file #pragma statement

jj2007

Thanks, Dave, will look into it, although a) it works fine now, b) charsetID 1200=Unicode has been among the values showing the odd behaviour...

dedndave

i noticed there is another value for "international"
not sure how it would differ from unicode - but...

jj2007

Dave,
I use...
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x0404, 65001
  END

... and the Version tab in "File properties" correctly shows Chinese (Taiwan). My suspicion was that the OS loader would use this info to set the console output page. Nope, it doesn't - the page is stuck at 850, and the console output is garbage.

Except with MasmBasic: wPrint wRes$(StringID) works like a charm. The secret is hidden in MB's wPrint macro :bg