• Right Justify

    From DesotoFireflite@VALHALLA to All on Mon Dec 28 10:28:46 2020
    Is there a way for me to right justify the output of a file for a bulletin. Im using the below to get the stats, and it's just part of the total file.

    var tlogons = formatString(users[i].stats.total_logons, 5);

    var lastCallerStr = "\1h\1c" + tlogons + " " + "\1h\1c" + firstOn;

    It displays ok, but it's left justified
    212
    3
    1946
    56
    10214

    I want it to be right justified and show as
    212
    3
    1946
    56
    10214

    Is there a simple way to do this. Thanks in advance.

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com
    Valhalla II! - (GAP) - bbs.valhallabbs.com:24
    A Gamers Paradise - Over 150 Registered Online Game Doors!

    Home Of Odin's Maze Game Server!
    Come Play Trade Wars On Valhalla's T.W.G.S!

    --- SENILE.COM found...Out of Memory...
    ■ Synchronet ■ Valhalla Home Services ■ USA ■ http://valhalla.synchro.net
  • From Nightfox@DIGDIST to DesotoFireflite on Mon Dec 28 13:06:06 2020
    Re: Right Justify
    By: DesotoFireflite to All on Mon Dec 28 2020 10:28 am

    Is there a way for me to right justify the output of a file for a bulletin. Im using the below to get the stats, and it's just part of the total file.

    var tlogons = formatString(users[i].stats.total_logons, 5);

    var lastCallerStr = "\1h\1c" + tlogons + " " + "\1h\1c" + firstOn;

    It displays ok, but it's left justified
    212
    3
    1946

    I don't know what formatString() is, as it doesn't seem to appear in the Synchronet JavaScript object model - but you can use the printf() function to justify text. For format specifiers, text is right-justified by default with printf. You may need to specify a field width though (I don't remember for sure off the top of my head) You could use something like this (with a field width of 4):

    printf("\1h\1c%4d \1h\1c%4d", tlogons, firstOn);

    And if you're curious, if you really wanted to left-justify those, you'd use a - after the % sign:

    printf("\1n\1c%-4d \1h\1c%-4d", tlogons, firstOn);

    Also, as a side note, the 2nd \1h\1c is extraneous in the string you're printing, as the string already has the high and cyan attributes at that point.

    Nightfox

    ---
    ■ Synchronet ■ Digital Distortion: digitaldistortionbbs.com
  • From Digital Man to DesotoFireflite on Mon Dec 28 14:37:08 2020
    Re: Right Justify
    By: DesotoFireflite to All on Mon Dec 28 2020 10:28 am

    Is there a way for me to right justify the output of a file for a bulletin. Im using the below to get the stats, and it's just part of the total file.

    var tlogons = formatString(users[i].stats.total_logons, 5);

    var lastCallerStr = "\1h\1c" + tlogons + " " + "\1h\1c" + firstOn;

    It displays ok, but it's left justified
    212
    3
    1946
    56
    10214

    I want it to be right justified and show as
    212
    3
    1946
    56
    10214

    Is there a simple way to do this. Thanks in advance.

    var lastCallerStr = format("\1h\1c%5u \1h\1c%5u", tlogons, firstOn);

    That print the integers ('u' means unsigned integer) right-justified to 5 characters (minimum), using spaces for padding. If you wanted 0-padding instead, then you'd specify "%05u". If you want left-justification, use "%-5u".
    --
    digital man

    Rush quote #21:
    You can surrender without a prayer, but never really pray without surrender Norco, CA WX: 49.1°F, 89.0% humidity, 0 mph S wind, 0.49 inches rain/24hrs
  • From DesotoFireflite@VALHALLA to Nightfox on Mon Dec 28 18:28:22 2020
    Re: Right Justify
    By: Nightfox to DesotoFireflite on Mon Dec 28 2020 01:06 pm

    I don't know what formatString() is, as it doesn't seem to appear in the Synchronet JavaScript object model - but you can use the printf() function to justify text. For format specifiers, text is right-justified by default with printf. You may need to specify a field width though (I don't remember for sure off the top of my head) You could use something like this (with a field width of 4):

    printf("\1h\1c%4d \1h\1c%4d", tlogons, firstOn);

    thanks, I will give that a shot, and see what happens. Again, thanks

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com
    Valhalla II! - (GAP) - bbs.valhallabbs.com:24
    A Gamers Paradise - Over 150 Registered Online Game Doors!

    Home Of Odin's Maze Game Server!
    Come Play Trade Wars On Valhalla's T.W.G.S!

    --- FART(n): An audio test of one's waste-disposal system.
    ■ Synchronet ■ Valhalla Home Services ■ USA ■ http://valhalla.synchro.net
  • From DesotoFireflite@VALHALLA to Digital Man on Tue Dec 29 14:40:10 2020
    Re: Right Justify
    By: Digital Man to DesotoFireflite on Mon Dec 28 2020 02:37 pm

    var lastCallerStr = format("\1h\1c%5u \1h\1c%5u", tlogons, firstOn);

    That print the integers ('u' means unsigned integer) right-justified to 5 characters (minimum), using spaces for padding. If you wanted 0-padding instead, then you'd specify "%05u". If you want left-justification, use "%-5u". --

    Thanks Rob

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com
    Valhalla II! - (GAP) - bbs.valhallabbs.com:24
    A Gamers Paradise - Over 150 Registered Online Game Doors!

    Home Of Odin's Maze Game Server!
    Come Play Trade Wars On Valhalla's T.W.G.S!

    --- CAT (n.), Furry keyboard cover.
    ■ Synchronet ■ Valhalla Home Services ■ USA ■ http://valhalla.synchro.net
  • From DesotoFireflite@VALHALLA to Digital Man on Tue Dec 29 16:44:34 2020
    Re: Right Justify
    By: Digital Man to DesotoFireflite on Mon Dec 28 2020 02:37 pm

    var lastCallerStr = format("\1h\1c%5u \1h\1c%5u", tlogons, firstOn);

    That print the integers ('u' means unsigned integer) right-justified to 5 characters (minimum), using spaces for padding. If you wanted 0-padding instead, then you'd specify "%05u". If you want left-justification, use "%-5u". --

    Ok, I think I got that, and I have managed to make it work with different colors for anything that uses strictly numbers, but lets say there is a alias field, and a date field, if I use the u, which applies to intergers, I get <error> in the field, and if I leave out the padding and justifaction, I get a blank screen.

    var lastCallerStr = format("\1h\1c%5u \1h\1r%2u \1h\1g%2u", tlogons, age, sec);

    The above works as is, but what would I use instead of a u to format the alias and a date field with color. I tried to find the answer on my own looking at the js object model, but no luck. I guess what do i use in place of the u for text and dates.

    var lastCallerStr = "\1h\1b" + alias + " " + "\1h\1y" + lastOn;

    Thanks, as always. I beginning to think, that this is way over my head :(



    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com
    Valhalla II! - (GAP) - bbs.valhallabbs.com:24
    A Gamers Paradise - Over 150 Registered Online Game Doors!

    Home Of Odin's Maze Game Server!
    Come Play Trade Wars On Valhalla's T.W.G.S!

    --- Don't eat the yellow snow!
    ■ Synchronet ■ Valhalla Home Services ■ USA ■ http://valhalla.synchro.net
  • From Digital Man to DesotoFireflite on Tue Dec 29 15:15:12 2020
    Re: Right Justify
    By: DesotoFireflite to Digital Man on Tue Dec 29 2020 04:44 pm

    Re: Right Justify
    By: Digital Man to DesotoFireflite on Mon Dec 28 2020 02:37 pm

    var lastCallerStr = format("\1h\1c%5u \1h\1c%5u", tlogons, firstOn);

    That print the integers ('u' means unsigned integer) right-justified to 5 characters (minimum), using spaces for padding. If you wanted 0-padding instead, then you'd specify "%05u". If you want left-justification, use "%-5u". --

    Ok, I think I got that, and I have managed to make it work with different colors for anything that uses strictly numbers, but lets say there is a alias field, and a date field, if I use the u, which applies to intergers, I get <error> in the field, and if I leave out the padding and justifaction, I get a blank screen.

    var lastCallerStr = format("\1h\1c%5u \1h\1r%2u \1h\1g%2u", tlogons, age, sec);

    The above works as is, but what would I use instead of a u to format the alias and a date field with color. I tried to find the answer on my own looking at the js object model, but no luck. I guess what do i use in place of the u for text and dates.

    var lastCallerStr = "\1h\1b" + alias + " " + "\1h\1y" + lastOn;

    Thanks, as always. I beginning to think, that this is way over my head :(

    You would use %s instead of %u: https://en.wikipedia.org/wiki/Printf_format_string
    --
    digital man

    Synchronet/BBS Terminology Definition #33:
    FTN = FidoNet Technology Network
    Norco, CA WX: 57.3°F, 43.0% humidity, 11 mph ESE wind, 0.53 inches rain/24hrs
  • From DesotoFireflite@VALHALLA to Digital Man on Wed Dec 30 15:38:57 2020
    Re: Right Justify
    By: Digital Man to DesotoFireflite on Tue Dec 29 2020 03:15 pm

    You would use %s instead of %u:

    That was the ticket, thanks so much for putting up with all my stupid questions and such. I'm trying to learn the code by doing and practicing, but not always successful in my endevors, I haven't nailed down the node thing, that I asked about last week, but I'm still trying. Anyway, thanks for putting up with me.

    https://en.wikipedia.org/wiki/Printf_format_string

    This site helped me alot, thanks for pointing it out to me.

    Again, Thanks for all you do....

    SysOp: C.G. Learn, AKA: DesotoFireflite
    Valhalla Home Services! - (Synchronet) - bbs.valhallabbs.com
    Valhalla II! - (GAP) - bbs.valhallabbs.com:24
    A Gamers Paradise - Over 150 Registered Online Game Doors!

    Home Of Odin's Maze Game Server!
    Come Play Trade Wars On Valhalla's T.W.G.S!

    --- Old farts never die! They just smell that way...
    ■ Synchronet ■ Valhalla Home Services ■ USA ■ http://valhalla.synchro.net