I finally got a serious understanding of DD, DB. (See DWORD Post) I got my text out of that DWORD with 1000's of zero's trailing it. So now it's All About STRINGS. Image that you got a string that you don't know the size of. GetFileSize is NOT the question here.

StrLen is the best i got so far, but it has limits. With it you have to declare the size that you want to get.... (remember we don't know the size and we don't want to use GetFileSize for whatever reason) My's is a long story...see previous post...

Imagine all you know is that the string start with the letter T with a bunch of : for separator throughout the string (or what every your case may be.)

All I want to do is get the whole string to the last KNOWN Charater : (Dump or Delete the rest or Move the string Out of There and Thats It . I now know how to do a few thing with strings, but i never have saw no one do something like this. Is this in the M32Lib... Do you know how to do it... Have you saw it before.
Thanks
Posted on 2001-12-24 22:15:32 by cmax
If you can't find a function to do it, it shouldn't be very hard..

That's why strings always have a NULL at the end. You just need to count bytes until you find the NULL. The NULL terminator is pretty much a "standard" but it is a problem if you need other NULLs in the string...

:)
Posted on 2001-12-24 23:42:27 by S/390
There has to be some parameters regarding the string: either a NULL termination or a stored size value. How is the string generated? Can you save the size from that operation? Does the string have a standard format - what are the rule governing the string?
Posted on 2001-12-24 23:50:11 by bitRAKE
"A DWORD moved to a DD Lenghth...Now it got 10000000's of zero's trailing the real string "

This string is already genarated from an ALLOCATE fuction. I just move it to a DD Lenghth. This is why i get 1000's of zero's trailing the text. It's all came from the pointer i guest with the good stuff leading it.

So, working with this is much differnt that a db. It got to be a way to move THAT Lenghth to ANOTHER FUCTION more Felxable than StrLen so that it can rip out ALL of what is needed....and leave the junk behind or whatever.

(Remember, we already moved it once to get to this mess)
I'm Hoping that someone know how....This is not standard stuff i beleive.

Its stuff that can or cannot be done by an experence assembler who experence it before. But I do believe that nothing is imposible with Assembler. I just don't know how to do it yet or was not told that this is Impossible.

But Hey bitRAKE if anybody know it got to be youuuuuuu.(:)

Thanks you both for the reply
Posted on 2001-12-25 00:40:32 by cmax
Don't copy all the zeroes in the first place. Find the length of the string and only copy what you need - be sure to keep atleast one of those zeroes.

Or, maybe I don't understand what your trying to do?
It's easier if I see some code. :)

I'd be more apt to go with S/390's wisdom.
Posted on 2001-12-25 00:55:09 by bitRAKE
I'm not stepping over S/390's. I just know a little about your style and it's deep.

Bla...Bla...Bla ............................my sH_t

invoke LocalAlloc, GMEM_FIXED, GatherText
mov MyText, eax

Bla...Bla...Bla ................................now i run it through my Proc

mov Lenghth,eax ....@ Quantum said put it in Lenghth to see something

invoke StrLen....@ Quantum gave me this lead more than i ever had Before

invoke WriteFile, hFile, MyText, Lenghth, addr dwBytes, NULL


ALL IS WELL....

But as i said before the StrLen is limited....because suppose you don't know the acual size. I like it this way. I just want to continue. GetFileSize may not work when coming off a DD.

By the way, I can do this easy 1,000,000,000x with edit boxes and static boxes but i wanted to avoid this too. In mem Only.

IT'S ALL ABOUT STRINGS NOW...My DWORD post almost turned into a novel....I talk to much....
Posted on 2001-12-25 01:17:41 by cmax
I am sorry, but it is late and I am having trouble understanding.

If you don't know the length of the string and it is followed by zeroes, then you can use invoke lstrlen,MyText then eax would be the length. You could code it yourself:
   mov eax,MyText

@@:cmp BYTE PTR [eax],0 ; test for zero
je @F
inc eax ; next byte
jmp @B
@@:sub eax,MyText
; eax is the length of the string
Edit: Reading other thread now - should have read it before...
Posted on 2001-12-25 01:32:40 by bitRAKE
"But Hey bitRAKE if anybody know it got to be youuuuuuu.( "

Thanks bitRAKE

Did i lie.

PS: I have not studie it yet but in the future if you see anything pretaining to this can you drop us a note (i know you would). I got to go back to the DWORD post and set a note so that anyone interested can follow the lead....That's where it all started. sending me to strings. If this work I'M IN HEVEN on EARTH.

Thanks Guys i did not expect this so quickly. The things ya do to keep us on top is AMAZEING.

No need to say "Us Rookey We Got your Back".

All new ideas would be Explored seriously.

cmax over and out
Posted on 2001-12-25 02:45:36 by cmax
bitRAKE, it did not work for me just yet. I got lazy . But what i did do was to test everything with M32Lib StrLen. Since none of my files exceed 150 byte I set StrLen at 150, and since it's in .txt files the little square don't show up in any of the .txt files. (I was testing it by writing .doc files)

But if that file is less than 150 byte it leave spaces only for each (what ever it is ) making the file size bigger on disk than what it actually is.

