|
Post by alexfish on Mar 3, 2020 7:20:10 GMT 1
Hi Vovchik
Not sure what be wrong with ALIGN
however one can place text in a terminal using the esc commands
Example :: note Bacon PRINT can make a mess of the esc sequences hence use printf + bacon CLEAR does not clear the scrollback in a terminal so have done esc sequence Reset;
some bits
PROTO printf
SUB Reset printf("\x1b[0m") printf("\033\143");
END SUB
SUB MoveTo(int row, int col) printf("\x1b[%d;%df", row, col) END SUB
Reset MoveTo (2,9) PRINT "This text here as well"; MoveTo(9,15) PRINT "More text here as well\n";
BR Alex
|
|
|
Post by alexfish on Mar 3, 2020 7:48:24 GMT 1
if you know the height of the terminal the can force the height using "\n" can get the size of term from Bacon commands
say term rows = 99;
Reset MoveTo (2,9) PRINT "This text here as well"; 'force the bits below a terminal MoveTo(100,15) PRINT "More text here as well\n"; MoveTo(100,15) PRINT "More text here as well\n"; MoveTo(100,2) PRINT "More text here as well\n";
BR Alex
|
|
|
Post by alexfish on Mar 3, 2020 8:26:29 GMT 1
Hi Vovchik
have tested latest bacon
Pi3 and align is working
happy to note Bacon ALIGN$ works better than moveto term cap commands esp
if print to cairo or to an output file
BR Alex
|
|
|
Post by alexfish on Mar 3, 2020 12:07:20 GMT 1
Hi Vovchik see what you mean the bish version Argh! KEYWORD: align -------- ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause. Now looking BR Alex
|
|
|
Post by alexfish on Mar 3, 2020 13:07:59 GMT 1
hi vovchik
had a look at some bits and changes the args in bish.bac results for your picking
the bits from bishtest
not shue what this means but looks like 3 bits echo "$th""align""$bh" cat newlist.txt | ./bish align - 3 0
CASE "align" cmd_result$ = ALIGN$(var$[2], VAL(var$[3]), VAL(var$[4]), VAL(var$[5])) changed to
use 3 bits CASE "align" cmd_result$ = ALIGN$(var$[2], VAL(var$[3]), VAL(var$[4])) result
KEYWORD: align -------- dog cat tre e wor ld dog tre e 1 88. 8 333 .5
also getting bad here but only two args rquired
KEYWORD: merge -------- ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
BR Alex
PS
can only say as have mentioned some time back::
Hence to be sure of a pass & no bugs use a system that does not ignore this feature.
added::
have not delved to much into the code but are checking the arg count
and if arg count = foo then blagh foo
|
|
|
Post by vovchik on Mar 3, 2020 13:54:41 GMT 1
Dear Alex, Thanks for testing - and confirming the bug. Should I just remove the last argument from ALIGN$ in bish for the moment (until we figure out why it is happening with the margin arg)? ALIGN$ is useful and nice to have in bish. I also use it in the attached script. With kind regards, vovchik Attachments:quotes-djt.tar.gz (5.93 KB)
|
|
|
Post by alexfish on Mar 3, 2020 15:55:39 GMT 1
hi vovchik
according to the docs
ALIGN$ taks from 3 to 4 args
here need to find a method of passing the amount of args
And Then
of note: in paring args then if val is require then check should also be done to see if all the bits for that arg are all digits
#ifndef IsDigit #define IsDigit(a) ( ( a >= '0' ) && ( a <= '9' )) #endif #ifndef IsNumber #define IsNumber(a) ( ( a >= '0' ) && ( a <= '9' ) || a == '.' || a==',') #endif
I use these macro funtions for the above: but can convert to BaCon
in this fashion :: basic
int t=0; int ck=0;
FOR t = 0 TO LEN(arg)
IF (IsDigit(arg[t])) THEN
ck=1 ELSE ck=0 BREAK END IF
NEXT
IF ck THEN 'DO STUFF HERE END IF
food for thought
BR Alex
|
|
|
Post by alexfish on Mar 3, 2020 16:26:38 GMT 1
hi vovchik
if change the arg in align
cat newlist.txt | ./bish align - p 0 this is the result
-------- KEYWORD: align --------
-------- no list in there
BR Alex
|
|
|
Post by vovchik on Mar 3, 2020 17:18:30 GMT 1
Hi Alex,
But this is OK:
cat newlist.txt | bish align - 1 0
The var p is 0 (uninitialized), so I think ALIGN$ is doing what it should in a zero-length case.
With kind regard, vovchik
|
|
|
Post by alexfish on Mar 3, 2020 19:58:11 GMT 1
Hi Vovchik
Now look at this bit this in relation to the vars passed = 5 and now works with 4 in ALING$
IF var$[2] = "" THEN cmd_result$ = "Commands: " & NL$ & ALIGN$(REPLACE$(cmds$, "|", " "), 60, 0) & NL$
I be puzzled by what is in the cmd$ and why the Replace "|" when that first arg should be a string var as said puzzled at what it is doing?
is passing more args into the ALIGN$ than its Max ?
BR Alex
|
|
|
Post by vovchik on Mar 3, 2020 21:39:32 GMT 1
Dear Alex,
I see what you mean, and think you have diagnosed it properly as some kind of maxargs problem. Peter suggested that it might be a problem with the PI environment - i.e. shell environment, IFS etc., but I have played with those bits and not had any success. In any case, eliminating var$[5] fixes it, and I may have to add a PAD$ function to add margins (or other chars). I have that function floating around somewhere.
With kind regards, vovchik
|
|
|
Post by vovchik on Mar 3, 2020 23:56:19 GMT 1
Dear all, Here is another bishy-bashy script to give you a new memorable phrase every day (podt). With kind regards, vovchik UPDATED 4 March 2020: The day changed since yesterday - and I was grabbing unnecessary data and missing some essential data when parsing the html. It now seems fixed and works again. Attachments:potd.tar.gz (1.9 KB)
|
|
|
Post by alexfish on Mar 4, 2020 0:30:29 GMT 1
hi vovchik the only thing i noticed using pi stdin 0 with 'echo foo | app' IE while(read(STDIN_FILENO, &ch, 1)>0){
} there is an extra bit at the which looks like foo 0
possible can try BaCon CHOP$ beyond that BR Alex
|
|
|
Post by vovchik on Mar 5, 2020 18:37:28 GMT 1
Dear all, Here is another bish-bash script to show "on this day" events and birthdays, using historynet. With kind regards, vovchik UPDATED 6 March 2020 (morning): Changed size of font in events display since, running this script the second day, I discovered that the list is of variable length (can have more than 16 entries), and it scrolled off the monitor today. Reducing the entry font size fixed it for now. Eventually, I should count the entries and adjust via calculation. Attachments:hotd.tar.gz (3.04 KB)
|
|
|
Post by vovchik on Mar 6, 2020 15:13:41 GMT 1
Dear all,
I updated bish - mainly added the PAD$ keyword. It adds a whitespace prefix aned can handle a string with newlines, adding the pad to each line. The update is in the first post.
With kind regards, vovchik
|
|