Solved

File formats

Posted on 2003-12-11
15
332 Views
Last Modified: 2013-11-22
Hello,

Can anyone please point me to a tutorial,some code or at least tell me some theory on creating my own text format (like .doc , .rtf , so on) and making it unreadable by Notepad (<-- bloody thing reads everything :D :D)
Thanks alot!
0
Comment
Question by:Prototype_T-104
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9920546
That's right - it WILL load anything - it don't matter what text format you use! However, if the first two letters of the file are MZ, then WordPad won't load it (it thinks it is an exe). Notepad will load it though.

If you don't want anybody to view your data, you need to encrypt it. This can be as simple as inverting every character or as complex as 128-bit encryption they use for Internet banking and suchlike. Inverting characters is just a case of c:=Chr(255 - Ord(c));

Geoff M.
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9920950
Try this:

-----------------------------------------------
type
  TMyCharType=record
    MChar: byte;
    MBold: boolean;
    MItalic: boolean;
.................
    MSize: byte;
  end;
  TMyFileType=file of TMyCharType;
------------------------------------------------

Read and Write file record to record (char to char) and you will have a richedit text

____________
But it is not optimized/
0
 

Author Comment

by:Prototype_T-104
ID: 9923213
Ummm could you please explain it a little bit? Thanks alot!
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 8

Expert Comment

by:gmayo
ID: 9923250
Which one of us are you responding to?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9924109
Your's replay was clear the Thespians was a little confusing :)
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9926786
Well, to be honest, Thespian's answer is not exactly efficient. For every character in the file, there'll be 4 characters saved, ie your file will be 4x bigger than it needs to be. And you'll STILL be able to read it with NotePad.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9927060
Yes, are there any tutorials or examples on this matter??
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9927201
var f : file of TMyRec;
rec1, rec2 : TMyRec;

Write:
AssignFile(f, 'filename.txt');
Rewrite(f);
Write(f, rec1);
Write(f, rec2);
CloseFile(f);

Read:
AssignFile(f, 'filename.txt');
Reset(f);
Read(f, rec1);
Read(f, rec2);
CloseFile(f);

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9931287
So to reatin the full formatting i would have to write for each charachter their properties?!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9931331
No, that's inefficient. I'm starting to wonder exactly what you want though. Do you want something which Notepad users can't read (ie encryption) or do you want a custom text format (ie with formatting)?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933690
Well for start a custom text format, but later if it would be a nice feature to encrypt it. So for now its just a custom text format.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 95 total points
ID: 9933790
Ok, well one way would be to use some of the control characters to control formatting. For example, use #30 to turn on bold and #31 to turn it off. All the characters in between would be bold. Another way is to use special combinations of printable characters like HTML or RTF - <B> and </B> for HTML, RTS might be something like -{Bold}- but I don't know exactly.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933880
Hey now i am starting to get it... so i would write a parser that load each line, gets the formatting tag and formats the text accordingly!
Thanks alot so far Geoff you really are a big help!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9933896
That's right. Just make sure that the formatting characters can't be typed by a human, causing unwanted effects. For example, you don't want somebody to type "to boldly go where..." and have everything from the LY onwards in bold!

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933908
Ok thanks!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IdTelnet1DataAvailable handler freezes the Application 4 74
Create Database on Android via Delphi dbExpress 3 88
Magic Software info 18 130
control image tags in a string ? 12 128
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now