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

World: r3wp

[All] except covered in other channels

Ladislav
6-Sep-2006
[2324]
it would be interesting to know how many users would want this feature 
- I am afraid it can help to hide a programming error
Anton
6-Sep-2006
[2325x3]
That's true. I will definitely be keeping it in my library though.
Can you remind us of the effect of [throw] on return etc.. ?
I got an error "return or exit not in function" when I had [throw] 
in the function header.
Ladislav
6-Sep-2006
[2328x2]
[throw]: "Normal" REBOL functions are expected to return a value 
when "encountering" RETURN. This behaviour differs from REBOL natives, 
though. See e.g. loop 1 [return 1], which does not mean the programmer 
wants the LOOP function to return one. The intended meaning is that 
the RETURN is meant for some other function, not for LOOP. To immitate 
this behaviour (necessary for control functions like SWITCH), Carl 
invented the [throw] attribute, which is "telling", that the function 
should "throw" RETURN to some other function instead of "using it" 
for itself.
For REBOL3 I proposed a change compatible with the above mentioned 
explanation allowing to discern return types.
Anton
6-Sep-2006
[2330x2]
Ah.. thankyou.
This means if I want to allow the user to use 'return in my switch2 
to jump out of her enclosing function, then I must add [throw] to 
the function header.
Ladislav
6-Sep-2006
[2332x2]
yes
unfortunately (in R2) this means, that you are unable to use RETURN 
for the SWITCH implementation purposes
Anton
6-Sep-2006
[2334]
Yes, I see now why you did not use it.
Ladislav
6-Sep-2006
[2335]
(unless you use "black magic", like my TFUNC instead of FUNC)
Anton
6-Sep-2006
[2336]
Ok, here it is:
; FIND-based, multi-action
switch3: func [

    "Selects a choice and evaluates the first block that follows it. 
    This occurs for every matching value and following block found."

    [throw] ; <-- allows RETURN to be used by the user to jump out of 
    an enclosing function (not just this one)
    value "Value to search for."
    cases [block!] "Block of cases to search."
    /default case [block!] "Default case if no others are found."

    /local result done? ; <-- flag so we know whether an action block 
    was done. (Can't just check 'result, could be unset!)
][
	while [cases: find cases value][

  either cases: find next cases block! [set/any 'result do first cases 
  done?: yes][break]
	]
	either done? [
		get/any 'result
	][
		if default [do case]
	]
]


my-switch: :switch3   ; <--- set to the function we want to test


;test
repeat n 10 [
	print [
		n

  my-switch/default n [2 4 6 ['even] 1 3 5 ['odd]] [mold "--default--"]
	]
]
my-switch 1 []
my-switch/default 1 [] [probe "--default, ok--"]
my-switch 1 [1 [probe "ok"]]
my-switch 2 [1 [probe "bad"]]
my-switch 1 [1 2 [probe "ok"]]
my-switch 2 [1 2 [probe "ok"]]
my-switch 3 [1 2 [probe "bad"]]

; multiple action blocks
my-switch 1 [1 2 [probe "ok"] 1 3 4 [probe "ok#2"]] ; <-- 
my-switch 2 [1 2 [probe "ok"] 1 3 4 [probe "bad"]]
my-switch 3 [1 2 [probe "bad"] 1 3 4 [probe "ok"]]
my-switch 4 [1 2 [probe "bad"] 1 3 4 [probe "ok"]]
my-switch 5 [1 2 [probe "bad"] 1 3 4 [probe "bad"]]


my-switch/default 5 [1 2 [probe "bad"] 1 3 4 [probe "bad"]] [probe 
"--default, ok--"]
Geomol
18-Sep-2006
[2337]
Does anyone know of a good alternative to MS Exchange running on 
Linux/UNIX? I've found OpenGroupware.org and Open-XChange. Anything 
else worth looking at?
yeksoon
18-Sep-2006
[2338]
there is Bynari , http://www.bynari.net/

and...Zimbra,   http://www.zimbra.com/products/


if you don't really need so much things...there is always sendmail
Graham
18-Sep-2006
[2339]
we've been using Scalix
Geomol
18-Sep-2006
[2340]
Thanks guys! I also found egroupware.org, which seems promising. 
I have enough now.
Louis
19-Sep-2006
[2341]
Hit any key to start: 19-Sep-2006/11:33:24.687+6:30
Hit any key to stop : 19-Sep-2006/11:33:29.515+6:30


