News:

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

2 quick questions

Started by brixton, June 04, 2005, 11:38:14 PM

Previous topic - Next topic

brixton

Hello all,

Just a couple of fast questions I would like answered! They are very simple so please don't laugh :lol

1)  If i was reading characters from a file on disk, how would I detect the end of a line?  Would I need to look for ASCII #10 (Ah), and if so, how would I go about looking for it?  Simple example maybe plz!  I am writing a program which filters out a variable string in a file based on the result of another string on a seperate line.

2)  Is it possible to launch an external program, but continue execution (ie. not wait until called program terminates)?

Many thanks!

ps. Other topic was locked, it's a shame, but I see your reasons.  It really was only innocent, it was for my parents to monitor my younger sister!  They didn't want to pay for any programs to restrict her, but wanted to keep an eye on her doings.  So I said i could help  :U
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

AeroASM


hutch--

If you don't need the extra control, you can use the old WinExec() as it maps to CreateProcess anyway.


fn WinExec,"YourApp.exe",SW_SHOWNORMAL


It is worth the effort to learn how to use CreateProcess as it offers you more control when you need it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

brixton

I thought WinExec halted the calling process :eek

Btw I have now written a long and fairly complicated program which parses and sorts a big list (several hundred KB) and writes desired output to a file.  It is probably extremely messy, but it is fast, tiny in size (it is 42 times smaller than a similar program my friend created in C), so I am very happy  :bg

One thing though is sometimes there is a sharing violation or similar while using the 16-bit compatible functions _lwrite and _lread, I don't know why they occur.. can anyone help?
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

hutch--

_lread and _lwrite should still work OK as they are 32 bit API functions, even though they are left there for 16 bit capacity when porting code. The share violatin probably depends on how your code is written, if the files you are trying to open are not locked by another application, then you mat be getting some lag with the opening and closing of files that is causing the problem.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

brixton

Quote from: hutch-- on June 06, 2005, 09:33:18 AMyou mat be getting some lag with the opening and closing of files that is causing the problem.

I don't think this is the case, as it opens both files at the start of the program and points to them using their file handles throughout.

If I post my (extremely messy) code, perhaps ye olde experts could give me a hand?  Also give me pointers (Excuse the pun?  Did I just make a nerd joke?!) on how to improve the code  :red :U
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

QvasiModo

1) There are several "end of line" formats. Windows and DOS use the 0Dh,0Ah while Linux (and I think Mac too) use just the 0Ah. Conceivably one might expect a 0Ah,0Dh pair or just a 0Dh character (but I guess you're safe ignoring these cases anyway).

The safest approach IMHO would be to scan for either 0Ah of 0Dh, then check the next char. If it's 0Dh or 0Ah (but not the same as the previous one) then consider it part of the end of line too.

brixton

What I did was just compare the return value of _lread to 0 after each read, and if it was equal then it's the end of the file  :dance:

I have finished the whole program now, it works perfectly, and is only 4.5KB (compiled, uncompressed) compared to my friend's filter in C which is about 170KB  :bg

If you're interested in source or executable, and usage for the filter, please say!
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

pbrennick

Qvasimodo,
Just for clarity...

DOS/Windows = 0D0A
*nix               = 0A
Mac               = 0D

brixton,
I think I would be interested in seeing the source.

hth,
Paul

Bieb


brixton

Well, it filters a bannerscan result log, and writes IPs which have a certain version in their response to a log file.
I wrote it for a friend.

The full source is here.

Bear in mind, this is one of my first programs in Assembly, and any tips are appreciated.  Just don't laugh at my messy code  :P
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

pbrennick

brixton,
You need not worry, nobody here is going to laugh and/or flame you.  The members of this forum are very well mannered and always want to help a newbe.

Paul

hutch--

Yep,

Keep in mind that everyone here had to learn assembler the hard way. My early stuff back around 1990 was so dangerous that I used to park it in a directory called "trashcan" as stuff that should NEVER be run. You knew when you made a real mess of it when the monitor displayed multicolour random blinking characters in colour text mode.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Another great way of doing that is to have a bunch of pocket change fall out and onto your video card. :toothy
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

brixton

pbrennick,

Thanks for the kind words, I have been looking at this forum for quite a while now (I first registered in mid-2004 sometime I think, on old forums, but I wasn't really much into assembly at that time), and I noted that most forumers were friendly and willing to help, which is great!  :cheekygreen:

hutch--,

That sounds pretty bad.. The only way I get my screen to do that is to overclock my old GeForce4 Ti4200 a little too much  :bg
Oh, and by the way, you look like my Uncle who lives in Perth, WA.  My father is from there (hence I am half Australian, and have a passport & citizenship :dance:)

Mark Jones,

Did you ever do that?  Poor card!  :'(
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..