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

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

Henrik
18-Jan-2011
[4137]
Carl is notified.
alemar
18-Jan-2011
[4138]
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
Maxim
18-Jan-2011
[4139]
type:

exists? % /C/users/alemar/download/
alemar
18-Jan-2011
[4140]
hmm ok
Henrik
18-Jan-2011
[4141]
you are doing the right thing. the question is if the script is really 
put there and if Windows allows reading there. I suppose you are 
using Win7?
alemar
18-Jan-2011
[4142]
yes i am
Maxim
18-Jan-2011
[4143]
ooops... 

exists? %/C/users/alemar/download/
alemar
18-Jan-2011
[4144]
as a vmachine at the moment
Henrik
18-Jan-2011
[4145]
Carl has fixed the site problem.
alemar
18-Jan-2011
[4146x2]
ahaaa i get --false
so i just gotta change the file location
Maxim
18-Jan-2011
[4148]
the R2 console can actually act like a shell.


in the latest release (2.7.8) they added posix style shortcuts to 
the various file operations directly... so you can do:

>> cd %/C/users/alemar/download/
>> ls
alemar
18-Jan-2011
[4149]
yeah i got it now it is verry simple i just assosciated the.r extension 
with rebol :D
Maxim
18-Jan-2011
[4150]
the advantage of opening the console first and executing do  is that 
any console i/o will remain in the current console...


if you just double click on a simple script, REBOL will open execute 
and close so fast, you might not even see it flash on screen!
alemar
18-Jan-2011
[4151]
aha
Maxim
18-Jan-2011
[4152]
one of the advantages of being only 700kb  ;-)
alemar
18-Jan-2011
[4153x2]
ok but now when i start the file directly i get ** Syntax Error: 
Script is missing a REBOL header
** Near: do/args script system/script/args
my-func: func [] [
	n: to-integer ask "enter a number"
	if  n < 0  [quit/return 1]
	sum: 0
	i: 0
	while [ i <= n ] [ sum: sum + probe (i * i)  i: i + 1]
	print sum
]
Maxim
18-Jan-2011
[4155]
ah yes.   scripts *must* start with rebol's header.

rebol [  ]
alemar
18-Jan-2011
[4156]
this is the body of the file
Henrik
18-Jan-2011
[4157]
did you add the first line:

REBOL []

?
alemar
18-Jan-2011
[4158x2]
REBOL[]
my-func: func [] [
	n: to-integer ask "enter a number"
	if  n < 0  [quit/return 1]
	sum: 0
	i: 0
	while [ i <= n ] [ sum: sum + probe (i * i)  i: i + 1]
	print sum
]
like so?
Maxim
18-Jan-2011
[4160]
you can see that Rebol is case insensitive  ;-)
Henrik
18-Jan-2011
[4161]
yep
Maxim
18-Jan-2011
[4162]
yep.  and don't forget to run the function at the end...

I'd also put a trailing ask ""

REBOL[]
my-func: func [] [
	n: to-integer ask "enter a number: "
	if  n < 0  [quit/return 1]
	sum: 0
	i: 0
	while [ i <= n ] [ sum: sum + probe (i * i)  i: i + 1]
	print sum
]

my-func

ask "press enter to quit"
alemar
18-Jan-2011
[4163x2]
ok trying that as well,on a side note now the file does not start 
:D
sry my mistake
Maxim
18-Jan-2011
[4165]
if you didn't put an ask at the end... just just didn't see it cause 
it closed to quicly.
alemar
18-Jan-2011
[4166x2]
works fine
yeah THAT i figured out from reading the libraries thanks alot guys 
you are great
Maxim
18-Jan-2011
[4168]
if you press escape at any point,  the execution stops and you are 
sent to the console... try it.
alemar
18-Jan-2011
[4169]
cool
Maxim
18-Jan-2011
[4170x2]
now try it with a negative number and the console will quit on its 
own (since I put a return/quit 1)
if you just want the function to return   remove the /quit 1
alemar
18-Jan-2011
[4172]
really nifty
Maxim
18-Jan-2011
[4173]
/quit  is a  Refinement   a special function datatype which can be 
used in functions to supply additional parameters or instructions 
to a function.
alemar
18-Jan-2011
[4174x2]
ok i am beggining to love this language
so everything aside i really got into the basics thank you fo that
Maxim
18-Jan-2011
[4176x2]
refinements is how REBOL gets away without any parens because the 
number of arguments is always known.
no problem... its always fun to have new users.  :-)
alemar
18-Jan-2011
[4178]
what do you mean always known
Sunanda
18-Jan-2011
[4179]
Be careful......Max is feeding you the red pill.
Maxim
18-Jan-2011
[4180x3]
ex:

my-func [value /optional opt-value] [
	probe value
	if optional [
		probe opt-value
	]
]

my-func 33
my-func/option 22 "tadam"
because you added the refinement, it knows to expect an additional 
argument.
oops... 

my-func: func  [value /optional opt-value] [
alemar
18-Jan-2011
[4183]
thnks guys really gr8 community unfortunately my timezone says:go 
to bed or don`t bother at all" :D so i will leave the pc now but 
i will leave the chat on if i think os something in my sleep
Pekr
18-Jan-2011
[4184]
alemar - where are you from?
alemar
18-Jan-2011
[4185x2]
bulgaria
it`s barely 22:30 but i got a lot to do tommorow