0:00:04.828


How can I force my stopwatch.r script (see announce group) to not 
display the nanoseconds, so instead of 0:00:04.828 it displays only 
0:00:04
Henrik
19-Sep-2006
[2342]
round now/time/precise
Louis
19-Sep-2006
[2343x2]
I'm timing a vid script, and the nano seconds never display, I assume 
because vid refreshes every second.
Henrik, that worked! Thanks! I love AltME and all you helpful guys.
Louis
31-Oct-2006
[2345]
I'm rather badly needing a pagemaker pm5 file converted to ASCII 
format. My copy of Pagemaker has been corrupted, and I just want 
to print a document using LaTeX. The file is about 309 MB. Is there 
anyone here that can do this for me?
[unknown: 9]
1-Nov-2006
[2346]
May I ask...why do you still "print" stuff?
Louis
1-Nov-2006
[2347x3]
Because, I'm in a small village in Indonesia. None of the people 
in this village have computers. Most of them are very poor.
On AltME I live in the future, but in this village I live 75 years 
ago or more.
Some of the major cities here are much more advanced, of course.
[unknown: 9]
1-Nov-2006
[2350]
Ah, I get it.  I really want to make a bunch of jokes about printing 
bibles, but will skip it.
Graham
1-Nov-2006
[2351x2]
309Mbs !
how many 1000s of pages is that?
Louis
1-Nov-2006
[2353x2]
:>) Typo. That should have been KBs.  What a difference one letter 
makes.
Programmers notice such things, since one letter often makes the 
difference between a program running of not.
[unknown: 9]
1-Nov-2006
[2355]
:)
Maarten
12-Jan-2007
[2356]
What would be your #2 language after REBOL for developing an entrprise 
apllication/web application?
Sunanda
12-Jan-2007
[2357]
I'd use Rexx if they let me:
http://en.wikipedia.org/wiki/REXX
BrianW
13-Jan-2007
[2358]
Possibly Python
Maxim
15-Jan-2007
[2359]
python for sure... just cause it will easily symbiose with C/C++ 
 and makes it very easy to work with both hand in hand.
Pekr
15-Jan-2007
[2360]
Hmm, would it be possible to get Rebol working with C more easily 
too?
Maxim
15-Jan-2007
[2361x3]
yes, if we could compile rebol directly using rebol.o  and link it 
with any other C  .o module


and if we could interpret. .c / .cpp / .h files directly and convert 
the stubs directly within rebol.
(like python does)
it seems as if  R3 will allow us to link to rebol itself... so this 
might be possible... as you have noticed... too in some of Carl's 
R3 posts.
Pekr
15-Jan-2007
[2364]
I am not sure it is possible. Is Python just some kind of direct 
C extension or what?
Maxim
15-Jan-2007
[2365x6]
internally it using the same type structure (immutable strings, etc)
and in loads C stubs easily. so you don't have to try and make it 
work... its python's main feature... its so easy, everyone is able 
to port their legacy C stuff and then use it within a scripted env.
and most C libs are within python as-is, so things like sockets, 
regexp, threads and such use the same mechanics and nomenclature... 
so there is very little adapting a part from the peculiar indent 
grouping.
obviously, python has other merits, but making C integration that 
easy made many developpers "take the risk" of trying it out, since 
it did not means wasting years of investment.
there is nothing like proving an easy, lazy path to migration.
proving= providing
Pekr
15-Jan-2007
[2371]
that sounds good. I tried to look into Ruby and Python, and if I 
would learn another new language, I would learn python - the syntax 
is pretty readable ...
Maarten
15-Jan-2007
[2372]
Yes, and the language is as capable as rebol, except for symbolic 
manipulation. But with a good parser generator you can do a lot
Pekr
16-Jan-2007
[2373]
guys, don't you  know any application, which would be able to generate 
traffic? I want to install two Mikrotik routers in Dual Nstreme mode, 
and I would like to test real-life thoughput. Copying one big file 
amongst two ends is interesting test for line stability, but there 
is a difference if you run one connection, or few hundreds ones ...