• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Bo
8-Feb-2013
[5471]
Kaj, now that I've had a chance to do some work with Red/System, 
it's amazing to me how much work you've already done on adding features!


Here's something that I think would really help out a lot of us who 
want to make use of all your hard work.  Would it be hard to create 
http://red.esperconsultancy.nl/index.htmlwith a link to all the 
Red stuff you've done?  The only way I found what I needed to download 
was by searching through AltME for links, and had to manually enter 
in things like Red-common, Red-C-library, Red-cURL, Red-GTK, etc.
Kaj
8-Feb-2013
[5472x6]
Thanks. A website is planned, but I haven't gotten around to it yet. 
I figure the time is better spent doing Red work
What I've done so far is the download.r script:
http://red.esperconsultancy.nl/Red-test/dir?ci=tip
If you combine it with Fossil, it will set up your entire environment 
automatically
It will also auto-update all bindings to new versions
Have you seen my 6502 emulator in Red/System yet? :-)
Bo
8-Feb-2013
[5478]
I saw that you wrote a 6502 emulator, but haven't had time to look 
at it yet.  Sounds like a fun project!
Kaj
8-Feb-2013
[5479]
It is. :-) If you run the download.r script, you'll get it automatically
Bo
8-Feb-2013
[5480x2]
Recalling from the days when I didn't have an assembler, I had most 
of the decimal equivalents of the commands remembered because I input 
values into memory manually when I was writing code.  Going back 
in my brain 20 years, I believe LDA (Load the accumulator) was 169. 
:-)
So 'with in Red/System is like 'context in R2?
Kaj
8-Feb-2013
[5482x3]
It's more like USE. CONTEXT exists as such in Red/System, but it's 
a compile time namespace instead of a runtime object
You first define a CONTEXT, then you can use it with WITH, or path 
notation
You're right about LDA #. :-) It's also $A9. I had the same problem, 
wrote a disassembler in Atari BASIC until I could get hold of an 
assembler, so also have a considerable part of my brain dedicated 
to such numbers :-)
Bo
8-Feb-2013
[5485x2]
With the following code:

#include %GTK.reds

with gdk [
	err: declare struct! [value [g/g-error!]]
	myimg: load-image "image.jpg" err
]

I get the following error:


*** Compilation Error: invalid literal syntax: [value [g/g-error!]]

If I change it to:

err: declare struct! [value [c-string!]]

I get the following error:


*** Compilation Error: argument type mismatch on calling: gdk/load-image

*** expected: [struct! [value [g/g-error!]]], found: [struct! [value 
[c-string!]]]
What am I missing?
Kaj
8-Feb-2013
[5487x2]
You can't use path notation on types. I've been trying to coerce 
Doc into implementing that, but he doesn't want to. :-/
So you have to use an extra WITH g [...]. You can combine that as 
WITH [gdk g] [...]
Bo
8-Feb-2013
[5489]
Aha!  That did the trick!
Kaj
8-Feb-2013
[5490x3]
By the way, if you only use images, you could do with including only 
GDK.reds. That would cut down on the dependencies
Instead of your struct definition, you can use g-error-reference! 
which is already defined in GLib.reds
There's an example of using load-image in GTK.reds in the icon function
Bo
8-Feb-2013
[5493x4]
Thanks!  When I use load-image, it looks like it is returning a pointer. 
 Is that correct?
For instance: 00DFD2B8
If 'load-image returns a pointer, how do I know when I have reached 
the end of the image?
Better yet, assuming 'load-image returns a pointer, how do I access 
the first memory location referenced by the pointer?
Kaj
8-Feb-2013
[5497x3]
See the function spec in GDK.reds. It returns a pointer to an image! 
struct, so if you want to access the image internally, you have to 
go by that struct definition
As you can see in the same file, I haven't finished the definition 
of that struct, because I don't have to look inside the image
What is your goal?
Kaj
9-Feb-2013
[5500]
Doc, could you bring lex-scope up to date with master? Then I can 
start testing it
DocKimbel
9-Feb-2013
[5501]
Done.
Kaj
9-Feb-2013
[5502]
Thanks! Been anxiously awaiting those fixes
DocKimbel
9-Feb-2013
[5503]
I'm working on fixing #405 too in the lex-scope branch. Once that 
done, I will merge it in master if there is no regression.
Kaj
9-Feb-2013
[5504]
I figured so
DocKimbel
9-Feb-2013
[5505]
I might add #374 too the list too as it is related to scoping.
Kaj
9-Feb-2013
[5506x4]
I hoped so :-)
No build regressions in a full build run
Oddly, there's a build regression in a GTK program just for Syllable, 
which is not even a valid combination
I can't replicate it
Bo
10-Feb-2013
[5510]
I want to be able to compare two images pixel-by-pixel.
Kaj
10-Feb-2013
[5511x4]
Ah, that's relatively easy, because you don't have to know the image 
format. At least not if you can compare byte values instead of strict 
pixels
So you only have to look in the GDK/GLib headers to finish the image! 
struct definition enough to know the data length
Have to run
Do you only want two know if two images are the same? Then why not 
just read the files and compare them?
Bo
10-Feb-2013
[5515]
Actually, I want to know which pixels are different between the two 
images. Thanks for the tips!
Kaj
10-Feb-2013
[5516x2]
You'd have to know GDK's internal image format, then
Perhaps there are more suitable functions in Oldes' ImageMagick binding
Bo
10-Feb-2013
[5518x2]
I'll take a look.
Looks like ImageMagick will do the trick, if I can just figure how 
to translate the tutorials from C to Red/System.
DocKimbel
11-Feb-2013
[5520]
Kaj: are we good with the fixes in lex-scope branch? If all is fine, 
I will merge it tonight.