Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

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 January 31st, 2006, 03:41 PM
GazouTG's Avatar
GazouTG GazouTG is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Quebec
Posts: 338 GazouTG User rank is Private First Class (20 - 50 Reputation Level)GazouTG User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 18 m 38 sec
Reputation Power: 5
Send a message via ICQ to GazouTG Send a message via MSN to GazouTG
Reading chr(26)

Hi.
I have a problem when trying to read a file containing the character 26
when trying to read this caracter, my position pointer det incremented by what look like a random number(skipping some bytes)
is there a way to read the ascii char 26 returning a variable containing chr(26) instead of substituing bytes.

example : creating all ascii char:

Code:
open "source.txt" for output as #1
for i = 0 to 255
    print #1,chr(i);
next


and then trying to read:
Code:
Open "source.txt" For Input As #1
dim longe
longe = lof(no1)
for i = 1 to longe
    caract = input$(1,#1)
    caractCode = asc(caract)
next


caractCode take values from 0 to 25 and then from 153 to 255
then the loop crash as it is trying to read past EOF

thx
__________________
-----------------------------------------
You're not the center of the Universe
You're just an ass in the space of time
-----------------------------------------

Reply With Quote
  #2  
Old January 31st, 2006, 05:43 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Writing actual control codes and reading them back can be iffy, as you've discovered. My guess is that when you get to ctrl-z which I believe is decimal 27, which is also the code for ESC, that code is seen by VB and it causes VB to do something.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old February 1st, 2006, 09:53 AM
Darius Darius is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 108 Darius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 16 m 54 sec
Reputation Power: 5
Change to binary the type of access

Open "source.txt" For Binary As #1

Reply With Quote
  #4  
Old February 1st, 2006, 10:27 AM
GazouTG's Avatar
GazouTG GazouTG is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Quebec
Posts: 338 GazouTG User rank is Private First Class (20 - 50 Reputation Level)GazouTG User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 18 m 38 sec
Reputation Power: 5
Send a message via ICQ to GazouTG Send a message via MSN to GazouTG
Quote:
Originally Posted by Darius
Change to binary the type of access

Open "source.txt" For Binary As #1

Thx but I've already tryed and it wont work either. I get the same result.

Reply With Quote
  #5  
Old February 1st, 2006, 10:31 AM
GazouTG's Avatar
GazouTG GazouTG is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Quebec
Posts: 338 GazouTG User rank is Private First Class (20 - 50 Reputation Level)GazouTG User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 18 m 38 sec
Reputation Power: 5
Send a message via ICQ to GazouTG Send a message via MSN to GazouTG
is there a way to get/set my File pointer position? I can alway skip misbehaving bytes

Reply With Quote
  #6  
Old February 3rd, 2006, 09:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Maybe if you explained what you're trying to accomplish it would help.

Information on VB6 file handling is here http://msdn.microsoft.com/library/e...eProcessing.asp

Reply With Quote
  #7  
Old February 6th, 2006, 08:41 AM
GazouTG's Avatar
GazouTG GazouTG is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Quebec
Posts: 338 GazouTG User rank is Private First Class (20 - 50 Reputation Level)GazouTG User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 18 m 38 sec
Reputation Power: 5
Send a message via ICQ to GazouTG Send a message via MSN to GazouTG
Quote:
Originally Posted by Doug G
Maybe if you explained what you're trying to accomplish it would help.

Information on VB6 file handling is here http://msdn.microsoft.com/library/e...eProcessing.asp


i'm trying to make a Vigenère cypher application using the ASCII table.

Reply With Quote
  #8  
Old February 6th, 2006, 02:56 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Quote:
Originally Posted by GazouTG
i'm trying to make a Vigenère cypher application using the ASCII table.

Oops, I have no idea what that is, unless it's a new kind of salad dressing or something

Anyway, read over the information on VB and files, I'm sure you'll find the answers there.

Reply With Quote
  #9  
Old February 6th, 2006, 03:06 PM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,641 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 3 h 14 m 36 sec
Reputation Power: 1902
why not using the ADODB.Stream object? as far as I know, VB has this component
and I'm using it in classic ASP to handle binary files just fine.

Reply With Quote
  #10  
Old February 7th, 2006, 02:47 PM
Scorpions4ever Scorpions4ever is offline
Mad Rater
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 126 Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level)Scorpions4ever User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 31 m 44 sec
Reputation Power: 8
Quote:
Originally Posted by Doug G
Writing actual control codes and reading them back can be iffy, as you've discovered. My guess is that when you get to ctrl-z which I believe is decimal 27, which is also the code for ESC, that code is seen by VB and it causes VB to do something.

Actually, ctrl-z is ASCII 26, not 27. You're correct in that ESC is ASCII 27, but that's not the issue here. In DOS, there were two kinds of file I/O (1. ASCII file and 2. Binary File), probably as a CP/M heritage. When performing file I/O in ASCII mode, the OS actually interprets certain control characters before passing them on to the program, whereas in binary mode, the data is passed through uninspected. As it happens, ASCII 26 is considered the EOF (End of File Character) and so, when the OS is reading the file in ASCII I/O mode and sees the character, it interprets it as end of file and stops reading any more, even if there is more data to read from the file. In binary I/O mode, it simply reads the data and passes it on to the program.

Contrast this with UNIX where file I/O is always binary. Unfortunately, this borked DOS behavior was also ported into Windows in the name of backward compatibility. This problem exhibits itself, even if you're not using VB for programming (C, C++, perl, python, ruby, Delphi etc.), since it is OS behavior rather than a function of the language. All these languages have a way to open a file in BINARY or ASCII mode (default is ASCII, due to DOS).
http://msdn.microsoft.com/library/d...l/vastmOpen.asp
http://msdn.microsoft.com/library/d.../vastmopenx.asp <-- Contains example for Binary
http://msdn.microsoft.com/library/d...l/vastmopen.asp
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.

Last edited by Scorpions4ever : February 7th, 2006 at 02:56 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Reading chr(26)


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT