r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Rebol School] Rebol School

Sunanda
18-Jan-2011
[3359]
Welcome!
I've posted one possible approach on REBOLforum:

   http://www.rebolforum.com/index.cgi?f=printtopic&topicnumber=46
alemar
18-Jan-2011
[3360x2]
thanks i will have a look at it trough the interpreter this looks 
promissing and not that hard
:D
Maxim
18-Jan-2011
[3362]
REBOL is a very human-oriented language... as little syntax as possible 
(notice how there aren't any parens for functions. for example)
alemar
18-Jan-2011
[3363]
yeah exactly
Maxim
18-Jan-2011
[3364]
if you are very used to C++ this will feel awkard for a while  though 
 :-)   its almost like the total opposite.
alemar
18-Jan-2011
[3365]
well it did look like moon-speak :D
Henrik
18-Jan-2011
[3366]
in a year, C++ will feel awkward :-)
alemar
18-Jan-2011
[3367]
well guys i have to say the community works and i am pleasntly impressed.I 
am checking the libraries now and trying to get the script to work 
since i am getting  ** Access Error: Cannot open /C/users/alemar/download/test.r
** Where: halt-view

** Near: do %/C/users/alemar/download/test.r                     
                                                                 
                   i will figure it out eventually and i can get 
to real programing in this langueage** Access Error: Cannot open 
/C/users/alemar/download/test.r
** Where: halt-view

** Near: do %/C/users/alemar/download/test.r** Access Error: Cannot 
open /C/users/alemar/download/test.r
** Where: halt-view
** Near: do %/C/users/alemar/download/test.r
jocko
18-Jan-2011
[3368]
don't forget to put a header to your file :
Rebol [ ]
Ladislav
18-Jan-2011
[3369]
We don't know whether the file exists, e.g., what does the expression

exists? %/C/users/alemar/download/test.r
Maxim
18-Jan-2011
[3370]
we went over all that in the i'm new group.  :-)
PatrickP61
9-Feb-2011
[3371]
Is there an easy way to suppress a carriage return and line feed 
when hitting the enter button?

For example:  I'd like to be able to do this:
Guess # 1:  XXX <enter> "  Nope, too high, guess lower"
Guess # 2: YYY <enter> "  Nope, too low, guess higher" ...

Can this be done with the ASK somehow?
Henrik
9-Feb-2011
[3372]
http://www.rebol.net/cookbook/recipes/0060.html
PatrickP61
9-Feb-2011
[3373]
Henrik,  That is close, but I'm looking to be able to enter several 
characters, then hit the enter button, but NOT have a LF character 
printed at the time of the enter.
Henrik
9-Feb-2011
[3374x2]
perhaps check the source for the INPUT function
(which is used by ASK)
PatrickP61
9-Feb-2011
[3376]
Will do!!!
BrianH
9-Feb-2011
[3377]
A while ago someone made a text UI dialect for R2 that used ansi 
codes to move around. You might consider looking into that. It is 
likely in the rebol.org script library.
PatrickP61
9-Feb-2011
[3378x3]
I'm stinking close!!!! But not there yet:  Try this in R2:

		set-modes system/ports/input [binary: true]
		string: []
		until [
			prin char: to-char input
			append string char
			char = 13 ; <enter>
			]
		set-modes system/ports/input [binary: false]
		head string
		print "string: " string
After each typed character, I do get the console to print each one 
out, but then I seem to loose the end value when I hit enter
Is there an equivilent for SET-MODES system/ports/input [binary: 
true] in R3?
BrianH
9-Feb-2011
[3381]
No, not yet.
PatrickP61
9-Feb-2011
[3382]
Any ideas on how to get my end value in R2?
BrianH
9-Feb-2011
[3383]
No SET-MODES at all yet.
PatrickP61
9-Feb-2011
[3384x3]
Any idea on what I'm doing wrong with R2 for this code:

		set-modes system/ports/input [binary: true]
		string: ""
		until [
			char: input
;			print char-x: to-char char
			if not char = 13 [
				prin "-" prin char-x: to-char char
				append string char-x
				]
			char = 13 ; <enter>
			]
		set-modes system/ports/input [binary: false]
		head string
		print "string: " string

