Any one know how to do this? thank
Write a simple text-formatting program that produces neatly printed
output from input text containing embedded command lines that
determine how to format the output; all lines begin with a period are
command lines. The task of the program is to collect words from input
lines, fill output lines with those words, adjust the margins, and
print the result. Your programs should handle the commands shown in
Table 1 and should make use of functions.
Table 1 Text formatting commands for Lab #2
Command
..ce n
..ce
..in ±n
..in n
..in
..po ±n
..po n
..po
..ll n
..ll
..ls n
..ls
..sp n
..sp
..ad
..na
Description
Centre the next n lines (n might be 0)
Centre the next line
Increase (decrease) the indentation by n spaces
Set the indentation to n spaces
Reset indentation to default (0 spaces)
Increase (decrease) the left margin (page offset) by n spaces
Set the left margin (page offset) to n spaces
Reset margin to default (10 spaces)
Set line length to n spaces
Reset line length to default (100 spaces)
Set interline spacing to n (n = 2 gives double spacing)
Reset to single spacing
Put (n * CurrentLineSpac ing) blank lines in the output
Put (1 * CurrentLineSpac ing) blank lines in the output
Start adjustment of right margin (default; works in fill mode only)
Stop adjustment of right margin
When the program is filling output lines with input words, it is said
to be operating in fill mode. When not operating in fill mode, lines
should be printed exactly as they appear in the input. When operating
in fill mode, the program also may have to pad each output line evenly
with blank characters to produce a straight right margin; the program
is said to be operating in adjust mode when operating in this manner.
When not in adjust mode, the program will fill output lines but the
right margin will be jagged.
Your program should begin execution using the following default
values: line length is 100 characters, line spacing is 1 (single
spacing), margin is 10 characters, indentation level is 0 characters.
The program begins execution in fill mode, adjusting the right margin.
These defaults should remain in effect until changed by the
appropriate commands. A period, question mark, or exclamation point
should be followed by 2 blank spaces in the output, unless it is at
the end of an output line. A new paragraph should be separated from
the previous by an extra CurrentLineSpac ing lines. 6 2741
"shoo" <yu******@gmail .com> wrote in message
news:1a******** *************** ***@posting.goo gle.com... Any one know how to do this?
Yes.
thank
You're welcome.
[snip homework assignment, accompanied by no
evidence of any attempt]
-Mike
shoo <yu******@gmail .com> scribbled the following: Any one know how to do this? thank
(Snip homework assignment copied more-or-less verbatim)
We don't do other people's homework for them. Please try it yourself at
first, and if you get stuck, show your code and explain what you are
having problems first. You can also ask your professor for help.
--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-------------------------------------------------------- rules! --------/
"Bad things only happen to scoundrels."
- Moominmamma
On 12 Feb 2005 21:58:08 -0800, shoo
<yu******@gmail .com> wrote: Any one know how to do this? thank
Yes, I've written three (one in CORAL-66, one in DEC Fortran-77, one in
C++). And various people wrote runoff, roff, nroff, troff, groff and
others...
I've rewritten parts from scratch, a version in C is used for formatting
help text in xcpp (http://www.keristor.co.uk/stuff/xcpp-0.5.6.tar.gz),
it took me about 30 minutes (it isn't quite as complete, and it doesn't
use the .xx format, but the principle is the same).
Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the output; all lines begin with a period are command lines. The task of the program is to collect words from input lines, fill output lines with those words, adjust the margins, and print the result. Your programs should handle the commands shown in Table 1 and should make use of functions.
You could get the code of groff, it's GPL.
Table 1 Text formatting commands for Lab #2
Sounds like homework/coursework to me.
Chris C
shoo wrote: Any one know how to do this? thank
Yes. After you do the exercise you will too. Write a simple text-formatting program that produces neatly printed output from input text containing embedded command lines that determine how to format the output; all lines begin with a period are command lines. The task of the program is to collect words from input lines, fill output lines with those words, adjust the margins, and print the result. Your programs should handle the commands shown in Table 1 and should make use of functions.
Table 1 Text formatting commands for Lab #2 Command
.ce n .ce .in ±n .in n .in .po ±n .po n .po .ll n .ll .ls n .ls .sp n .sp .ad .na Description
Centre the next n lines (n might be 0) Centre the next line Increase (decrease) the indentation by n spaces Set the indentation to n spaces Reset indentation to default (0 spaces) Increase (decrease) the left margin (page offset) by n spaces Set the left margin (page offset) to n spaces Reset margin to default (10 spaces) Set line length to n spaces Reset line length to default (100 spaces) Set interline spacing to n (n = 2 gives double spacing) Reset to single spacing Put (n * CurrentLineSpac ing) blank lines in the output Put (1 * CurrentLineSpac ing) blank lines in the output Start adjustment of right margin (default; works in fill mode only) Stop adjustment of right margin
When the program is filling output lines with input words, it is said to be operating in fill mode. When not operating in fill mode, lines should be printed exactly as they appear in the input. When operating in fill mode, the program also may have to pad each output line evenly with blank characters to produce a straight right margin; the program is said to be operating in adjust mode when operating in this manner. When not in adjust mode, the program will fill output lines but the right margin will be jagged.
Your program should begin execution using the following default values: line length is 100 characters, line spacing is 1 (single spacing), margin is 10 characters, indentation level is 0 characters. The program begins execution in fill mode, adjusting the right margin. These defaults should remain in effect until changed by the appropriate commands. A period, question mark, or exclamation point should be followed by 2 blank spaces in the output, unless it is at the end of an output line. A new paragraph should be separated from the previous by an extra CurrentLineSpac ing lines.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Va negvpyr <1n************ **************@ cbfgvat.tbbtyr. pbz>, lh******@tznvy. pbz fnlf... Nal bar xabj ubj gb qb guvf? gunax
Lrf, ohg gur fbyhgvba vf n pnershyyl thneqrq vaqhfgel frperg.
V pbhyq fubj lbh, ohg gura V'q unir gb znxr lbh jngpu ernyvgl
GI.
Jevgr n fvzcyr grkg-sbeznggvat cebtenz gung cebqhprf arngyl cevagrq bhgchg sebz vachg grkg pbagnvavat rzorqqrq pbzznaq yvarf gung qrgrezvar ubj gb sbezng gur bhgchg; nyy yvarf ortva jvgu n crevbq ner pbzznaq yvarf. Gur gnfx bs gur cebtenz vf gb pbyyrpg jbeqf sebz vachg yvarf, svyy bhgchg yvarf jvgu gubfr jbeqf, nqwhfg gur znetvaf, naq cevag gur erfhyg. Lbhe cebtenzf fubhyq unaqyr gur pbzznaqf fubja va Gnoyr 1 naq fubhyq znxr hfr bs shapgvbaf.
Gnoyr 1 Grkg sbeznggvat pbzznaqf sbe Yno #2 Pbzznaq
.pr a .pr .va ±a .va a .va .cb ±a .cb a .cb .yy a .yy .yf a .yf .fc a .fc .nq .an Qrfpevcgvba
Prager gur arkg a yvarf (a zvtug or 0) Prager gur arkg yvar Vapernfr (qrpernfr) gur vaqragngvba ol a fcnprf Frg gur vaqragngvba gb a fcnprf Erfrg vaqragngvba gb qrsnhyg (0 fcnprf) Vapernfr (qrpernfr) gur yrsg znetva (cntr bssfrg) ol a fcnprf Frg gur yrsg znetva (cntr bssfrg) gb a fcnprf Erfrg znetva gb qrsnhyg (10 fcnprf) Frg yvar yratgu gb a fcnprf Erfrg yvar yratgu gb qrsnhyg (100 fcnprf) Frg vagreyvar fcnpvat gb a (a = 2 tvirf qbhoyr fcnpvat) Erfrg gb fvatyr fcnpvat Chg (a * PheeragYvarFcnp vat) oynax yvarf va gur bhgchg Chg (1 * PheeragYvarFcnp vat) oynax yvarf va gur bhgchg Fgneg nqwhfgzrag bs evtug znetva (qrsnhyg; jbexf va svyy zbqr bayl) Fgbc nqwhfgzrag bs evtug znetva
Jura gur cebtenz vf svyyvat bhgchg yvarf jvgu vachg jbeqf, vg vf fnvq gb or bcrengvat va svyy zbqr. Jura abg bcrengvat va svyy zbqr, yvarf fubhyq or cevagrq rknpgyl nf gurl nccrne va gur vachg. Jura bcrengvat va svyy zbqr, gur cebtenz nyfb znl unir gb cnq rnpu bhgchg yvar rirayl jvgu oynax punenpgref gb cebqhpr n fgenvtug evtug znetva; gur cebtenz vf fnvq gb or bcrengvat va nqwhfg zbqr jura bcrengvat va guvf znaare. Jura abg va nqwhfg zbqr, gur cebtenz jvyy svyy bhgchg yvarf ohg gur evtug znetva jvyy or wnttrq.
Lbhe cebtenz fubhyq ortva rkrphgvba hfvat gur sbyybjvat qrsnhyg inyhrf: yvar yratgu vf 100 punenpgref, yvar fcnpvat vf 1 (fvatyr fcnpvat), znetva vf 10 punenpgref, vaqragngvba yriry vf 0 punenpgref. Gur cebtenz ortvaf rkrphgvba va svyy zbqr, nqwhfgvat gur evtug znetva. Gurfr qrsnhygf fubhyq erznva va rssrpg hagvy punatrq ol gur nccebcevngr pbzznaqf. N crevbq, dhrfgvba znex, be rkpynzngvba cbvag fubhyq or sbyybjrq ol 2 oynax fcnprf va gur bhgchg, hayrff vg vf ng gur raq bs na bhgchg yvar. N arj cnentencu fubhyq or frcnengrq sebz gur cerivbhf ol na rkgen PheeragYvarFcnp vat yvarf.
--
Enaql Ubjneq (2ercyl erzbir SBBONE)
"Znxvat vg uneq gb qb fghcvq guvatf bsgra znxrf vg uneq
gb qb fzneg barf gbb." -- Naqerj Xbravt This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: joes |
last post by:
Hello there !
I rendering a PDF with XSLT using Xalan and FOP.
I like to place in my article an image, so that the text is floating
around the image. I tried several things but it didn't work so far. I
found some hints that it should work with "fo:float" but it seems not
to work with apache's FOP, so has anybody out there any solution and
experience ?
example:
|
by: Jiri Palecek |
last post by:
I have a question on web authoring (probably HTML+CSS). Is it
somehow possible to put two words above each other inside a paragraph
so the result would be valid and render at least in Mozilla?
I mean this:
text text text text text text text text text text text text
text text text text text text text text text text text text
| is |
text text text txt | | text text text text ...
|
by: Buddy Ackerman |
last post by:
Apparently .NET strips these white space characters (MSXML doesn't)
regardless of what the output method is set to. I'm using
<xsl:text> </xsl:text> to output a tab character and
<xsl:text>
</xsl:text> to output a carriage return and line feed
but they get stripped at some point. I'm passing a StringWriter to the
XslTransform.Transform method. Anyway to get this to actually output the
tab and carriage and line feed characters?
|
by: Lance Geeck |
last post by:
I have a simple form where I am using a dataset called Client. On the data
entry screen, there are name, address, city state and zip.
I have the fields bound to the dataset field. (Properties screen: Data
bindings then Text )
When I run the program and make a change to an existing record in the City
text box, the Dataset value for this column is changed as expected. When I
check the HasChanges property it says false. I don't...
|
by: jweinberg1975 |
last post by:
I would like for users to be able to select from a small number of options
that come from a little drop down menu which then closes.
..
http://www.geocities.com/jweinberg1975/dropdown_on_text00.html
..
In order to see the behavior you should "mouseover" the white-on-black text
segment that says "omnis dolor repellend"
..
the thing is that I don't want for the whole space in the paragraph to be
empty. I just need for the little menu to...
| |
by: bbepristis |
last post by:
Hey all I have this code that reads from one text file writes to
another unless im on a certian line then it writes the new data however
it only seems to do about 40 lines then quits and I cant figure out why
any help would be much apprechiated
1.
Dim line_num As Integer
2.
Dim filename2 As String
3.
|
by: acecraig100 |
last post by:
I am fairly new to Javascript. I have a form that users fill out to
enter an animal to exhibit at a fair. Because we have no way of
knowing, how many animals a user may enter, I created a table with a
createElement function to add additional entries. The table has the
first row of input text boxes already in it. You have to click a button
to add another row. That seems to be working fine. How
do I pull the information from the input boxes...
|
by: jonniethecodeprince |
last post by:
Hi all,
I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file.
There are 50 Records in this file.
There are 5 colums of data I wish to display.
I want to display these records in groups of 10.
Based on the fact that the records I want are located in a separate file, how can I get these details to show on the form and manipulate the data to...
|
by: bluemountain |
last post by:
Hi there,
Iam new to python forms and programming too
I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2, TEXT3in entire file(file consisting of 150 lines) that is related to a particular id and get the sum of the, WRITES of TEXT1, TEXT2, TEXT3
ex: input file will be as below
Windows 2000 text text text text text text text
|
by: dpw.asdf |
last post by:
I have been searching all over for a solution to this. I am new to
Python, so I'm a little lost. Any pointers would be a great help. I
have a couple hundred emails that contain data I would like to
incorporate into a database or CSV file. I want to search the email
for specific text.
The emails basically look like this:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |