Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to print two variables separated by tab in TACL Program

131 views
Skip to first unread message

ChinmaYT

unread,
Jan 7, 2010, 9:10:59 AM1/7/10
to
Hi Guys,


I want to print two variables on terminal seperated by tab

I am trying like following:
#SET VAR1 ABC
#SET VAR2 XYZ
#OUTPUT [VAR1][ASCII 9][VAR2]

I am using ASCII 9 i.e. a tab to put tab on terminal. But this is not
working.

Is there any way to put a tab on TACL?

Thanks

ChinmaYT

unread,
Jan 7, 2010, 9:18:59 AM1/7/10
to

Actually I am trying to print variables in tabular format. As variable
lengths are not same all variables are not coming one below other.

Doug Miller

unread,
Jan 7, 2010, 9:59:47 AM1/7/10
to
In article <42f69916-c0e4-4ae8...@j5g2000yqm.googlegroups.com>, ChinmaYT <chin...@gmail.com> wrote:

>On Jan 7, 7:10=A0pm, ChinmaYT <chinma...@gmail.com> wrote:
>> Hi Guys,
>>
>> I want to print two variables on terminal seperated by tab
>>
>> I am trying like following:
>> #SET VAR1 ABC
>> #SET VAR2 XYZ
>> #OUTPUT [VAR1][ASCII 9][VAR2]
>>
>> I am using ASCII 9 i.e. a tab to put tab on terminal.

ASCII is apparently some function in your own TACL library? It's certainly not
part of the TACL command set, at any rate.

>>But this is not
>> working.

"This is not working" is not a helpful description of the problem. What
happens, specifically? Do you get a diagnostic of some sort?


>>
>> Is there any way to put a tab on TACL?

Yes.

#SET /TYPE DELTA/ make^a^tab 9i
#SET tab [#DELTA /COMMANDS make^a^tab]

#OUTPUT [var1][tab][var2] == but as you note below, this may not be exactly
what you want. Read further.


>>
>> Thanks
>
>Actually I am trying to print variables in tabular format. As variable
>lengths are not same all variables are not coming one below other.

This is easily done with a combination of the COLUMN, WIDTH, JUSTIFY, and HOLD
options of the #OUTPUT and #OUTPUTV commands. For example:

#OUTPUTV /WIDTH 10, JUSTIFY LEFT, HOLD/ var1
#OUTPUTV /COLUMN 11, WIDTH 15, JUSTIFY LEFT, HOLD/ var2
#OUTPUTV /COLUMN 26, WIDTH 10, JUSTIFY LEFT/ var3

Keith Dick

unread,
Jan 7, 2010, 3:19:50 PM1/7/10
to

Another way to get a tab or other control character is to use a STRUCT variable:

[#DEF spc STRUCT
BEGIN
BYTE b VALUE 9;
CHAR c REDEFINES b;
END;
]

#OUTPUT [var1][spc:c][var2]

I got this by modifying an example in the TACL Programming Guide. I don't know whether it will insert spaces between the values of the three expansions. If it does and that is a problem, you might be able to eliminate the extra spaces like this:

#OUTPUTV var1 '+' spc:c '+' var2

I think the approach Doug described using COLUMN and WIDTH options on #OUTVAR probably is easier to work with just for producing nicely-formatted output.

I point out this other method in case you ever want to put escape sequences or other control characters into a string and find #DELTA a bit hard to understand (as I do). In this example, fields b and c were single characters, but they may be arrays if you need a sequence of special characters. If they are arrays, the expansion in #OUTPUT needs to be an array reference. For example, a three-character sequence would be [spc:c(0:2)]. I don't know what would be the proper reference in the #OUTPUTV case. I imagine it would be spc:c(0:2) but I am not sure.

Doug Miller

unread,
Jan 7, 2010, 6:14:56 PM1/7/10
to

>I point out this other method in case you ever want to put escape sequences or
> other control characters into a string and find #DELTA a bit hard to
> understand (as I do). In this example, fields b and c were single characters,
> but they may be arrays if you need a sequence of special characters. If they
> are arrays, the expansion in #OUTPUT needs to be an array reference. For
> example, a three-character sequence would be [spc:c(0:2)]. I don't know what
> would be the proper reference in the #OUTPUTV case. I imagine it would be
> spc:c(0:2) but I am not sure.

And you find that *easier* to use than #DELTA? The mind boggles. ;-)

