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.

Ladislav
4-Jun-2009
[2934]
do read clipboard://
mhinson
4-Jun-2009
[2935]
Thanks
BrianH
4-Jun-2009
[2936]
I often put
;rebol []

in front of my code when testing it, then include the rebol [] when 
selecting.
mhinson
5-Jun-2009
[2937]
Hi, I have associated .r files with Rebol/view, but when I open my 
.r files I get an error
** Access Error: Cabbot open /c/documents
** Near: do/args script system/script/args


I tried associating .rs with Rebol/View & that works ok...  I suspect 
this is a windowsy problem, any suggestions please?
BrianH
5-Jun-2009
[2938]
You need quotes around the association, like this: "%1". Edit the 
file type in the Folder Options control panel.
Maxim
5-Jun-2009
[2939]
hope you have XP... cause vista only allows to fix associations thru 
the registry editor  :-(
BrianH
5-Jun-2009
[2940]
But that's not hard either.
Maxim
5-Jun-2009
[2941x2]
and you can't set manual paths in shortcuts, only select "installed" 
applications.  >-:(
maybe not if you are used to playing in it, but finding and properly 
setting the registry items for rebol isn't really obvious (especially 
if you add the -qs) options.
BrianH
5-Jun-2009
[2943]
But that doesn't affect the associations in the registry :)
Maxim
5-Jun-2009
[2944x3]
they removed many USER features in vista, thinking it makes is safer 
if you can't do anything with your computer... but the features are 
still there anyways... which is totally stupid... its in fact less 
safe, now that you can't fix things directly in the panels.
In XP I had applications that had different argument setups directly 
in shortcuts... can't do that in vista... well, I installed XP now 
so I can't complain anymore... I can actually do stuff with my pc 
now.
XP was designed for dumb users... vista went a step further and added 
that pre-requisite to its analysts.
BrianH
5-Jun-2009
[2947]
Well, for most users "fix" = "make things worse", except for the 
users who are probably familiar with the registry. I agree about 
the shortcut thing though - not familiar enough with Vista to know 
the workaround for that.
Maxim
5-Jun-2009
[2948]
I try to design software thinking people are smart, but with the 
idea that you have to learn & understand it first.  Learning curve 
has to be exponential, but start flat. 

Misunderstanding and being dumb are different.  MS doesn't get that.
BrianH
5-Jun-2009
[2949]
Everyone is dumb sometimes, and the more generally smart even more 
often. As long as the software doesn't get in the way of doing the 
smart thing, and perhaps even enables it, that's good. If it discourages 
dumb behavior, better.
Maxim
5-Jun-2009
[2950]
I agree.    Its the software that has to be smart... not the user 
 ;-)
