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 by jj

Started by clamicun, December 04, 2015, 04:03:17 AM

Previous topic - Next topic

clamicun

jj, how are you doing

I am looking for a macro to change an us_date (2015-12-03) to de_date (03-12-2015).
The way "php explode" does.

$array = explode('-',$us_date);
$de_date = $arr[2]."/".$arr[1]."/".$arr[0];

Testing your Split$ Macro.
Yes it does the job, but why does it take about 10 seconds the first time ?
Then it works normally.

And..
How do I use the result after the job is done ?

jj2007

Hi Clamicun,

That delay with Split$() is mysterious, grateful if you could post code.

Convert U.S. date to German date as follows:

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals usDate$="2015-12-03", deDate$
  Init
  Let esi=Right$(usDate$, 2)+"."+Mid$(usDate$, 6, 2)+"."+Left$(usDate$, 4)
  Let deDate$=fDate$(TimeSF(esi), "dd.MM.yyyy")
  Inkey "German date: [", deDate$, "]"
EndOfCode


The other way round, DE->US:

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals usDate$, deDate$="03-12-2015"
  Init
  Let usDate$=fDate$(TimeSF(Replace$(deDate$, "-", ".")), "yyyy-MM-dd")
  Inkey "U.S. date: [", usDate$, "]"
EndOfCode

clamicun

The code is like in the example
;---------
include \masm32\MasmBasic\MasmBasic.inc   ; download

  Split$ MACRO src, array, delimiter:=<"-">   ; splits strings using a delimiter, by default: a space
  StringToArray Replace$(src, delimiter, CrLf$), array
  ENDM

   Init

splitcode_s:
   Split$ "2015-12-03", MySplit$()   ; create the string array MySplit$() using - as delimiter
splitcode_endp:

   push eax
   xor ecx,ecx
   PrintLine "Result"
   .Repeat
      Print Str$("\nString %i\t", ecx), MySplit$(ecx)
      inc ecx
   .Until ecx>=stack

   pop eax
   Inkey

   Exit
end start

clamicun

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals usDate$="2015-12-03", deDate$
  Init
  Let esi=Right$(usDate$, 2)+"."+Mid$(usDate$, 6, 2)+"."+Left$(usDate$, 4)
  Let deDate$=fDate$(TimeSF(esi), "dd.MM.yyyy")
  Inkey "German date: [", deDate$, "]"
EndOfCode

Does not work.
Returns "invalid use of register on line 5"

clamicun

By the way..
what this code has to do with the Split Macro, which I want to use ? 

jj2007

Quote from: clamicun on December 04, 2015, 05:23:32 AMDoes not work
Get the latest version.

> what this code has to do with the Split Macro, which I want to use ?

Nothing. It was you who mentioned Split$(), but I can't judge it because I don't see the context... complete example would be nice.

Under the hood, Split$() uses Recall, so file I/O could play a role. Again, without seeing the code, impossible to judge...

clamicun

include \masm32\MasmBasic\MasmBasic.inc
  SetGlobals usDate$="2015-12-03", deDate$
  Init
  Let esi=Right$(usDate$, 2)+"."+Mid$(usDate$, 6, 2)+"."+Left$(usDate$, 4)
  Let deDate$=fDate$(TimeSF(esi), "dd.MM.yyyy")
  Inkey "German date: [", deDate$, "]"
EndOfCode

ok, I installed MasmBasic 02.12.2015
above code runs - returns the right result.
Takes over 10 seconds the first time,then immediately.


"Nothing. It was you who mentioned Split$(), but I can't judge it because I don't see the context... complete example would be nice."

jj per favore !

That is what I wrote..

"I am looking for a macro to change an us_date (2015-12-03) to de_date (03-12-2015).
The way "php explode" does.
$array = explode('-',$us_date);
$de_date = $arr[2]."/".$arr[1]."/".$arr[0];"

So I am testing Split$ because it seems to do about the same job as explode (src,delimiter,dest)


include \masm32\MasmBasic\MasmBasic.inc   ; download

;syntax Split$ MACRO
;Split$ MACRO src, delimiter, array
; StringToArray Replace$(src, delimiter, CrLf$), array
; EXITM <eax>
;ENDM

.data
myyear    db 4 dup(?),0
mymonth db 2 dup(?),0
myday     db 2 dup(?),0
mysrc      db "2015-12-03",0
mydest    db 10 dup(?),0
 
   .code
   Init

   Split$ offset mysrc,"-",offset mydest   ; create the string array  using - as delimiter  ;Line 20

   Exit
end start

Returns a syntax error on line 20





jj2007

Quote from: clamicun on December 04, 2015, 07:11:00 AM
jj per favore !

That is what I wrote..

"I am looking for a macro to change an us_date (2015-12-03) to de_date (03-12-2015).
The way "php explode" does.
$array = explode('-',$us_date);
$de_date = $arr[2]."/".$arr[1]."/".$arr[0];"

So I am testing Split$ because it seems to do about the same job as explode (src,delimiter,dest)
...
Returns a syntax error on line 20

Scusa, non avevo capito :P

Split$ is a functional macro, i.e. it returns the number of strings obtained from the splitting. Here are two methods to use it:

include \masm32\MasmBasic\MasmBasic.inc

.data
; myyear    db 4 dup(?),0
; mymonth db 2 dup(?),0
; myday     db 2 dup(?),0
mysrc      db "2015-12-03",0
mydest    db 10 dup(?),0
mydate    dd ?

  Init

  For_ ct=0 To Split$(offset mysrc, "-", My$())-1
      PrintLine "[", My$(ct), "]"
  Next

  invoke lstrcpy, offset mydest, Cat$(My$(2)+"."+My$(1)+"."+My$(0))
  PrintLine "[", offset mydest, "]"

  Let mydate=My$(2)+"."+My$(1)+"."+My$(0)
  PrintLine "[", mydate, "]"
EndOfCode


Re the 20 seconds delay: mysterious. Check if an antivirus is active.

As you can imagine, I use MB a lot and on several machines (Win XP, 7-64, 8.1), but I have never seen such a delay. My sources always build almost immediately: *** Assembling and linking took 702 milliseconds ***

This is the RichMasm editor's source code, >17,000 lines. For ordinary hello world proggies, it's below 200 ms, linking included.

The library is very small in comparison to many other standard C libraries (Boost, QT, ...). MasmBasic.inc has now 14,000 lines, but in my tests the build times with ML (6.15 ... 10.0), JWasm and AsmC are identical to sources built only with Masm32.

clamicun

Tu sei un tesoro JJ,
molto grazie e buona notte

Farabi

One of my coleague when I worked at university was a Visual Basic heavy user. Great experience, but with low interest on learning new language. So as a replacement, I sent him MASM basic and easy code. Trust me, he know what he's doing. Each time I tried to rewrite the library system on the university I kept thinking about him, he could lose his job while at his age its hard to study a new thing. But we will see.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165