I figure I do it all this way than latter use some kind of edit function to delete all those space so that i can still prove to be efficient. Programmably i will be trading one step for another by doing this. But professionally i will still be lacking. ( no one will ever know... I can live with this )

Good Enough i think maybe. After 9 days and 9 nights it was all worth it educationally.

By the way you saying I'm sorry don't become you, We all know you are the Macro King. Thank you for taking time out to assist us. And that goes for the rest of you Educators. Can you imagine where we would be with out you....( Jumping out of REAL Windows and everything )

Thanks for responding and putting up with me.

Happy New Year
Posted on 2001-12-25 02:57:00 by cmax
cmax
StrLen should work for what you want this function counts the letters untill youget to the zero

lets say you have this in your code

.data
MyText dd ?
MyTextLength dd ?

...
blah blah..

iinvoke LocalAlloc ...blah
;now eax is a pointer to a buffer in memory
mov MyText, eax ;so you save it in MyText

;Next your proc moves the string into MyText Correct?

;then if you do this
invoke StrLen, MyText
; now eax holds the number of letters in the string pointed to by Mytext
; so you would save it
mov MyTextLenghth, eax

and now use MyTextLenghth when ever you need it so remember that each letter is one BYTE (even though a DWORD is used to point to it) and use MyTextLenghth as the number of bytes to write in WriteFile
Just remember that MyText contains the address of a memory buffer where your string is stored wich is a sequence of bytes
Posted on 2001-12-25 11:27:10 by Quantum
There are trim functions within the M32LIB to remove spaces from both sides of a string.
Posted on 2001-12-25 11:44:54 by bitRAKE
> bitRAKE:
> There has to be some parameters regarding the string: either a NULL
> termination or a stored size value. How is the string generated? Can you save
> the size from that operation? Does the string have a standard format - what
> are the rule governing the string?
>
>
> S/390:
> If you can't find a function to do it, it shouldn't be very hard..
>
> That's why strings always have a NULL at the end. You just need to count bytes
> until you find the NULL. The NULL terminator is pretty much a "standard" but
> it is a problem if you need other NULLs in the string...

Strings (under Windows) are terminated by null characters (bytes with all bits
set to zero). The identifier NULL represents a null pointer constant so it
should be reserved for use in a pointer related context.

If you want to terminate a string just use a plain 0 (zero) or two 0's (zeros)
if its a wide string. I think you guys were were confused with the NUL
character whose code is defined in the ASCII character set. Natively Windows
9x use the ANSI character set and the NT variants use the Unicode character
encoding.

Just be careful when using these terms.

regards,
Boggy
Posted on 2001-12-25 20:23:51 by Boggy
Boggy, your absolutely correct - it's easy to get lost in all the terminology, but it's very important when trying to communicate. I've always hated NULL and VOID. :grin: What the hell is wrong with 0 and {nothing}? If you asked me, I'd say this stuff was invented for the compiler - not people. Oh, someone stop me before I veer off into a Crusade... :tongue:
Posted on 2001-12-26 00:09:54 by bitRAKE
ok cmax,

i really have to say, that i'm totally confused about what you're trying to do finally. please let me summarize and tell me if this is what you would like to do:

You have a string, stored in a dword variable. that means, that there are following 3 zeroes after every character, right? it's like i explained you:

if you define a variable like this:
.data
myString dd "c","m","a","x",0

...in memory it looks like this:
"c",0,0,0,"m",0,0,0,"a",0,0,0,"x",0,0,0,0,0,0,0

i hope you understand that now.

and now you would like to get the string size, although there are zeroes, right? then lstrlen won't do the job, cause it checks for a terminating zero, it would find it a the second "character" (cause it is a zero). so you have to code your own procedure that does the job for you. now my final question (if this what i said is correct): do you want to get the size of the string, WITH the zeroes, or WITHOUT the zeroes?

let's say you want it without the zeroes, then this could probably do the job, provided that your string finally really looks like the one i explained you at the beginning of this post. with this code you get the number of characters of the string:



.data
myString dd "c","m","a","x",0
mylength dd 0

.code
push esi
lea esi,myString
@@:
cmp BYTE PTR [esi],0
je @F
inc mylength
add esi,4
jmp @B
@@:
pop esi



and if you would like the real length of the string, that means, with the zeroes, from the beginning to the end of the string, then just multiply mylength with four:



mov eax,mylength
mov ecx,4
mul ecx
mov mylength,eax


hope that helps now....

nop

p.s.: if myString is a pointer to a memory location with such a string, then just use mov esi,myString instead of lea esi,myString
Posted on 2001-12-26 04:20:49 by NOP-erator
Boggy,

Yes, technically you are correct. However the term "zero" can also lead to confusion. Are you talking about binary zero (00h) or ASCII zero (30h)?

"My string0"

is quite different than

"My string",0

NULL, as defined by WINDOWS.INC is

NULL equ 0

This eliminates the possibility of any confusion. The above string can also be written with the correct result as

"My string",NULL

And it really isn't a "size" issue.

cmp al,NULL
cmp ax,NULL
cmp eax,NULL

