The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
August 26, 2019, 01:40:16 AM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Workshop
| | |-+  MasmBasic
« previous next »
Pages: 1 ... 13 14 [15] 16 17 ... 21 Print
Author Topic: MasmBasic  (Read 139657 times)
dedndave
Member
*****
Posts: 12523


Re: MasmBasic
« Reply #210 on: January 16, 2011, 06:42:17 PM »

that takes care of it - they can use chr$   Tongue

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
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #211 on: January 18, 2011, 11:32:24 PM »

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

Quote
include \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
   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:
Code:
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.

* DimFillStoreRecall.zip (11.56 KB - downloaded 191 times.)
Logged

jj2007
Member
*****
Gender: Male
Posts: 6011



Simple multilingual window
« Reply #212 on: January 21, 2011, 12:38:08 AM »

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.

* SkelWinMB_rsrc.zip (23.46 KB - downloaded 191 times.)
Logged

hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: MasmBasic
« Reply #213 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.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #214 on: January 22, 2011, 02:27:44 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)

* SkelWinMB_rsrc2.zip (24.28 KB - downloaded 192 times.)
* MultiLingual.zip (3.84 KB - downloaded 405 times.)
Logged

jj2007
Member
*****
Gender: Male
Posts: 6011



RichMasm editor
« Reply #215 on: January 27, 2011, 08:57:59 PM »

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.

* RichMasm.zip (68.37 KB - downloaded 189 times.)
* MsgBoxHelp.zip (15.37 KB - downloaded 391 times.)
Logged

Farabi
Neuroscientist Student
Member
*****
Gender: Male
Posts: 2409


MASM+OpenGL Fanatic


Re: MasmBasic
« Reply #216 on: January 28, 2011, 03:06:41 PM »

Thanks jochen your package is good for beginner.  ThumbsUp
Logged

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #217 on: January 29, 2011, 12:41:01 AM »

Thanks jochen your package is good for beginner.  ThumbsUp

Thanks for the feedback, Farabi ThumbsUp

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

Quote
include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init

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

* HelloWhatString.zip (12.08 KB - downloaded 167 times.)
« Last Edit: January 29, 2011, 08:31:35 AM by jj2007 » Logged

jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #218 on: February 01, 2011, 01:50:01 AM »

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

Quote
include \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 ;-)
   
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.
Logged

dedndave
Member
*****
Posts: 12523


Re: MasmBasic
« Reply #219 on: February 01, 2011, 12:15:34 PM »

you got it to work   ThumbsUp
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #220 on: February 01, 2011, 04:58:34 PM »

you got it to work   ThumbsUp

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

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

dedndave
Member
*****
Posts: 12523


Re: MasmBasic
« Reply #221 on: February 13, 2011, 03:10:49 AM »

Jochen,
i have been reading documentation regarding resource files - trying to learn stuff   Tongue
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   ThumbsUp

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
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #222 on: February 13, 2011, 07:25:19 AM »

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

dedndave
Member
*****
Posts: 12523


Re: MasmBasic
« Reply #223 on: February 13, 2011, 10:49:04 AM »

i noticed there is another value for "international"
not sure how it would differ from unicode - but...
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: MasmBasic
« Reply #224 on: February 13, 2011, 11:36:32 PM »

Dave,
I use...
Code:
  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 BigGrin
Logged

Pages: 1 ... 13 14 [15] 16 17 ... 21 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!