flat assembler
Message board for the users of flat assembler.

Index > Windows > how to get length of a string "on the fly"?

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
Hi, some APIs (WriteConsole, for example) need number of characters to be passed as one of params. is there any macro that helps doing so?
for example, to be able to do smth like

invoke WriteConsole, [hStdOutput],szMessage,lengthof.szMessage,Var,0

...
szMessage db 'hello, world!',0
Post 15 Jul 2008, 08:42
View user's profile Send private message Reply with quote
Grom PE



Joined: 13 Mar 2008
Posts: 114
Location: i@grompe.org.ru
Grom PE
I use this:
Code:
struc dbs [data]
{
  common
  . db data
  .size = $ - .
}

invoke WriteConsole, [hStdOutput],szMessage,szMessage.size,Var,0
...
szMessage dbs 'hello, world!',0
    
Post 15 Jul 2008, 09:00
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
it works, thx a lot! I even extended it to get size with or without terminating null char Smile)

struc dbs [data]
{
common
. db data
.size = $ - . - 1
.sizez = $ - .
}
Post 15 Jul 2008, 10:24
View user's profile Send private message Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]
Post 16 Jul 2008, 18:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.