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

World: r4wp

[#Red] Red language group

Arnold
4-Jul-2013
[9352x2]
Where can I find your I/O binding Kaj?
@Doc in your example I now notice the declaration of the local variable 
as well: http://pastebin.com/Dddf57eH

Is that necessary, I didn't use it and all seems to work pretty well.
DocKimbel
4-Jul-2013
[9354]
It was just for the sake of showing that arguments and locals are 
not in the same context.
Arnold
4-Jul-2013
[9355]
ok I was afraid some sort of memory leak could happen if you forgot.
Kaj
4-Jul-2013
[9356x3]
INPUT and ASK are in the C library binding:
http://red.esperconsultancy.nl/Red-C-library/dir?ci=tip
Both for Red and Red/System, in ANSI.red and ANSI.reds
Arnold
4-Jul-2013
[9359]
Ah! the ANSI files. Should have guessed! Nice to use in the video 
next.
MikeL
4-Jul-2013
[9360x2]
This Zato.io stuff is where I was looking for Red + zmq to go.   
bit.ly/19U6S64  (Hintjens RT)
http://bit.ly/19U6S64
kensingleton
7-Jul-2013
[9362]
I am trying to learn Red/System but I have a strange result. When 
I enter this code all works fine, the input line is printed correctly:

#import [
	LIBC-File cdecl [
		get-line: "gets" [
			line	[c-string!]
			return:	[c-string!]
		]
	]
]

foo: ""
get-line foo            ; when run I enter: this is a test
print newline
print foo                  ; Correctly outputs: this is a test


but if I do this;

foo: ""
boo: ""
get-line foo          ; when run I enter: this is a test
boo: foo
print newline
print boo

then I get             ; "thisX @"

or if I enter: hello
it prints out: hellX @


It seems that something in the process of binding foo to boo is messing 
up, but I have no clue what it might be.
Any ideas?
DocKimbel
7-Jul-2013
[9363]
gets() requires you to allocate a buffer of adequate size. Empty 
c-string! literals ("") will statically allocate an empty string, 
unsuitable for use with gets(), resulting in buffer overflows ('boo 
is allocated just after 'foo). Try rather: 

foo:  allocate 100
boo: allocate 100


This will dynamically allocate 100 bytes for each c-string!. You 
need to ensure that gets() won't overflow those buffers (which in 
practice is impossible, so one should just avoid using gets() in 
production code).
kensingleton
7-Jul-2013
[9364x2]
Thanks Doc. What then would your recommend for getting console input 
into Red/System if not gets()?
The allocate did not work because of a type mismatch but using long 
empty string literals did.
DocKimbel
7-Jul-2013
[9366]
Have a look the Red/Sysme parts of Red's console:

https://github.com/dockimbel/Red/blob/master/red/tests/console.red


These are not the only ways to securely read inputs from user, fgets() 
is the main safe alternative:

http://stackoverflow.com/questions/4309746/safe-alternative-to-gets
kensingleton
7-Jul-2013
[9367]
Thanks Doc.
DocKimbel
7-Jul-2013
[9368]
Type mismatch: you can fix it easily with a simple type casting and 
proper string initialization.

foo: as c-string! allocate 100
boo: as c-string! allocate 100
kensingleton
7-Jul-2013
[9369]
Great, thanks Doc, worked a treat!
Kaj
7-Jul-2013
[9370x2]
Here is the first Red/System driver, a minimal Hello World kernel 
driver for Windows:
Red/System []

#import ["ntoskrnl.exe" stdcall [

 log-error: "DbgPrint" [				"Print formatted message to debug log."
		[variadic]
		; format		[c-string!]
		;	value		[variant!]
		;	...
	]
]]

