Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

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


  • Please log in to reply
3 replies to this topic

#1 footswitch

footswitch

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 21 December 2005 - 12:28 PM

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

Attached Files









#2 w0uter

w0uter

    resreveR nA

  • Active Members
  • PipPipPipPipPipPip
  • 2,262 posts

Posted 21 December 2005 - 02:36 PM

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, 21 December 2005 - 02:46 PM.

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

#3 footswitch

footswitch

    Polymath

  • Active Members
  • PipPipPipPip
  • 206 posts

Posted 21 December 2005 - 05:18 PM

(...)
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, 21 December 2005 - 05:19 PM.


#4 w0uter

w0uter

    resreveR nA

  • Active Members
  • PipPipPipPipPipPip
  • 2,262 posts

Posted 21 December 2005 - 05:38 PM

(?:(..)..)*

tells it to repeat the pattern

pattern to return a byte (the char) and then skip a byte (the NULL)
My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users