Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 21st, 2009, 10:03 PM
javaman javaman is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 33 javaman User rank is Corporal (100 - 500 Reputation Level)javaman User rank is Corporal (100 - 500 Reputation Level)javaman User rank is Corporal (100 - 500 Reputation Level)javaman User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 9 h 27 m 59 sec
Reputation Power: 5
Dealing with bytes

I am creating a file byte viewer/editor. The viewing part is pretty simple, using ADODB.Stream LoadFromFile and so on.
The problem is when it comes to writing back to the byte stream. I tried creating a Byte String (if that makes sense to you) using vbscript's chrB. But, that is, according to ADODB.Stream, only a kind of string, and not a byte array. Next, I tried changing the stream type to text, add the characters, and switch the type back bytes. The problem with that is that the stream changes those non regular characters to what it feels appropriate.
Then I tried Scripting.FileSystemObject. But when I entered those non regular characters into the write method it gave me an error.
Eventualy, I sort of settled on ADODB.Stream, and set the charset to unicode. This seemed to have retained the bytes I've entered. But, as you might have guessed, you get all those 00 bytes between them.
So, the work around for this is obvious: The text is entered into a new stream object. Then, you set the position to 2, to skip the first two bytes that are markers showing that it contains text. After that you make a loop for the length of the string, and at each loop you copy 1 byte to the original stream, and move position ahead one byte.
I'm non sure that it still doesn't mess up any characters. But if it does cause problems, there are still a couple of more tricks up my sleeve.
If anyone has a more straight forward way, please let me know.

I'm really sorry for not showing examples, but I wrote this from a phone.

Reply With Quote
  #2  
Old October 22nd, 2009, 01:15 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,880 Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)Nilpo User rank is General (90000 - 100000 Reputation Level)  Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1Folding Points: 214558 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 8 h 47 m 8 sec
Reputation Power: 967
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
You can find an example of this technique in my Compressed Folder class in the Code Bank forum.

http://forums.aspfree.com/showthread.php?t=258394

VBScript does not have native support for binary writing. This is a workaround. For more efficiency you should look to .NET.
__________________
Don't like me? Click it.

Scripting problems? Windows questions? Ask the Windows Guru!

Stay up to date with all of my latest content. Follow me on Twitter!

Help us help you! Post your exact error message with these easy tips!

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Dealing with bytes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek