Hello all, I got two quick questions. First can anyone tell me how to
format the output of a hash in pairs in a table format like
a=1 b=2 c=3
d=4 e=5 f=6
I would prefer the list go down the left most row first but across would
be fine.
Second is there any tutorials or gems/librarys that will deal with
console formating on a screen scale rather than strings. I am thinking
the way aircrack-ng looks. I am not trying anything illegal, just one of
the few programs that I know look like what I want. A picture is at http://www.aircrack-ng.org/screenshots/aircrack-ng.gif .
running in irb i get no errors loading but the printf throws an error if
I put clib. in front of it. The scanf gets throws an error also. I know
I am doing something incorrectly but I don’t know what. Thanks for your
help and info.
Thank you guys that is perfect. I got one more quick question off
topic. Is there an equivalent in ruby to pythons ctype. All research I
have found shows writing code directly for use in ruby(like in the
pickaxe). What I would like to do is make calls directly to c libraries
that aren’t meant for ruby like system libraries.
The ‘dl’ package is certainly one of the most useful Ruby libs out there
and avery clever piece of work. It’s a shame it hasn’t been
documented/supported very well.
The following works on 1.8.6 and I believe it doesn’t in 1.9.
No doubt some gurus will be able to clarify.
The above is calling strlen which has simple parameters,
an 'I’nteger return, and a 'S’tring by reference.
(It’s too late in the night to do scanf, and the Standard library
already does scanf)
You can use this for any C routine, as long as you get the
parameter prototype string setup correctly.
Hi.
If you look in your ruby folders, you should find a file called dl.txt.
Rudimentary and cryptic documuntation, but reading it with a bit of
patience may help. It is some time ago that I looked it, and the best
doc I found was at http://www.jbrowse.com/text/rdl_en.html but at the
moment I get ‘access denied’ when I tried to go there.
The method I described earlier has served me very well and it is quite
easy once you get the hang of it.
Firtly, you tell DL where your library is :
lib1=DL.dlopen(library) # Open library
then you create ‘pointers’ to the routines you want, along with the
parameter prototype string. I remember there were quite a few parameter
code, but the only ones I ended up using were ‘I’ & ‘S’ without
problems.
Some others were “L” for long, “P” for pointer.
As long as you are clear about passing parameters by value or by
reference you should be ok. (I don’t do C, but I still manage)
func1=lib1[‘funtion1’,‘ISSSS’) # integer returncode +4 parameters passed
by reference
Then to call the function, you can use .call or []
returncode=func1.call(p1,p2,p3,“p4”).first
or
returncode=func1[p1,p2,p3,“p4”].first