Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 23 Nov 2014, 03:45
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon - Bash-based Basic-to-C converter/compiler
Post new topic   Reply to topic View previous topic :: View next topic
Page 35 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 33, 34, 35, 36 Next
Author Message
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Wed 10 Apr 2013, 15:36    Post subject:  

Dear Terry,

Since build 1.29 beta and also build 2.0, you can use "&" to concatenate strings. Smile That was somebody's request and Peter obliged...

With kind regards,
vovchik
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Wed 10 Apr 2013, 15:37    Post subject:  

New things all the time...!

It is a bit better and easier to use.

Thanks vovchik.
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Wed 10 Apr 2013, 15:59    Post subject:  

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.
.


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).

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
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Wed 10 Apr 2013, 16:09    Post subject:  

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...
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Wed 10 Apr 2013, 16:23    Post subject:  

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.
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 887

PostPosted: Wed 10 Apr 2013, 17:15    Post subject:  

PaulR wrote:
I Maybe I can convert these on the fly somehow....

.


Paul,

Here you go-
Code:
 pngtopnm FILENAME.png >FILENAME.pnm
ppmtoxpm FILENAME.pnm >FILENAME.xpm


Two steps - first convert .png file to .pnm file then .pnm to .xpm.
I think those commands are standard in Puppies.

Cheers,
s

EDIT: actually I think you could just pipe it straight through-
Code:
 pngtopnm FILENAME.png | ppmtoxpm  >FILENAME.xpm
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Wed 10 Apr 2013, 18:52    Post subject:  

Or... Use vovchik`s picscale.

It converts most pic. types to any of the other types.
Back to top
View user's profile Send private message 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Thu 11 Apr 2013, 09:52    Post subject:  

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... Very Happy

- 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 Confused


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
Back to top
View user's profile Send private message 
miriam


Joined: 06 Dec 2006
Posts: 281
Location: Queensland, Australia

PostPosted: Sun 12 May 2013, 12:03    Post subject:  

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/view/svn/general/imlib2.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.

_________________
A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send private message Visit poster's website 
PaulR

Joined: 04 May 2005
Posts: 248
Location: UK

PostPosted: Sun 12 May 2013, 13:25    Post subject:  

Cheers Miriam, I'm sorted but no doubt others will find that info very useful Smile

Paul
Back to top
View user's profile Send private message 
miriam


Joined: 06 Dec 2006
Posts: 281
Location: Queensland, Australia

PostPosted: Sun 12 May 2013, 17:16    Post subject: Linux From Scratch
Subject description: very cool project
 

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...

_________________
A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send private message Visit poster's website 
e_mattis


Joined: 20 Dec 2012
Posts: 114
Location: Williamston, SC

PostPosted: Fri 17 May 2013, 00:07    Post subject: Help needed
Subject description: comparing text within an array then creating new array with unique entries
 

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 Shocked ) 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 Mad

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

.
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 5042
Location: Arizona, U.S.A.

PostPosted: Fri 17 May 2013, 02:13    Post subject:  

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:
Code:
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

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..!
.

Last edited by sunburnt on Fri 17 May 2013, 17:01; edited 3 times in total
Back to top
View user's profile Send private message 
miriam


Joined: 06 Dec 2006
Posts: 281
Location: Queensland, Australia

PostPosted: Fri 17 May 2013, 05:27    Post subject:  

If you have the text strings as lines in a file called list.txt, like
Code:
dog
cat
tree
world
dog
tree
Then you can list the unique strings like this:
Code:
sort list.txt | uniq >no_duplicates.txt
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.

_________________
A life! Cool! Where can I download one of those from?
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Fri 17 May 2013, 10:26    Post subject:  

Dear all,

If we take miriam's list as a basis:

Code:
dog
cat
tree
world
dog
tree


we can do this little bit of processing:

Code:
' ------------------
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


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
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 35 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 33, 34, 35, 36 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1043s ][ Queries: 12 (0.0173s) ][ GZIP on ]