|
Post by bigbass on Feb 24, 2020 19:21:06 GMT 1
Thanks Alex and vovchik works perfectly I agree with your approach of making a stand alone function for testing and it's easier to add those functions into bish or other bacon programs with less effort and as a plus a working demo code example! what more could you ask for P.S the stand alone working examples for me is a notebook whenever I forget how something is suppose to work it is so nice to focus on just one thing before doing all of the other electrical connections in your head Joe
|
|
|
Post by bigbass on Feb 25, 2020 8:00:20 GMT 1
here is a little function that does a big job
on the simple side it prints out an ascii list on the complex side it automatically assigns all of those values to the environment for you so that bacon and bash can use them easily
I needed this to solve some special problems with the shell (and its all pure bacon code )
Joe
DECLARE ASCII_DATA$ TYPE STRING DECLARE count TYPE int DECLARE LOCALENV$ TYPE STRING DECLARE LOCALVALUE$ TYPE STRING
'---255 for all codes or non extend codes 127 '---start at 32 which is a space '=================== FUNCTION ASCII_LIST$() '=================== count = 32 WHILE (count <= 126) ASCII_DATA$ = CONCAT$(STR$(count), " = ", CHR$(count)) INCR count PRINT ASCII_DATA$ LOCALENV$ = CONCAT$("asc",STR$(count)) LOCALVALUE$ = CONCAT$(CHR$(count)) SETENVIRON LOCALENV$,LOCALVALUE$ WEND RETURN FALSE END FUNCTION
CALL ASCII_LIST$
'--- now all of those values are available to the environment '--- about 96 now can be extened to 255
PRINT GETENVIRON$("asc38") PRINT GETENVIRON$("asc36")
'--- they can be used by the bash shell easily also ENV$ = EXEC$("echo $asc35") PRINT ENV$
|
|
|
Post by vovchik on Feb 25, 2020 9:45:24 GMT 1
Dear Joe (and Peter),
Thanks. I was also playing with a generated ascii table:
DECLARE asctab$ TYPE STRING PRINT LOOP$(i, 95, RIGHT$("0" & STR$(i + 31), 3) & " - " & CHR$(31 + i) & " | " ) TO asctab$ PRINT ALIGN$(asctab$, 80, 0, 0) PRINT PRINT asctab$ PRINT PRINT LOOP$(i, 95, RIGHT$("0" & STR$(i + 31), 3) & " - " & CHR$(31 + i) & " | " )
This should work, I think, but we are getting cut off at character 83:
032 - | 033 - ! | 034 - " | 035 - # | 036 - $ | 037 - % | 038 - & | 039 - ' | 040 - ( | 041 - ) | 042 - * | 043 - + | 044 - , | 045 - - | 046 - . | 047 - / | 048 - 0 | 049 - 1 | 050 - 2 | 051 - 3 | 052 - 4 | 053 - 5 | 054 - 6 | 055 - 7 | 056 - 8 | 057 - 9 | 058 - : | 059 - ; | 060 - < | 061 - = | 062 - > | 063 - ? | 064 - @ | 065 - A | 066 - B | 067 - C | 068 - D | 069 - E | 070 - F | 071 - G | 072 - H | 073 - I | 074 - J | 075 - K | 076 - L | 077 - M | 078 - N | 079 - O | 080 - P | 081 - Q | 082 - R | 08
Might this be a bug,or am I doing something wrong? It is cutting off at 512 bytes (before ALIGN$ comes into play).
With kind regards, vovchik
|
|
|
Post by Pjot on Feb 25, 2020 19:31:50 GMT 1
Hi vovchik, Yes, this is correct. As the documentation for PRINT mentions: So you have to change your code to, for example: PRINT LOOP$(i, 95, RIGHT$("0" & STR$(i + 31), 3) & " - " & CHR$(31 + i) & " | " ) TO asctab$ SIZE 4096
BR Peter
|
|
|
Post by vovchik on Feb 25, 2020 19:57:58 GMT 1
Dear Peter, Thanks for clarifying that SIZE option, and sorry for the trouble. I should indeed look at the documentation more carefully first, and not rely fuzzy memory. It now works fine, just as it was designed to do. With kind regards, vovchik
|
|
|
Post by vovchik on Feb 25, 2020 20:31:04 GMT 1
Dear all,
I have updated bish (see first post), adding ASCTAB (ascii table).
With kind regards, vovchik
|
|
|
Post by vovchik on Feb 26, 2020 14:16:29 GMT 1
Dear all,
Again a little update in the first post. I added a WC keyword. It is for convenience and does much of what UNIX/LINUX wc does.
With kind regards, vovchik
|
|
|
Post by vovchik on Feb 27, 2020 15:00:02 GMT 1
Dear all,
I have updated bish (in the first post) with a few meteo functions: METEO_FEELSLIKE, METEO_HUMIDEX and METEO_WINDCHILL. Bish help and perusing the bish source provide details.
With kind regards, vovchik
|
|
|
Post by bigbass on Feb 27, 2020 18:46:15 GMT 1
Hello vovchik undocumented in bacon but works also the formatting of output is always tricky but when the terminal is 80 (the default in geany) we can cheat a little I just changed just the first PRINT statement to use the FORMAT "%-10s" now I get a nice table formatted This may come in handy elsewhere '--- thinking in c heres a hacky hack but does the job '--- the minus sign means left align the 10 is how many characters '--- notice no new line is used PRINT ASCII_DATA$ FORMAT "%-10s" DECLARE ASCII_DATA$ TYPE STRING DECLARE count TYPE int DECLARE LOCALENV$ TYPE STRING DECLARE LOCALVALUE$ TYPE STRING
'---255 for all codes or non extend codes 127 '---start at 32 which is a space '=================== FUNCTION ASCII_LIST$() '=================== count = 32 WHILE (count <= 126) ASCII_DATA$ = CONCAT$(STR$(count), " = ", CHR$(count)) INCR count '--- thinking in c heres a hacky hack but does the job '--- the minus sign means left align the 10 is how many characters '--- notice no new line PRINT ASCII_DATA$ FORMAT "%-10s" LOCALENV$ = CONCAT$("asc",STR$(count)) LOCALVALUE$ = CONCAT$(CHR$(count)) SETENVIRON LOCALENV$,LOCALVALUE$ WEND RETURN FALSE END FUNCTION
CALL ASCII_LIST$
'--- now all of those values are available to the environment '--- about 96 now can be extened to 255 PRINT PRINT GETENVIRON$("asc38") PRINT GETENVIRON$("asc36")
'--- they can be used by the bash shell easily also ENV$ = EXEC$("echo $asc35") PRINT ENV$
|
|
|
Post by vovchik on Feb 28, 2020 21:06:08 GMT 1
Dear Joe (and all), Thanks for the ASCII table. Bish's ascitab has one advantage in that people who use wide terminals (> 80 columns), like Peter, are likely to get a mess. Asciitab produces 80 column output no matter what. The idea of having all chars easily accessible via the environment is nice. We can do that in bish a little more clumsily as a=$(bish chr 35) now. I fixed up the windchill calculation (there was an error with some values) in the latest bish. I have attached a little - still incomplete - weather script that uses BBC Meteo. It still needs polishing and some imperial-metric conversions, but it shows a lot of bish string handling in action with xml files. With kind regards, vovchik Attachments:bbc-meteo.tar.gz (1.16 KB)
|
|
|
Post by vovchik on Feb 29, 2020 14:16:58 GMT 1
Dear all, Here is a working (functional) weather script that uses bish (get the lastest from the first post) and xcowsay (sudo apt install xcowsay). I am also working on a similar 3-day forcast script for BBC, but am wondering how to lay it out. With kind regards, vovchik
|
|
|
Post by bigbass on Feb 29, 2020 17:26:31 GMT 1
Hello vovchik
your right (as usual) I shouldn't rely on a hack (it would be messy on a large terminal) I was really after the environment automation (actually for m4 use some characters cause problems there and thats why I was converting to ascii)
but for only the table here is a another short demo that solves the formatting problem
Tip : the count,6 could be changed to any column number you want if your terminal supports it you could use count,12 to give twelve columns nicely formatted
so the math is 126/6
And I like all the new improvements with bish great job! Joe
'--- ASCII table only using FORMAT only
DECLARE count TYPE unsigned char FOR count = 32 TO 126 STEP 1 PRINT count,count FORMAT " %3d - %c " IF MOD(count,6) == 0 THEN PRINT NL$ END IF NEXT PRINT
|
|
|
Post by vovchik on Mar 2, 2020 0:36:31 GMT 1
Dear all, Here is an updated BBC Meteo weather script that allows you to choose locations (using yad) and uses a dynamically generated svg report (displayed via xcowsay). The script makes extensive use of bish and shortcuts. The latest bish (which you need) is in the first post. Adjust the script for the bish.inc location, and make certain bish itself is in the executable path. You can edit the SHOWMENU function to suit your location interests. Let me know how it works for you. You will need xcowsay and yad, both of which are in standard repositories. It seems to be working nicely in Mint and on my PI4 (Raspbian Buster). With kind regards, vovchik Attachments:yadbbc-meteo.tar.gz (5.23 KB)
|
|
|
Post by Pjot on Mar 2, 2020 18:30:34 GMT 1
Thanks vovchik! Especially the location Den Haag works well on my system For Mageia Linux, there does not seems to be a package for xcowsay, so I had to install that tool manually, but it works. Best regards Peter Attachments:
|
|
|
Post by vovchik on Mar 2, 2020 21:59:25 GMT 1
Dear Peter (and all), Thanks. It looks exactly the way it does on my machine, so I think everything works. I coudn't help myself today and had to produce a coronavirus alert which queries the EU Centre for Disease Prevention and Control for its latest statistics. It also requires bish, bish.inc and xcowsay - but not yad. The PI4 version uses fmt instead of ALIGN, since ALIGN still bombs on Pi and I don't really know why yet. I am investigating. Maybe Joe and Alex have some idea... With kind regards, vovchik
|
|