on-load: function ["DriverEntry"
	DriverObject	[driver-object!]
	RegistryPath 	[byte-ptr!]
	return:			[integer!]
][
	log-error "Hello Red/System from Windows kernel driver!"
	0
]
Bo
7-Jul-2013
[9372]
Great news!
Paul
9-Jul-2013
[9373]
Can the RED compiler generate PDB files?
Pekr
9-Jul-2013
[9374x2]
So, I gave my new BeagleBone Black (BBB) a quick test. With latest 
Arngstrom Linux, I was able to upload Red ARM tests (generated using 
%build-arm-tests.r). All tests pass, except %function-test, which 
crashes with Runtime Error 1: Access violation ....
The above mentioned script also fails at it tries to make a directory. 
Maybe it needs make-dir/deep %runnable/arm-tests, or simply to remove 
%runnable ....
Kaj
9-Jul-2013
[9376]
Doc said PDB is undocumented and too complex
Paul
9-Jul-2013
[9377]
I didn't know it wasn't documented.
Kaj
9-Jul-2013
[9378]
Early results were that PE format is less complex than ELF, but if 
you count in debug extensions, it's the other way around
Paul
9-Jul-2013
[9379]
I have a technet subscription so I'm combing the database right now.
Pekr
9-Jul-2013
[9380]
Ah, just found out, that above access violation is present even with 
Windows version of the function-test.exe
Kaj
9-Jul-2013
[9381]
I think Doc would be interested
DocKimbel
9-Jul-2013
[9382x2]
Function-test: it's a test that rely on unimplemeted feature that 
cause the crash, it should be disabled until  we get that supported.
PDB Paul if you can get me all the required documentation, I'll be 
glad to add PDB generation to Red toolchain.
Pekr
9-Jul-2013
[9384]
OK, got news posted to FB profile anyway ;-)
DocKimbel
9-Jul-2013
[9385]
Pekr: does the Red console works fine on the BeagleBone?
Paul
9-Jul-2013
[9386]
Does look to be a bit closely guarded but here are some links that 
may get you going for PDB output  -> http://ccimetadata.codeplex.com/wiki/search?tab=Home&SearchText=pdb
DocKimbel
9-Jul-2013
[9387]
You could cross-post it also on the Red ML and Tweeter (I'll retweet 
it).
Paul
9-Jul-2013
[9388x2]
Is there a RD
Sorry a RED Facebook?
Pekr
9-Jul-2013
[9390x3]
DocKimbel - so I tried it, and yes, it works ...
As for news channels - if there is anything new, and my time and 
skills permit, I do post. It is a pity, it is not reposted to your 
blog, it looks really dated with latest 0.3.2 Repl release :-( I 
find it a bad strategy, the project seems a bit stalled, at least 
Git get propagated there ....
as for Red ML, AFAIK, I am not there ... Any activity there?
DocKimbel
9-Jul-2013
[9393]
Paul: no much usable info there it seems. What I really need is a 
PDB file specification.
Pekr
9-Jul-2013
[9394]
Doc - I noticed Carl mentioned he is getting BBB for his HW purposes. 
When you will try to hook him into Red, just mention, that we are 
already there too :-)
DocKimbel
9-Jul-2013
[9395x2]
There are Twitter and Github for day to day news.
Pekr: will do. ;-)
Pekr
9-Jul-2013
[9397]
FB has component to display news, twitter too. As for FB, I would 
not put it into your website, but maybe twitter could be corrected
DocKimbel
9-Jul-2013
[9398]
If you think about the Twitter plugins on Blogger, they seem all 
dead. Anyway, I would be glad to get rid of Blogger and switch to 
something else, Blogger is horribly bad and outdated.
Pekr
9-Jul-2013
[9399x2]
Well, it works, no? Not sure what other blogging sites/domains are 
available. Twitter kind of removed possibility to freely display 
content via JS code. You can do it, but inside your twitter profile, 
in Settings/Widgets, you can create new display widget. But customisation/design 
options are limited - basically dark/bright theme, number of tweets, 
some other formatting, and that's it. It spits out a little code 
you add to your site, and done ... maybe worth the effort, dunno 
- not sure about minimal width though - more info here https://dev.twitter.com/docs/embedded-timelines
the question is, if you want to loose your time with such stuff .....
DocKimbel
9-Jul-2013
[9401]
I tried it once IIRC, and couldn't use it for Red site as it was 
requiring too much horizontal space.