BrianH
5-Jun-2009
[2951]
Software at its best is a distillation of your smarter moments, for 
later use during your dumber ones :)
Maxim
5-Jun-2009
[2952]
(or someone else's  ;-)
mhinson
5-Jun-2009
[2953]
I dont see anything to put quotes round.
BrianH
5-Jun-2009
[2954]
Are you on XP/2000 or Vista?
mhinson
5-Jun-2009
[2955]
XP...  I may have found it now, I remeber experimenting adding %1 
%2 %3 ......  then I remeber thinking I should have just added "%1"
BrianH
5-Jun-2009
[2956]
Unfortunately, the installer hasn't worked at all in the 2.7 series. 
In the 2.6 series it was broken, and in prior releases even more 
so.
mhinson
8-Jun-2009
[2957]
Hi, I seem to be answering more of my own questions for the last 
few days which is encouraging, but I am wondering if I am getting 
into bad habits as I have no solid programming background & apart 
from the tips I have got here I am just self-taught.  

Is there anywhere I can put a few hundred lines of code to be torn 
to shredds please?  I don't paticularly relish the idea, but I suspect 
it will be a good learning experience.
Sunanda
8-Jun-2009
[2958x2]
Few hundred lines of code!? Congratulations on writing them.....But 
can you extract a subset (say a function of two that you are especially 
proud of) for analysis. 100s of lines of code is going to be hard 
for anyone to wrap their mind around for comment.

Having said that, possible locations: Here or the mailing list.
You tend to get more thought out replies on the ML.
You get  more instant interaction here.
You could also try reboltalk -- though that seems overrun with spam 
a lot these days:
http://www.reboltalk.com/
mhinson
8-Jun-2009
[2960x2]
It is mostly a parse with about 8 small functions that are called 
within the parse to identify special cases, expand ranges & mess 
about with IP address info.
I think the fact that I can readily extract a decent function to 
post means that I have been using too many globals & getting my code 
a bit muddled.  Thanks for the feedback, I will post something once 
I get it a bit more untangled....  It just went like that, honest 
I didnt write it like that to start with.. :-(
Graham
8-Jun-2009
[2962]
the library at rebol.org ....
Gregg
8-Jun-2009
[2963]
In addition to what Sunanda said, if the code does something useful, 
people are more inclined to look at it, and make suggestions for 
improvements.
mhinson
8-Jun-2009
[2964]
I am intrested in Cisco networking & writing tools related to that 
area of technology, not sure that is a very prominent interest in 
the AltME world??
Reichart
8-Jun-2009
[2965]
I suspect everything done "with REBOL" is interesting to people here. 
 That simple.
mhinson
8-Jun-2009
[2966]
This is a unique place.  It is a priveledge to be invited here.
Gregg
8-Jun-2009
[2967]
We all love tools. :-)
mhinson
8-Jun-2009
[2968]
I cant get the library to accept it :-(
make object! [
    code: 200
    type: 'syntax
    id: 'invalid
    arg1: "path"
    arg2: "intIpaddrS/"
    arg3: none

    near: {(line 68) write/append outFile reduce [either debug [currentFile 
    tab i tab] [""] hostname tab ipVrfForward tab interface tab vlan 
    tab mode tab trunkEncap tab nativeVlan tab allowedVlans tab upState 
    tab intDesc tab speed tab duplex tab intIpaddrS/(count1) tab QualifiedNetworkS/(count1) 
    tab tagMtu newline]}
    where: none
]
Graham
8-Jun-2009
[2969]
this is the error seen in the browser ??  ie. is the rebol org script 
that processes the uploads saying this?
Sunanda
9-Jun-2009
[2970]
The Library does sometimes have trouble with scripts.

It needs to load the script to get header information. But the Library 
is running on an older version of R2. Some newer scripts cannot be 
loaded as they contain syntax elements that crash the version the 
Library is running.
We have some creative work-arounds.

Mike can you email me your script (right click my name for email 
address). I'll see what the options are.
Thanks.....You are a natural at finding bugs!
mhinson
9-Jun-2009
[2971]
Hi, I have sent the whole thing to Sunanda as the script is ok in 
the browser, but has a few (other) problems being loaded into the 
Library. Probably down to me doing strange noobie things. In the 
case above the library prefers ... intIpaddrS/:count1 ...   Which 
seems better in any case so I have changed it.
Graham
9-Jun-2009
[2972]
yeah ..old rebol version
Sunanda
9-Jun-2009
[2973]
Thanks Mike.

It's [old REBOL version + REBOL not being backward compatible].


There is a theory that REBOL does not need to be backward compatible, 
as old applications can continue to run on older versions of the 
interpreter. That theory is fine in many cases.....


.....But it fails in the case of REBOL.org -- we're an old (verging 
on legacy) application that consumes REBOL code as data ..... We 
fail in some cases because the code we try to consume as data crashes 
the version of the interpreter we use.


I have an idea for (yet another) creative work around for the issue 
Mike has.....But I also have to spend a few days away from REBOL 
coding, so no immediate solution forthcoming. Sorry!
mhinson
10-Jun-2009
[2974x2]
Hi, is there any clever Rebol way to access the Tuples in this block 
by the associated numbers 80 & 4 please?
b: [80["8.8.8.8" "random"] 4["4.4.4.4"]]


if they were words it would be easy, but with numbers I am wondering 
if I just have to search for them & find the index & add one? Or 
perhaps convert the numbers into words by prepending them with a 
letter perhaps? Thanks.
This solution seems a bit messy, so I wondered if there was a neater 
way.
>> b: [_80["8.8.8.8" "random"] _4["4.4.4.4"]]
== [_80 ["8.8.8.8" "random"] _4 ["4.4.4.4"]]
>> b/_80
== ["8.8.8.8" "random"]
Sunanda
10-Jun-2009
[2976]
Select may help:
    first select b 80
    == "8.8.8.8"
mhinson
10-Jun-2009
[2977]
That is perfect....  Again I learn a new word for my Rebol conversations. 
 Thanks Sunanda
mhinson
13-Jun-2009
[2978]
Hi, I have written this function and would be glad of any comments 
please.  I know it is only simple stuff but I want to try any learn 
to write code well, not just hack stuff together that just about 
works.  Thanks. 
;; Generate all IPv4 dotted decimal masks
AllMasks: has [a b c d allMasks][
	allMasks: []
	if (allMasks = []) [
		for count 0 7 1 [ 
			i: to-integer power 2 (count)	
			a: 255.255.255.255 - to-tuple rejoin ["0.0.0." (i - 1) ""]
			b: 255.255.255.255 - to-tuple rejoin ["0.0." (i - 1) ".255"]
			c: 255.255.255.255 - to-tuple rejoin ["0." (i - 1) ".255.255"]

   d: 255.255.255.255 - to-tuple rejoin ["" (i - 1) ".255.255.255"]
			insert allMasks  reduce [a b c d]
		] 
		sort/all/reverse allMasks
		insert tail allMasks 0.0.0.0
		print "Created all IPv4 masks"  ;; debug
	] return allMasks
]
Sunanda
13-Jun-2009
[2979]
Any code that works is fine by me.....!

You could make your to-tuples a little tidier by utilising the fact 
the to-tuple will take a block of integers, eg:
    to-tuple [255 255 255 248]
    == 255.255.255.248
Paul
13-Jun-2009
[2980x2]
Hi mhinson, a couple things at first glance.  Beware setting a word 
to series data.  One of the big pitfalls newcomers have is that if 
they intend to reuse a function that contains a series being set 
that it can result in the series getting recursively populated.  
To avoid that we often use the 'copy word when setting series.  Although, 
by design sometimes we want the previous behavior.  The other thing 
is to get rid of the return at the end.  Just end your statement 
with allmasks.  You should really only need the 'return if you intend 
to pre-empt the full execution of the body block of the function.
Another tip while I'm here.  If you ever use the series pickers such 
as first, second etc.., then try to use them as the last item in 
logic functions.  For example:
series: [1 2 3]
if first series = 1 [true]
if 1 = first series [true]


The first logical expression will give you an error and the second 
will work correctly.
Sunanda
13-Jun-2009
[2982]
Use of 'return is partially a personal style issue. It is, literally, 
not needed if the last value your function handles is the one you 
want returned; in that case omiting the 'return can speed up a function 
considerably.


On the other hand, consider "literate programming" conventions: it 
can be polite to spell out the details so future code readers do 
not need to recapitulate your clevernesses just to work out what 
is returned......The code snippet below can return three separate 
things: spelling it out would help future generations!

    f: func [a b][
      either a > b [
          print a
         ][
         if a = b [b + 5]
        ]
     ]
mhinson
13-Jun-2009
[2983]
Hi guys, thanks for the tips, it is looking neater allready.

About setting the words to series data, is this us in my gode a bad 
example would you say?  I intended that the function would only ever 
need to calculate the values once, but perhaps my method is not secure?

Thanks for the tip about series pickers, that way looks a bit reversed 
so I would have probably got it wrong.