09-23-2011
Please help. Complicated text file manipulation problem
Let me try my best to give you a picture of what I'm trying to do. Once again I'm sorry for the essay thats coming up.
I programmed a rather large library of script functions to deal with input, displaying ANSI block graphics, playing sounds, and refining the terminal and so on. I also designed a file format for displaying ANSI block characters in a complete group onto the screen.
The library is completely working. Graphics display properly, I can save a graphics file, and load the image on to terminal. Sound properly plays sequences of notes, etc.
Now here is where my problem arises. I hate designing graphics files for my library. I have to manually type in each ANSI escape code to make an image, and its extremely hard to make an image. So I decided to write an application to edit the ANSI graphic file images.
The program works, I set up the interface and painting works properly. BUT! I need to find a way to save the blocks on the screen into a file. This is what I did so far: I set it so whenever you paint onto the screen, it saves the respective escape code sequence into a file. That works, but the problem is, the escape codes get saved into the file sequentially in a line, so when you load the image, its just a line of colors.
So I'm asking if theres a way to navigate through the file with commands and add text, etc. so I can implement it in my paint program?
Can I for example, use "sed" to navigate around the file and add text, etc.?
Thank you for your time.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I need to remove lines from a text file that are less than certain length in UNIX. For example, test.txt file contains the following lines:
abcdefghijklmnopqrstuvwxyz.
123456789009876543211234567
This line to be removed.
zyxwvutsrqponmlkjihgfedcba.
The length of each line is supposed... (5 Replies)
Discussion started by: svannala
5 Replies
2. UNIX for Dummies Questions & Answers
I am a new unix user & I wanted to work with unix as it is very good in text manipulations. I need a little help. I will be grateful if someone can help me out.
I need help in grepping a pattern of numbers from one file to another file. Specific details are as follows:
File one contains only... (4 Replies)
Discussion started by: Ezy
4 Replies
3. Shell Programming and Scripting
I've got two files, both plain text. Each file is a datafeed of products, pipe delimited. The current file is in directory 1 and yesterday's file is in directory 2 (literally, those are the directory names). What I'm trying to do is compare the files and pull out products whose price has changed... (3 Replies)
Discussion started by: Daniel M. Clark
3 Replies
4. Shell Programming and Scripting
What I am trying to do is make a script that will add a port number within a section of a file if it already doesn't exist in that section of the file. The particular line that I would like to add the port number to in the file is formatted like this:
TCPPORTS="25 80 125 443 8080 10000"
For... (3 Replies)
Discussion started by: nullifx
3 Replies
5. Shell Programming and Scripting
Hi,
I need to write shell script for the scenario explained below -
datafile.txt
AcctNum,code,Region,,,,
12345451,AN ,abaab
12345452,AN ,xccxc
76677545,RP ,acxcc
43567878,RP ,afghh
32190900,AN ,afrfrf
87312345,AN ,aqaw
I have a text file (datafile.txt)... (1 Reply)
Discussion started by: ravigupta2u
1 Replies
6. UNIX for Dummies Questions & Answers
Hi I've two text files FILE_1 and FILE_2 as shown below:
FILE_1.txt
CO Contig1 342 12 11 U
GGGCTGACGTGGCCGCTAATACGACTCACTATAGGG*AGAGAAGTCATTTTCTTGTTTAG
BQ
35 35 35 50 50 50 50 50 50 50 50 60 65 65 65 65 65 65 65 65 65 65 65 65 50
AF GP5UOVN01AOPE0 U 1
AF GP5UOVN01AT8W3 U 1
... (1 Reply)
Discussion started by: Fahmida
1 Replies
7. Shell Programming and Scripting
I don't know if this is a big issue or not, but I'm having difficulties. I apoligize for the upcoming essay :o.
I'm writing a script, similar to a paint program that edits images, but in the form of ANSI block characters. The program so far is working. I managed to save the image into a file,... (14 Replies)
Discussion started by: tinman47
14 Replies
8. Programming
Hi
I have a requirement to write a script but not sure which is the best way to approach this
I have not worked in sed but I'm aware that its robust for file extraction requirements
I have a scripting task. I already developed the code in perl but the script is taking almost 2 mins for... (5 Replies)
Discussion started by: John Trevor
5 Replies
9. Shell Programming and Scripting
Hi Gurus,
I have a question
I have a flat file like below with three fields (3 rd field is amt)
ad|B|500
cc||100
dd|C|600
ee||900
Need to write a code in such a way that when second field is empty then do sum of third field
So in this case it will be 100 +900
I tried but no luck... (1 Reply)
Discussion started by: patricjemmy6
1 Replies
10. UNIX for Dummies Questions & Answers
Hello,
Supposing I had a huge list as follows:
TAC manufacturer Device Type
1392600 LG D959 LG-D959TS FeaturePhone
1409700 LG V410 FeaturePhone
35150806 LG F350S FeaturePhone
35165206 Samsung GT-E1200 FeaturePhone
35194505 Nokia Asha 200 FeaturePhone
but I want to make it look like... (3 Replies)
Discussion started by: Cludgie
3 Replies
ppmtoicr(1) General Commands Manual ppmtoicr(1)
NAME
ppmtoicr - convert a portable pixmap into NCSA ICR format
SYNOPSIS
ppmtoicr [-windowname name] [-expand expand] [-display display] [-rle] [ppmfile]
DESCRIPTION
Reads a portable pixmap file as input. Produces an NCSA Telnet Interactive Color Raster graphic file as output. If ppmfile is not sup-
plied, ppmtoicr will read from standard input.
Interactive Color Raster (ICR) is a protocol for displaying raster graphics on workstation screens. The protocol is implemented in NCSA
Telnet for the Macintosh version 2.3. The ICR protocol shares characteristics of the Tektronix graphics terminal emulation protocol. For
example, escape sequences are used to control the display.
ppmtoicr will output the appropriate sequences to create a window of the dimensions of the input pixmap, create a colormap of up to 256
colors on the display, then load the picture data into the window.
Note that there is no icrtoppm tool - this transformation is one way.
OPTIONS
-windownamename
Output will be displayed in name (Default is to use ppmfile or "untitled" if standard input is read.)
-expandexpand Output will be expanded on display by factor expand (For example, a value of 2 will cause four pixels to be displayed for
every input pixel.)
-displaydisplay
Output will be displayed on screen numbered display
-rle Use run-length encoded format for display. (This will nearly always result in a quicker display, but may skew the colormap.)
EXAMPLES
To display a ppm file using the protocol:
ppmtoicr ppmfile
This will create a window named ppmfile on the display with the correct dimensions for ppmfile, create and download a colormap of up to 256
colors, and download the picture into the window. The same effect may be achieved by the following sequence:
ppmtoicr ppmfile > filename
cat filename
To display a GIF file using the protocol in a window titled after the input file, zoom the displayed image by a factor of 2, and run-length
encode the data:
giftopnm giffile | ppmtoicr -w giffile -r -e 2
BUGS
The protocol uses frequent fflush calls to speed up display. If the output is saved to a file for later display via cat, drawing will be
much slower. In either case, increasing the Blocksize limit on the display will speed up transmission substantially.
SEE ALSO
ppm(5)
NCSA Telnet for the Macintosh, University of Illinois at Urbana-Champaign (1989)
AUTHOR
Copyright (C) 1990 by Kanthan Pillay (svpillay@Princeton.EDU), Princeton University Computing and Information Technology.
30 July 1990 ppmtoicr(1)