Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-2007, 09:38 AM
paul. paul. is offline
Newbie
 
Join Date: Apr 2007
Posts: 6
Rep Power: 0
paul. is on a distinguished road
Default Writing to binary file

Ok I have only recently started with delphi and kind of got thrown in at the deep end so to speak.

I have a blank binary file that needs strings and booleans input from several lists in .txt files at a repetative address. I am not sure how to do this.

For example say the values in the namelist.txt were:
Code:
Paul
Michael
Andrew
Stacy
The output binary file needs to be something like this:
Code:
045061756C00000000000000000000000000000000000000000000000000000000000000
074D69636861656C00000000000000000000000000000000000000000000000000000000
06416E647265770000000000000000000000000000000000000000000000000000000000
055374616379000000000000000000000000000000000000000000000000000000000000
So it tells the length of the "name" then the "name" and every 36 bytes a name is input

Would appreciate it if someone could help me do this.
Thanks a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-13-2007, 12:36 PM
paul. paul. is offline
Newbie
 
Join Date: Apr 2007
Posts: 6
Rep Power: 0
paul. is on a distinguished road
Default

All I can come up with is this, it allows me to write Hello every 8 bytes

Code:
var
  binString1, myString2: shortString;
  binFile : File of string[8];

begin
  AssignFile(binFile, 'Test.bin');
  ReWrite(binFile);

  binString1 := 'Hello';
  binString2 := 'Hello';
  Write(binFile, binString1, binString2);

  CloseFile(binFile);

end;
This deletes the old file and writes to a new one. Also doesnt allow me to position where the bytes are input to.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-13-2007, 02:44 PM
paul. paul. is offline
Newbie
 
Join Date: Apr 2007
Posts: 6
Rep Power: 0
paul. is on a distinguished road
Default

Done it now nevermind thanks for reading
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-13-2007, 07:46 PM
Jordan's Avatar   
Jordan Jordan is online now
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 26
Posts: 5,864
Last Blog:
Performance or Maintai...
Rep Power: 20
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

That was fast, what was your solution?
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Don't hesitate to ask any questions that you have! Check out our ASCII Calculator!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-13-2007, 08:23 PM
paul. paul. is offline
Newbie
 
Join Date: Apr 2007
Posts: 6
Rep Power: 0
paul. is on a distinguished road
Default

It was under my nose the whole time, I just didnt realise it was compatable with binary and strings. I used TMemoryStream, which allowed me to adjust the position and then saved the memory stream to a file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 03:22 PM
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 300 08-13-2008 08:36 PM
Issue writing to file: pointer to a class which contains pointers to other classes Sheemer C and C++ 0 08-21-2007 01:17 AM
Writing to a File - Shell Script Help! dirkfirst General Programming 2 10-03-2006 06:02 PM
Determine if a file is binary Nightracer C# Programming 5 09-16-2006 02:26 PM


All times are GMT -5. The time now is 08:11 AM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 66%

Ads