Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > big headache.., converting codes...


Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2003, 08:04 PM
Byan Byan is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 195
Unhappy big headache.., converting codes...


Ok I finally figured out how to convert from ANSI to RTF (just color)..., I can do it on my own but I can't seem to be able to make a function for it..., it just ends up as a mess I end up deleting....

I figured that one of you may be able to help me....

k, I will tell you how I can do it out of VB...

you take a common ANSI ESC code combined with a a string that will become the color that the code says it will...
(codes- http://www.bluesock.org/~willg/dev/ansi.html)
first of when I use ESC, it is really chr$(27), the ESC button

ESC[0;1;31;47mThis is Red
at the url you will find out this means that it will be displayed normally, boldly, red(bold) forground, white backround..

at the end it should say- This is Red

ok, now I need to use that to convert it to RTF coding so that it can be displayed..., and I should state that there will be times where different colors will be on the same line...

{{\colortbl;\red255\green0\blue0;} {\cf1 This is Red} }

um the colors are in a txt attached to this post


I have made a couple of attempts but at the end each of them ends up not making sence...,

thanx in advanced,
Byan
Attached Files
File Type: txt ANSI_color_RBG.txt (253 Bytes, 5 views)
Reply With Quote
  #2  
Old 12-05-2003, 08:19 PM
Byan Byan is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 195
Default

It seems what I need to do is do a bunch of splits but I can't seem to do so without making a mess....

first split the ESC[, so you will have arrays -
(0) #;#;#m$
(1) #;#;#m$
ect...

then split those from the m so you will have the code and the string apart.., only problem is that you may have m's inside the string..
(0) #;#;#
(1) $
(2) $
combine all the strings after 0...

then you have to split each peice of codes using the ";"
(0) #
(1) #
(2) #
proccess(to the rtf coding) each number and put the appropraite effect on the correct string from one split above....

and in the end you combine everthing and you will have a finished line with color coding...

i just can't seem to do this correctly...

thanx again,
Byan
Reply With Quote
  #3  
Old 12-09-2003, 03:31 PM
Byan Byan is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 195
Default

I know that someone here must know how to do this....

all I need to do is turn:

"{15;84;97;32}SomeString" in to an array -
str(0) = 15
str(1) = 84
str(2) = 97
str(3) = 32

the string ("{15;84;97;32}SomeString") will vary so the numbers could be anything, (the # from before look kinda confusing...)

with another string with the string afterwords.... (OtherStr = "SomeString")

I think that everyone was initmidated by all the fancy stuff in the coding above..., ignore the other stuff and help me with this..., this is a little easier to understand, but it is really no different the the above one...

thanx again,
Byan
Reply With Quote
  #4  
Old 12-09-2003, 03:33 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,883
Default

First find the string part between the { and } using the InStr() function.
Put this part in a temp string and use the Split() function to make it a dynamic array
Reply With Quote
  #5  
Old 12-09-2003, 03:58 PM
Byan Byan is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 195
Default

explain how to use the InStr() function to do so..., I can't seem to find out how to do so... I really dont know how to use this function.., I tried looking it up and it finds the position of string2 inside string1

instr(start, String1, String2)

how does this help me?

thanx again,
Byan
Reply With Quote
  #6  
Old 12-09-2003, 05:47 PM
Byan Byan is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 195
Default

I should also add that there maybe a series of there-
"{15;84;97;32}SomeString{15;84;97;32}SomeString{15;84;97;32}SomeString "

each set of {} needs to be matched up the the following SomeString...
also Somestring may have a } inside of it... (it can't have a { because of what the code I am going to use this with actualy is.., I doubt anyone is going to be using the ESC char (char$27) in the purpose I am going to be using this for...

I think this may complicate is alot more.., I was thinking that we could first split using the "{" so you will have an array Str-
Code:
'(dim Str is above) dim i as interger redim str(0 to ubound(Split(WholeString,"{"))) for i = 0 to ubound(Split(WholeString,"{")) str(i) = Split(WholeString,"{")(i) next 'Is there an easier way to transfer arrays? been doing it like this....

k now you have the str array-
str(0) = ""
str(1) = "15;84;97;32}SomeString"
str(2) = "15;84;97;32}SomeString"
str(3) = "15;84;97;32}SomeString"

now split using "}" and I am stuck here since I need to keep SomeString entact.., and it may have a "}", how will I tell if..., wait hmm.., maybe I just figured it out...

Code:
'(dim Str2 is above) for a = 1 to ubound(str) dim i as interger redim str2(1 to ubound(Split(str(a),"}"))) for i = 1 to ubound(Split(str(a),"}")) str2(i) = Split(str(a),"{")(i) if i >= 3 then str(2) = str(2) + str(i)'this way it will add all the other ones together if there are any end if next next

so now str2 arry-
str2(1) = 15;84;97;32
str2(2) = SomeString

Now one part I don't know how to do is erase the rest of the Str2(3 to whatever), I'll try redim Str2(1 to 2) to see if that works....



I just found out that I'll have to make somesort of other str2 thing since I can't have more than 1 of them.., I think I'll make a function to do this...

then I need to make another function that will do the spliting for the 15;84;97;32 I think i can do this....

is there anything I should change at all?

thanx again,
Byan
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
converting codes. Benzakhar General 3 11-11-2003 07:09 PM
Converting HTML color codes to VB WTSO Web Programming 5 06-19-2003 01:42 PM
Is anyone here able to crack codes? or know a site that does that? try &crack my code clockworkorange Game Programming 9 03-12-2003 03:29 PM
how to convert ascii codes to letters, and how to uncode letters to ascii codes? andreww General 1 04-29-2002 04:43 AM
List of color codes? CornMaster General 5 03-14-2001 09:04 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->