Typing in the following gives me this:
-1-2-3string:      

I was hoping for
-1-2-3string: "123"
Typing in      123<enter>
dinner calls -- will check back later
Sunanda
9-Feb-2011
[3387x2]
Might be that last print statement.......I think you mean:
    	print ["string: " string]
or perhaps:
    	print ["string: " mold string]
PatrickP61
9-Feb-2011
[3389]
Dohhhhh! That is right!!  Thank you Sunanda
PatrickP61
11-Feb-2011
[3390x3]
I am plaqued by a simple problem.  In R2-core, I keep on getting 
a Security Check prompt when attempting to read a file.

I am able to avoid security check prompts with R3-core by setting 
SECURE [DEBUG ALLOW] in %rebol.r
But I am not able to do this with R2-core. 


What is the proper way to use the SECURE [FILE ALLOW] option so that 
I am not continually prompted all the time?
I've tried it in my rebol.r file but it still asks me for this.
Another annoyance -- I am not sure why, but R2-core seems to require 
two REBOL [] headers for %rebol.r and %user.r -- Is anyone else seeing 
this as well?
Windows XP  R2.7.8
GrahamC
11-Feb-2011
[3393]
secure none
Awi
11-Feb-2011
[3394x4]
Is it possible to get the value of variable number of occurences 
while parsing block?
Foe example, I have the following 

block1: [cancel "res-1" "res-2" "res-3"]	; the number of strings 
following 'cancel might be 1, 2, 3...
>> parse block1 ['cancel set res-numbers some string!]
== true
>> res-numbers
== "res-1"
Is there a way I can get all three strings? Thank you very much!
BrianH
11-Feb-2011
[3398x5]
>> parse block1 ['cancel copy res-numbers [some string!]]
== true
>> res-numbers
== ["res-1" "res-2" "res-3"]
>> parse block1 ['cancel copy res-numbers some string!] res-numbers
== ["res-1" "res-2" "res-3"]
>> parse block1 ['cancel return res-numbers some string!]
== ["res-1" "res-2" "res-3"]
These are all R3 though.
>> parse block1 ['cancel return some string!]
== ["res-1" "res-2" "res-3"]
The ones with COPY work in R2 as well.
Don't use this one (from above):
>> parse block1 ['cancel return res-numbers some string!]
== ["res-1" "res-2" "res-3"]
It is matching the previously copied res-numbers as a rule :(
Awi
12-Feb-2011
[3403]
Thanks Brian! I'm still working with R2. I thought COPY was only 
for parsing string, my bad I didn't even try it. Thanks again.
Awi
14-Feb-2011
[3404]
Is it possible to get the current context name in Rebol?

I'm trying to write a log function (write log data to file, like 
nlog or log4net in .net world), surely it will be nice if I could 
also write the current function being logged.
Example:

log: func [to-log] [write/append/lines %log.txt reform [now current-context/parent-context/name 
to-log]
plus: func [a b] [log reform ["adding" a "to" b] a + b]
>> plus 1 1
== 2
>> read %log.txt
== "14-Feb-2011/23:35:04+7:00 plus adding 1 to 1^/"


What I'm asking if whether such a thing like current-context and 
it's parent context exist, and how to get them. Thanks!
Henrik
14-Feb-2011
[3405]
I'm not sure if you can. The closest analogy is BIND?, I believe.
Sunanda
14-Feb-2011
[3406]
You can, sort of, by cheating and generating an error.....The error 
object usually contains the current context name, but not the parent's
     plus: func [a b /local name][
        name:  get in disarm try [0 / 0 ] 'where   ;; cheat
        print name

        log reform ["adding" a "to" b "in" name]  ;; and add name explicitly 
        to log function call
        a + b
         ]
Maxim
14-Feb-2011
[3407x2]
sunanda, that is a hell of a nice cheat!  never thought of that one.
pity it can't be made into a function  :-)