BaCon - Bash-based Basic-to-C converter/compiler
Hehe, I realize both of those but the files I'm seeking could be anywhere. As it's probably a program that would only be run once speed isn't a major issue - if it was I'd probably be doing it straight in C (although that would take much longer to code as I'm well out of practice).sunburnt wrote: # PaulR; If you reduce the "find" to /usr or whatever you`re looking for, it be quicker.
Also, I think you`ll find that shell scripts are much better at doing strings.
And you end up needed the shell to interface with the O.S. and file systems anyway.
.
At some point I'm going to learn shell scripting but for now I'm still learning Linux and BaCon!
Thinking about it, I suspect there's another way to solve this problem anyway...
Cheers
Paul
PaulR; Shell scripting is Linux for the most part.
I coded Visual Basic for years ( very much like Bacon ).
When I tried scripting it was daunting at first ( pipe chaining commands ).
But then I realized an entire paragraph of code is needed in Basic to do what 1 line does in Bash.!
And again, you are using shell code in Bacon`s EXEC$ and SYSTEM commands.
I`m writing a pre-processor for Bacon, and it`s a pain in Bacon.
All it does is rewrite the Bacon code so it`s ready to run "bacon" on.
So a shell script will do this very well. I`d prefer it be Bacon code, but...
I coded Visual Basic for years ( very much like Bacon ).
When I tried scripting it was daunting at first ( pipe chaining commands ).
But then I realized an entire paragraph of code is needed in Basic to do what 1 line does in Bash.!
And again, you are using shell code in Bacon`s EXEC$ and SYSTEM commands.
I`m writing a pre-processor for Bacon, and it`s a pain in Bacon.
All it does is rewrite the Bacon code so it`s ready to run "bacon" on.
So a shell script will do this very well. I`d prefer it be Bacon code, but...
I know, I'm happy enough with the command line I just can't deal with all the arcane stuff and new syntax for scripting atm (having recently learned a good chunk of php and Java/Processing for no particular reason!).
The idea I had earlier is a non-starter so I've checked all the default icon locations in .jwmrc and they are all under /usr so I'll limit the search as you suggested - it's faster and eliminates the searching or /proc at a stroke.
The problem I have with icons not displaying seems to be Fluxbox related - all the problem ones are .png - obviously Fluxbox only likes .xpm. Maybe I can convert these on the fly somehow....
Thanks again
Paul
EDIT: Seems that the png problem is because this version of fluxbox is compiled without suitable support for png's.
The idea I had earlier is a non-starter so I've checked all the default icon locations in .jwmrc and they are all under /usr so I'll limit the search as you suggested - it's faster and eliminates the searching or /proc at a stroke.
The problem I have with icons not displaying seems to be Fluxbox related - all the problem ones are .png - obviously Fluxbox only likes .xpm. Maybe I can convert these on the fly somehow....
Thanks again
Paul
EDIT: Seems that the png problem is because this version of fluxbox is compiled without suitable support for png's.
Paul,PaulR wrote:I Maybe I can convert these on the fly somehow....
.
Here you go-
Code: Select all
pngtopnm FILENAME.png >FILENAME.pnm
ppmtoxpm FILENAME.pnm >FILENAME.xpm
I think those commands are standard in Puppies.
Cheers,
s
EDIT: actually I think you could just pipe it straight through-
Code: Select all
pngtopnm FILENAME.png | ppmtoxpm >FILENAME.xpm
I'm going to try compiling Fluxbox with png support - first problem, it requires imlib2 which doesn't appear to be on my system so far as I can see. So, a few questions...
- where should I obtain this library? It doesn't appear in package manager...
EDIT: I found the library and the source but neither archive contains the imlib2-config file that ./configure is calling for as far as I can see. Actually I'm not sure if I need the pre-compiled library or the source package
Everything else when running ./configure looks ok so once the imglib2 issue is fixed, if I go ahead and make/install will itoverwrite my existing Fluxbox or is it possible to install another version side by side?
Please excuse my Linux noobiness!
Cheers
Paul
- where should I obtain this library? It doesn't appear in package manager...
EDIT: I found the library and the source but neither archive contains the imlib2-config file that ./configure is calling for as far as I can see. Actually I'm not sure if I need the pre-compiled library or the source package
Everything else when running ./configure looks ok so once the imglib2 issue is fixed, if I go ahead and make/install will itoverwrite my existing Fluxbox or is it possible to install another version side by side?
Please excuse my Linux noobiness!
Cheers
Paul
Hi PaulR, I just stumbled on this page. You've probably solved your imlib2 problem by now, but just in case you haven't, the Linux From Scratch project has a page that links to the downloadable and gives more info on dependencies and so on.
http://www.linuxfromscratch.org/blfs/vi ... mlib2.html
Just one thing. The page's instructions on compiling don't really need to be so complex for Puppy. Just open a terminal in the folder of decompressed imlib2 contents.
./configure
make
make install
And it should be all done.
Cheers.
http://www.linuxfromscratch.org/blfs/vi ... mlib2.html
Just one thing. The page's instructions on compiling don't really need to be so complex for Puppy. Just open a terminal in the folder of decompressed imlib2 contents.
./configure
make
make install
And it should be all done.
Cheers.
[color=blue]A life! Cool! Where can I download one of those from?[/color]
Linux From Scratch
Actually, I need to remind myself to visit the Linux From Scratch project's pages more often, as it has so much useful info there. Basically it, and its sister projects, build versions of Linux totally from start (hence the name) and document the process in its entirety.
http://www.linuxfromscratch.org
Of course those Linux forms don't have the cool features of Puppy -- their Linux From Scratch LiveCD project is much more bloated (fills the CD) with less content and less features. However it does have the wonderful advantage of being almost completely documented. There is so much yummy information there...
http://www.linuxfromscratch.org
Of course those Linux forms don't have the cool features of Puppy -- their Linux From Scratch LiveCD project is much more bloated (fills the CD) with less content and less features. However it does have the wonderful advantage of being almost completely documented. There is so much yummy information there...
[color=blue]A life! Cool! Where can I download one of those from?[/color]
Help needed
Hey guys!
I'm having problems. I'm trying to take a file with some text strings and reading it in as an array. I need to be able to compare the array elements and create anew array of totally unique elements. the list i am using to learn how is as follows:
array[1] = "SP"
array[2] = "HP"
array[3] = "SP"
array[4] = "B-tip"
array[5] = "B-tip"
I need to create an array containing only the following:
array[1] = "SP"
array[2] = "HP"
array[3] = "B-tip"
I've been through the documentation and have some limited (last time I did things like this was over 30 years ago - before qbasic even ) programming experience. I think it used to be done in a double-loop (ie. For x = 1 to 5, for y = 1 to 5, etc) Of course that could just be for bubble loops...can't remember ...grrrr
I just can't seem to find a handle on it, so I turn to those more knowledgeable for assistance. Any help is appreciated!
Thanks!
E
.
I'm having problems. I'm trying to take a file with some text strings and reading it in as an array. I need to be able to compare the array elements and create anew array of totally unique elements. the list i am using to learn how is as follows:
array[1] = "SP"
array[2] = "HP"
array[3] = "SP"
array[4] = "B-tip"
array[5] = "B-tip"
I need to create an array containing only the following:
array[1] = "SP"
array[2] = "HP"
array[3] = "B-tip"
I've been through the documentation and have some limited (last time I did things like this was over 30 years ago - before qbasic even ) programming experience. I think it used to be done in a double-loop (ie. For x = 1 to 5, for y = 1 to 5, etc) Of course that could just be for bubble loops...can't remember ...grrrr
I just can't seem to find a handle on it, so I turn to those more knowledgeable for assistance. Any help is appreciated!
Thanks!
E
.
I just coded a solution for this.
It looks like you`re wanting to remove duplicate lines.
You don`t say what the delimiter is, I assume it`s NL$.
Read the file into a list and test it for dups. like this:
This code ignores any duplicate lines and makes an array.
I know Bash`s "uniq" will do the same, but I assume BaCon code is wanted.
Enjoy dude..!
.
It looks like you`re wanting to remove duplicate lines.
You don`t say what the delimiter is, I assume it`s NL$.
Read the file into a list and test it for dups. like this:
Code: Select all
OPEN File$ FOR READING AS file_
list$ = ""
WHILE NOT(ENDFILE(file_))
READ line$ FROM file_
IF ENDFILE(file_) THEN BREAK
IF INSTR(list$, line$) > 0 THEN CONTINUE
list$ = list$ & line$ & NL$
WHEN
CLOSE FILE file_
SPLIT list$ BY NL$ TO array$ SIZE Sz
I know Bash`s "uniq" will do the same, but I assume BaCon code is wanted.
Enjoy dude..!
.
Last edited by sunburnt on Fri 17 May 2013, 21:01, edited 3 times in total.
If you have the text strings as lines in a file called list.txt, likeThen you can list the unique strings like this:Then you can read the no_duplicates.txt file in using BaCon to do whatever else you want with it.
I don't know enough about BaCon to be able to give a fully BaCon solution, but it seems that if using the shell makes your task simpler it's worth using it.
Code: Select all
dog
cat
tree
world
dog
tree
Code: Select all
sort list.txt | uniq >no_duplicates.txt
I don't know enough about BaCon to be able to give a fully BaCon solution, but it seems that if using the shell makes your task simpler it's worth using it.
[color=blue]A life! Cool! Where can I download one of those from?[/color]
Dear all,
If we take miriam's list as a basis:
we can do this little bit of processing:
The function CAT is there just there for convenience - to read the 'list.txt' file into a string variable. There are many ways of doing this, but this is one of them. Note that it doesn't take care of numerics well. You would have to check for a numeric type (probably using REGEX) and then prepend the requisite number of space pads before sorting - not hard.
With kind regards,
vovchik
If we take miriam's list as a basis:
Code: Select all
dog
cat
tree
world
dog
tree
Code: Select all
' ------------------
FUNCTION CAT(STRING FILENAME$)
' ------------------
LOCAL fileline$, txt$ TYPE STRING
IF FILEEXISTS(FILENAME$) THEN
OPEN FILENAME$ FOR READING AS catfile
WHILE NOT(ENDFILE(catfile)) DO
READLN fileline$ FROM catfile
txt$ = CONCAT$(txt$, fileline$, NL$)
WEND
CLOSE FILE catfile
END IF
RETURN CHOP$(txt$)
END FUNCTION
' ------------------
FUNCTION UNIQ$(STRING org$)
' ------------------
' assumes OPTION BASE 0
LOCAL i TYPE NUMBER
LOCAL new$ TYPE STRING
SPLIT org$ BY NL$ TO tmp$ SIZE elements
SORT tmp$
FOR i = 1 TO elements - 1
IF tmp$[i] = tmp$[i - 1] THEN
tmp$[i - 1] = " "
END IF
NEXT i
SORT tmp$
JOIN tmp$ BY NL$ TO new$ SIZE elements
RETURN CHOP$(new$)
END FUNCTION
myoldlist$ = CAT("list.txt")
PRINT "Old list: ", NL$, myoldlist$
mynewlist$ = UNIQ$(myoldlist$)
PRINT "New list: ", NL$, mynewlist$
OPEN "newlist.txt" FOR WRITING AS newfile
WRITELN mynewlist$ TO newfile
CLOSE FILE newfile
With kind regards,
vovchik