Sign in to follow this  
Followers 0

Problems reading *.vmg files (Nokia message file format)

4 posts in this topic

Posted

Hello there.

I'm kinda new here but i've been using au3 since March, to help with Dialog Boxes and Installations automation.

Now that I'm trying to bring au3 to file management, I'm having some problems reading .vmg files. These files (example attached. NOTE: The true file extension is .vmg, but the forum does not allow it to be uploaded) are created with Nokia Message Editor, from Nokia PC Suite for Nokia's Mobile Phones. When you copy sms messages from your phone to your PC, they are converted to .vmg files (each file for each message).

I'm posting the content of the example .vmg file below (Ctrl+C from Windows Notepad and direct unformatted Ctrl+V):

//-------------------------- begin .vmg file -------------------------//

BEGIN:VMSG

VERSION:1.1

X-IRMC-STATUS:UNSENT

X-IRMC-BOX:INBOX

BEGIN:VCARD

VERSION:2.1

N:

TEL:+351964651189

END:VCARD

BEGIN:VENV

BEGIN:VCARD

VERSION:2.1

N:

TEL:+400123456789

END:VCARD

BEGIN:VENV

BEGIN:VBODY

Date:21-12-2005 11:24:50

this is the text part of the sms message. it can contain virtually unlimited chars.

END:VBODY

END:VENV

END:VENV

END:VMSG

//-------------------------- end .vmg file -------------------------//

As you may observe, the content is perfectly splitted and organized. In Notepad, the content is in a single line, and line breaks appear as square boxes.

When I try to read content from this file into au3, every char is followed by an empty or unknown string. But cetain functions like FileRead() or FileReadLine() don't work properly. They just return one char at a time, even if I tell them to read 1000 chars...

Other functions like _FileCountLines() return NEGATIVE values and _FileReadToArray() returns ONE SINGLE char.

Is anybody there who can help me on this? Do I need to open those files in another way? Am I missing some vital information about file management, like... Does au3 only support plain text files?

Thanks in advance for your help...

Keep up the good work :P

test_msg.txt

Share this post


Link to post
Share on other sites



Posted (edited)

first line hex: 42 00 45 00 47 00 49 00 4E 00 3A 00 56 00 4D 00 53 00 47 00 0A 00

that means you need to strip all the nullchars from the file

this can be done useing the binary functions

(since strings are ended with 00)

and the 0A indicated a LINEFEED (@LF)

notepad needs 0A 0D (@CRLF) to break else it will show a box char

then just parse stuff you want with regexp.

dim $s_file = ''
dim $as_SRE = StringRegExp(StringTrimLeft(String(BinaryString(FileRead('index.php'))), 2), '(?:(..)..)*', 1)

for $i = 0 to UBound($as_SRE)-1
	$s_file &= Chr('0x' & $as_SRE[$i])
Next

ConsoleWrite($s_file & @LF)
Edited by w0uter

Share this post


Link to post
Share on other sites

Posted (edited)

(...)

StringRegExp(StringTrimLeft(String(BinaryString(FileRead('index.php'))), 2), '(?: (..)..)*', 1)

(...)

i didn't understand what the h*ll you were coding... Until I downloaded the BETA version and saw it all :lmao:

this is what i get when i stick to shiny final versions =)

this in fact works perfectly, and i bless you in this holy season for that :( but i'd like to understand better the '(?: (..)..)*' part... the help file is a bit complicated for a non-experienced-non-english guy... I've never dealed with hex and binary stuff... :"> shouldn't the '(..)..)' part be some sort of a certain number of chars? or does this combination translates to an hex '0'? Don't know, maybe I'm just retarded :) I gotta study this more deeply... :">

thanks for your help, indeed greatly appreciated! :P

Edited by footswitch

Share this post


Link to post
Share on other sites

Posted

(?:(..)..)*

tells it to repeat the pattern

pattern to return a byte (the char) and then skip a byte (the NULL)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0