Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Align

Aug
1,929
71
From http://sites.google.com/site/jlcprogrammingstuff/home/tcc/align

Code:
:: ALIGN.BTM
::
:: Demonstrate the use of the Variable Functions of the
::   ALIGN Plugin, available from;
::
::  https://sites.google.com/site/jlcprogrammingstuff/home/tcc/align
::
::  Written by Joe Caverly
::  Tested with Windows XP SP3, TCC 11.00.52
::
::
@echo off
@setlocal
if not plugin align plugin /l align
echo %@LALIGN[Left-Aligned,20]%@CALIGN[Centre-Aligned,20]%@RALIGN[Right-Aligned,20]
do kount = 1 to 25
  echo %@LALIGN[Line %kount,20]%@CALIGN[Line %kount,20]%@RALIGN[Line %kount,20]
enddo
if plugin align plugin /u align
@endlocal
@LALIGN left-aligns text into a string of x characters
@CALIGN centre-aligns text into a string of x characters
@RALIGN right-aligns text into a string of x characters

Joe
 
Nifty! Works here, and seems to deal sensibly with (a) strings longer than n characters, and (b) strings with leading/trailing spaces.

It doesn't like unquoted strings containing commas, though; and if the string is quoted, the quotes remain in the output. All three functions always expect exactly two arguments, right? I'd suggest that if the input string contains more than one comma, then the last one separates the two args -- everything before the last comma is a part of the string arg.
 
Nifty! Works here, and seems to deal sensibly with (a) strings longer than n characters, and (b) strings with leading/trailing spaces.

It doesn't like unquoted strings containing commas, though; and if the string is quoted, the quotes remain in the output. All three functions always expect exactly two arguments, right? I'd suggest that if the input string contains more than one comma, then the last one separates the two args -- everything before the last comma is a part of the string arg.

This works;

Code:
echo %@calign[%@quote[Hello, It's Me],30]
        Hello, It's Me
Joe
 
This works;

Code:
echo %@calign[%@quote[Hello, It's Me],30]
        Hello, It's Me
Joe

... You're right; the quotes I was seeing were quotes which I put around the function for testing, not the ones I passed in to it. My mistake.

A couple of other minor quibbles: error messages don't seem to go to stderr (or stdout either?); and in the case of a syntax error, the function ought to return some nonzero value (-1 works for me) so that TCC knows an error occurred and doesn't continue executing the erroneous command.
 
Back
Top