all generate the proper code.

Just my $.02 :)
Posted on 2001-12-26 06:07:03 by S/390
NOP-erator, it's all my fault I was trying hard to talk technically. There are a few people on the Board that get angry if you don't.

I should have just said....Have you ever gotton Blank Spaces, Black Square, Scribble Scrabble or a BUNCH of 0's at the end of your file after writing it...There a few ways to do write files and one of them that i sometimes expermiment with will do this.

It only lead me to the intrest of wanting to know how to remove such a thing from any string or whatever. So that i know what to do...It don't really matter how i got it... i just want to remove it with a procedure.

But the good thing about all this is that I will be an Real Assembler one day because I did not know the true detail of what DD,DB and so on was all about until now. Beleived me I will be reading much more deeper into things now.

I tried rTrim from M32Lib but had no luck at trying to remove these zero at the end of the line below. I had trouble with Dest:

Do you know how to remove all Zero or Blanks Spaces . . . .after the last :

Thanks


10/14/01-00738 :: 10/15/01-00262 ::0000000000000000000000000
Posted on 2001-12-26 09:52:34 by cmax

Boggy, your absolutely correct - it's easy to get lost in all the
terminology, but it's very important when trying to communicate. I've always
hated NULL and VOID. :grin: What the hell is wrong with 0 and {nothing}? If you asked me, I'd say this stuff was
invented for the compiler - not people. Oh, someone stop me before I veer off
into a Crusade... :tongue:


bitRAKE,
Yeah NULL and VOID are remnants of C, they're quite useful macros though
because they aid portability. For example a void * is
a generic pointer (can store a ponter to any data type) which is used a lot in
allocating memory of unknown data types i.e. malloc(), calloc(),
VirtualAlloc() etc.

But since we're only concerned with a single implementation (Windows) on a
specific architecture (IA32) in 32bit assembly language their sole purpose (NULL, VOID)
seems only to confuse asm programmers and pollute the namespace.

S/390,
> Yes, technically you are correct. However the term "zero" can also lead to
> confusion. Are you talking about binary zero (00h) or ASCII zero (30h)?

So then use the *correct* term: null-character; it has the bit pattern
of all-bits-zero, and terminates a string character string under Windows.
NULL is a pointer concept, it has nothing to do with the character that
terminates a string--using these two terms synonymously is not only confusing
but incorrect.

> "My string0"
>
> is quite different than
>
> "My string",0

Obviously, and from the context it's quite clear what the representation and
meaning of zero is supposed be in each case.

> NULL, as defined by WINDOWS.INC is
>
> NULL equ 0
>

This proves nothing; SECURITY_WORLD_RID, FILE_BEGIN and PIPE_TYPE_BYTE all
equate to zero as well: the representation of a type should have nothing to do
with how it is used.

> This eliminates the possibility of any confusion. The above string can also be
> written with the correct result as
>
> "My string",NULL

Well you've managed to confuse me ;P Think about the semantics of the idea
you're trying to express; a string constant terminted by a null pointer
constant--this simply doesn't make sense. All it does is create more questions
than it answer.

If you need to terminate a character sequence terminate it with a zero, if you
need to do a comparison with a memory address use NULL.

The NULL macro has very specific purpose; it is a null-pointer constant used
in pointer related expressions--using it for any other purpose simply because
"you can" or "it still produces the correct results" is IMO encouraging very a
bad programming practice.

The reason for NULL is because its representation can change from system to
system, it just so happens that under MS Windows 32 bit environments it has
the representation of all-bits-zero, a system could just as well define it to
be bit pattern of 0xdeadbeef if it wanted to. If you move you code to that
system its broken. But given the nature of what we're doing (asm programming)
is inherently unportable, that's a moot point.

> And it really isn't a "size" issue.
>
> cmp al,NULL
> cmp ax,NULL
> cmp eax,NULL
>
> all generate the proper code.

Yup, as I said to BitRAKE above we're working in such a specific environment
that we can afford to hardcode values that rely on the underlying
implementation and architecture, but being in a technical forum I still think
its important to be pedantic and make these kinds of distinctions.

>
> Just my $.02
My $.05

Cheers,
Boggy
Posted on 2001-12-26 10:38:49 by Boggy
cmax, then please tell me, where this string, data or whatever is stored....give me more details please....

nop
Posted on 2001-12-26 12:14:54 by NOP-erator
I Got It....I Got It..... This Below Should Explain It

Look at it as a file on disk C:\NewRecord.text and all you want to do is open the file....remove everything AFTER the last :
Than RE-SAVE it


This is in the file now
10/14/01-00738 :: 10/15/01-00262 ::0000000000000000000000000

This should be the file After the funtion
10/14/01-00738 :: 10/15/01-00262 ::


rTrim may be the key but i don't know how to use it.
Posted on 2001-12-26 20:23:10 by cmax
....remove everything AFTER the last


after the last what??? would be good if you could attach the file to your next post, so i can look at it. it still isn't clear for me. sorry......it's gettin funny that you're talking, and talking, and nobody understands you...... ;)

nop
Posted on 2001-12-27 04:52:34 by NOP-erator