For inserting non-printable characters into a variable, it seems to me that
#DELTA is far easier to use and understand than any of the other options.
Just build a DELTA command thus:

#SET /TYPE DELTA/ delta^cmd <n1>i <n2>i <n3>i ...

where <n1>, <n2>, <n3>, etc. are the numeric values of the ASCII characters
you want to insert, e.g. 9 for TAB, 27 for ESC, 7 for BELL, and so on (easily
determined by examining an ASCII code table).

Thus, to insert ESC SOH TAB BELL, use

#SET /TYPE DELTA/ delta^cmd 27i 1i 9i 7i

Then follow that with

#SET sequence [#DELTA /COMMANDS delta^cmd]

What could be simpler? <g>

Keith Dick

unread,
Jan 7, 2010, 6:50:12 PM1/7/10
to
Doug Miller wrote:
> In article <NuOdnUyud7163NvW...@giganews.com>, kd...@acm.org wrote:
>
> What could be simpler? <g>

You're one of those folks who just loved TECO, aren't you? <g>

I would never tell anyone comfortable with #DELTA not to use it, but I know many TACL users are utterly lost when trying to figure out how to use #DELTA to do anything. Most people find TACL STRUCTs very easy to understand since they are much like structures in languages they already know, so I wanted to point out that one can use STRUCTs to solve the problem if they don't want to get into #DELTA.

Doug Miller

unread,
Jan 7, 2010, 7:24:52 PM1/7/10
to
In article <yLCdnYg57Jqo7tvW...@giganews.com>, kd...@acm.org wrote:
>Doug Miller wrote:
>> In article <NuOdnUyud7163NvW...@giganews.com>, kd...@acm.org
> wrote:
>>
>> What could be simpler? <g>
>
>You're one of those folks who just loved TECO, aren't you? <g>

Never used that, actually -- my career pre-Tandem was spent on Big Iron (IBM
370 series). Got pretty familiar with DITTO on that platform, though...


>
>I would never tell anyone comfortable with #DELTA not to use it, but I know
> many TACL users are utterly lost when trying to figure out how to use #DELTA
> to do anything. Most people find TACL STRUCTs very easy to understand since
> they are much like structures in languages they already know, so I wanted to
> point out that one can use STRUCTs to solve the problem if they don't want to
> get into #DELTA.

Granted. I guess I'm one of the fortunate few that cottoned on to #DELTA
pretty quickly, and I've used it extensively. However, knowing that its
operation is not particularly intuitive, I've made sure to always thoroughly
comment every non-trivial #DELTA I've ever written.

TEP

unread,
Jan 8, 2010, 12:20:43 AM1/8/10
to

The main problem with #DELTA is the appalling documentation, so it
remains a complete mystery to most. .

But to return to the OPs question:
There is an option in the #OUTPUT command to specify the COLUMN,
wouldn't that solve his problem? He just wants to get tabulated lists,
if I understand correctly. Do they really need to be formatted with tab
characters?

T.

ChinmaYT

unread,
Jan 8, 2010, 4:47:03 AM1/8/10
to
Thanks Guys,

This helped me.

Doug Miller

unread,
Jan 8, 2010, 7:50:47 AM1/8/10
to

>The main problem with #DELTA is the appalling documentation, so it
>remains a complete mystery to most.

It could be better written, that's for sure. But it's a lot better than it
used to be.


>
>But to return to the OPs question:
> There is an option in the #OUTPUT command to specify the COLUMN,
>wouldn't that solve his problem?

Of course. I already posted a description of that a day or two ago.

>He just wants to get tabulated lists,
>if I understand correctly. Do they really need to be formatted with tab
>characters?

Actually, no. They do not need to be, and should not be, formatted with tabs.
Using the COLUMN and WIDTH options on #OUTPUT is the only way to go.

TEP

unread,
Jan 8, 2010, 5:54:32 PM1/8/10
to
Doug Miller wrote:
> In article <7qntm0...@mid.individual.net>, TEP <cncn...@gmax.com> wrote:
>
>> The main problem with #DELTA is the appalling documentation, so it
>> remains a complete mystery to most.
>
> It could be better written, that's for sure. But it's a lot better than it
> used to be.
>> But to return to the OPs question:
>> There is an option in the #OUTPUT command to specify the COLUMN,
>> wouldn't that solve his problem?
>
> Of course. I already posted a description of that a day or two ago.
Doug - my apology, I didn't page down your posting far enough.
T-
0 new messages