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

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp5907
r3wp58701
total:64608

results window for this page: [start: 32601 end: 32700]

world-name: r3wp

Group: I'm new ... Ask any question, and a helpful person will try to answer. [web-public]
mhinson:
14-May-2009
so I will add a comma to the end, then parse data [any [ some digit 
#"/" copy result #"," (insert results result) | skip]]
Janko:
14-May-2009
If it is I wouldn't call that a parse problem, ... remember you have 
to divide and conquer the problems , and that looks like a compound 
problem which parsing is not the big part of.. you just need regular 
"split" method
mhinson:
14-May-2009
the 2 is a module number on a Cisco catos switch
Janko:
14-May-2009
I qould 1) split on comma to get list of entities  2) for each entity 
if it's a single num append it to block, else split again and append 
 whole range to the block
mhinson:
14-May-2009
the port information is stored in a form like
set port disable 2/2,2/4,2/6-8
set port disable 3/1-5,3/7
Then the same sort of thing for the names given to the ports.

I want to extract it all into a standard format for analysis & comparison 
of IOS based information (done the IOS stuff ok)
BrianH:
14-May-2009
a: [...]
some-a-with-comma: [a any ["," a]]
mhinson:
14-May-2009
ah, do I need a copy result to perhaps?
PeterWood:
14-May-2009
I usually try to take a few small steps rather than try to get the 
answer straight away.

The test data:

>> inp:  {random 2/2,2/4-6,2/33-37}

== "random 2/2,2/4-6,2/33-37"
mhinson:
14-May-2009
random is sometimes a word & sometimes a number between 1 & 1000
mhinson:
14-May-2009
so copy range has captured everything up to the point it no longer 
matches the expression in the []  a bit like a regular expression 
match.
PeterWood:
14-May-2009
So now I'm capturing the first number after the 2/ but not the range. 
So let's add a little more to the parse rule to capture that:


>> parse/all inp [ any [copy range ["2/" some [digit | "-"]]  (print 
range) | skip ]]                                                 
                         
2/2
2/4-6
2/33-37

== true
mhinson:
14-May-2009
a bit like copy thru?
PeterWood:
14-May-2009
Then we can come up with a pattern for them:

digit opt digit "/"
mhinson:
14-May-2009
they are, but there will never be a 0/  or 22/ that we want to avoid 
in this case
PeterWood:
14-May-2009
That's a good idea but I was being lazy partly because it's such 
a pain to copy and paste in AltME (it strips out all line endings).
PeterWood:
14-May-2009
Once we've captured all-ranges, we can process them in a second step 
:
mhinson:
14-May-2009
Ladislav, I am not sure I understand your terminology. record: [random-part 
whitespace repeated-part any ["," repeated-part]]
random-part may be absent
repeated-part is a number between 1 & 13 followed by "/" 
any is the bit we want and will be a number or a range
,
 is not present at the end of the line

repeated-part  is the same as above, but will not be the last thing 
on the line.
Ladislav:
14-May-2009
so you are saying, that random-part may be a-word a-number or absent. 
This is it:

random-part: [a-word | a-number | none]
mhinson:
14-May-2009
Yes, that sounds a good description of the random part.
Ladislav:
14-May-2009
fine, we need to describe further, what is a-word:

a-word: [some alpha]

, is this adequate?
Ladislav:
14-May-2009
alpha: charset [#"a" - #"z" #"A" - #"Z"]
Ladislav:
14-May-2009
fine, now for the a-number part. how big a number can it be?
Ladislav:
14-May-2009
a-number: [one-to-two 3 digit | non-zero-digit 0 2 digit]
Steeve:
14-May-2009
hum..
a-number: [1 4 digit]
is that not enough ?
Maxim:
14-May-2009
mhinson... If I can encourage you... once you will "get" it... it 
will all become <really> simple.  you mind is just adapting to maping 
rules and seeing the inherent stack of what they imply.  

Don't give up, it will all become clear.  I think we all feel the 
same anxiety at first.  Most don't follow through, its a good thing 
that you persevere.  :-)
Ladislav:
14-May-2009
the rule

line: [random-part repeated-part any ["," repeated-part]]


just means, that at the start there is a special random-part, and 
then we have more repeated-part's separated by comma
Ladislav:
14-May-2009
we didn't specify what exactly is in the repeated-part, so we can 
continue:

repeated-part: [one-to-thirteen "/" a-range]
Maxim:
14-May-2009
steeve, that means it will not require a comma, which means the repeated 
part can match some wrong pattern
Steeve:
14-May-2009
digit: charset "0123456789"
alpha: charset [#"a" - #"z" #"A" - #"Z"]

prefix: [1 2 digit]
sufix: [some digit opt ["-" some digit]]
range: [copy range! [prefix #"/" sufix] (prin ["range:" range!])]

rand: [copy rand! [1 4 digit | some alpha] (prin [newline "random:" 
rand!])] 

target: [rand range any [#"," range]]

parse/all inp [some [target | skip]]

is that ok ?
mhinson:
14-May-2009
I think this is what Ladislav has given us so far:
alpha: charset [#"a" - #"z" #"A" - #"Z"]
a-word:  [some alpha]
one-to-two: [#"1" - #"2"]
digit: [#"0" - #"9"]
non-zero-digit: [#"1" - #"9"]
a-number: [one-to-two 3 digit | non-zero-digit 0 2 digit]
random-part: [a-word | a-number | none]


record: [random-part whitespace repeated-part any ["," repeated-part]]


I understand how it relates to the data, but not how to use it to 
extract the bit I want....
mhinson:
14-May-2009
the data is structured with a key words or a vlan number followed 
by ports & ranges of ports. (like 2/2,2/4-6)
I want to restructure this data so I end up with
port 2/2 vlan55 disabled name3
port 2/4 vlan55 disabled name4
port 2/5 vlan88  named somthing else
Maxim:
14-May-2009
the generall concept: 

   Once you match data, you add a parens, in which you add rebol code 
   to execute.
Maxim:
14-May-2009
so you'd just create a block before the parse, and dump the data 
which you want in there, using your new structure.
Group: Rebol School ... Rebol School [web-public]
Geomol:
6-Oct-2011
What does the english word "book" mean?


Is it "a book" you can read in, or is it "book a ticket". You see, 
the same word can mean more than one thing. Same in REBOL.
todun:
6-Oct-2011
also you say I put "other stuff" and such. I'm guessing this means 
I'm mixing code in a non-kosher way. From a paradigm-like sort of 
way, how to I separate out my code in REBOL way or the correct way?
Geomol:
6-Oct-2011
In your example, you use the LAYOUT dialect, and you have to follow 
the rules of that dialect.


A dialect is a sequence of datatypes, that hold a certain meaning, 
because they're used in a certain context.
todun:
6-Oct-2011
@Geomol, that dialect description is helpful. What context can I 
use a dialect, the VID in this case, and how do I know what data-types 
to use and what external things to the dialect to use(or not to use)?
Geomol:
6-Oct-2011
Because those blocks are action facets described here:
http://www.rebol.com/docs/view-guide.html#section-17


When you interact with a style, in this case a button, those blocks 
are evaluated as if they were normal REBOL code, so the rules of 
the layout dialect doesn't rule there.
todun:
6-Oct-2011
Doing a file access and then storing the state of your access, writing 
that to file, seems quite difficult to formulate in REBOL, for me 
anyways.
todun:
6-Oct-2011
What I mean is that, if I read the file and end my read at a particular 
location before closing the GUI, does REBOL allow you to presist 
your state across executions of the program?
Geomol:
6-Oct-2011
Things like INDEX? will tell you, where you are in a series. And 
you can easily save rebol code/values to disc using the SAVE function, 
and load them again with the LOAD function.
todun:
6-Oct-2011
@Geomol, INDEX? will tell me its position, but the circular series 
link I sent you talks about how to always go around and around the 
series. I want to do the same with the lines of a file, but I'm not 
sure how to do it without using REPEAT
Geomol:
6-Oct-2011
Pass! I'm not enough into your problem to point you into a direction. 
But go on and read some more of the docs, and you should be able 
to help yourself some more:

http://www.rebol.com/docs/core23/rebolcore.html
http://www.rebol.com/docs/dictionary.html
todun:
8-Oct-2011
Is there anyway to clear an info view after a button is pressed?
Sunanda:
8-Oct-2011
question-database: [
    ["Doctor who?"  "Oops -- silence has fallen"]

    ["Is there a doctor in the house?" "Yes -- his name is Gregory"]
]



next-question: func [ ;; function to find and display the next question
   ][
   question-database: next question-database

   if tail? question-database [question-database: head question-database]
   question-field/text: first first question-database
     answer-field/text: ""
     show question-field
     show answer-field
    ]


   ;; code to define and run the panel
unview/all
view/new layout [
  across
  question-field: field ""
  answer-field: field ""
  return
  answer-button: button "show answer" [
               answer-field/text: second first question-database
               show answer-field
               ]
  next-button: button "Next question" [
                 next-question
                  ]
     ]

  ;; open code to start it running
next-question     
do-events
Singy:
23-Nov-2011
ip: ["DC1" 10.75.48.14 "DC2" 10.75.48.11 ]

foreach [name address] ip [
	tmp: copy ""
	print join "Pinging " name

 print "***********************************************************"
	call/output reform ["ping " address " -n 2"] tmp
	print [head clear find/last tmp "Ping"]
]

When I run it via a shortcut (on Windows 7) it prints this:

Pinging DC1
*****************************************

and then it just hangs until I force it close.


Any ideas why running it via a shortcut would do this when running 
it via Crimson it works fine???
BrianH:
23-Nov-2011
What's the command in Crimson Editor for running a file of that type?
BrianH:
23-Nov-2011
It works without start though, even if you do call/show. Maybe it's 
a bad interaction with start, Pekr.
Singy:
23-Nov-2011
Dock the shortcut target line, when run in a cmd console runs the 
program fine. The only time it does not run is when I try to run 
the same command from the shortcut!
Dockimbel:
23-Nov-2011
Let me try with a shortcut on 2.7.6...
Dockimbel:
23-Nov-2011
With a shorcut, it hangs too, but if you add a /SHOW refinement to 
CALL, it works.
Dockimbel:
23-Nov-2011
It's probably a REBOL bug.
Singy:
23-Nov-2011
Yes I think it is a bug, because the whole point of /output is to 
not use shell window but to capture the data that would be sent to 
it and use it instead in your program. Anyway - at least this is 
a workaround for now. Thanks for your input guys :))
Dockimbel:
23-Nov-2011
/SHOW is a late addition to CALL, we used to live with the DOS window 
for years.
Singy:
23-Nov-2011
Well - looks like I might be living with it for a few more yet - 
grins.
Singy:
23-Nov-2011
I have another question - probably a dumb one - can you use make 
routine! to tap into .Net or is this impossible because it is a managed 
language?
Singy:
23-Nov-2011
Thanks Doc. However, is there a way to tap into .Net from REBOL? 
As a network admin it would be useful at times. I know you can use 
call to draw upon powershell which in turn can use .Net but that 
seems a bit convoluted. Also I can use wmic via call as well. Any 
other thoughts on REBOL and .Net integration?
Dockimbel:
23-Nov-2011
Doing a quick search on this topic (as it's interesting also to me 
for Red), it seems that LOADing a .Net library is at least possible 
from C++: http://stackoverflow.com/questions/757298/loading-managed-c-dll-from-plain-c-program-via-loadlibrary
Dockimbel:
23-Nov-2011
From REBOL, you could set up a TCP communication channel with a .Net 
app to pass commands and receive data. You can achieve that using 
plain REBOL code or using a messaging library like 0MQ.
Dockimbel:
23-Nov-2011
Maybe you could just make a simple powershell script for making it 
work as slave for REBOL.
Dockimbel:
23-Nov-2011
(using a TCP channel)
Singy:
23-Nov-2011
Using a powershell script definitely works because I have tried it 
- I just used: call "powershell scriptname.ps1" and it worked. But 
of course I need to know 3 languages to do this - REBOl, powershell 
and .Net.
Dockimbel:
23-Nov-2011
I meant using a powershell script for writing a server that would 
receive commands from a REBOL client through TCP. The REBOL client 
could then hide the powershell commands inside adequate REBOL functions, 
making it feel more natural.
Dockimbel:
23-Nov-2011
It seems to be possible to write C wrappers for managed code too: 
http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-interop/5678/Can-Unmanaged-Code-call-LoadLibrary-on-a-managed-DLL
Singy:
23-Nov-2011
Hosting the Common Language Runtime - as per that last article sounds 
interesting - I wonder how large that would be. What about running 
REBOL in the DLR like iron python etc. Is such a thing doable? Or 
is that a blasphemous though to REBOlers?
Singy:
23-Nov-2011
It will be interesting to see how Doc pulls it off then when he gets 
to that stage in Red (interfacing to .Net I mean). I love REBOL but 
as a netwok admin who lives in a world of Windows being able to interact 
with all things Windows from REBOL would be heaven :))
BrianH:
23-Nov-2011
As someone who uses MS SQL Server a lot, being able to call R3 from 
.NET could lead to stored procedures written in REBOL, maybe :)
BrianH:
23-Nov-2011
In that case, reimplementation starts to look pretty good, or maybe 
even a Red port if it gets PARSE support :)
Dockimbel:
23-Nov-2011
PARSE support: certainly! Supporting .Net  as a target for Red compilation 
(more accurately: for Red/System compilation) is in the roadmap, 
but not a high-priority though.
Awi:
24-Nov-2011
Hi, I am trying to write a Rebol app that download some .png map 
tiles from OpenStreetMap, and display them.  Since Rebol does not 
support multithreading, while downloading every map tile, the user 
will face a non responding screen, which is not very nice. Is there 
a known trick to download in background, or something like that? 
Many thanks..
Awi:
30-Nov-2011
@Kaj: Sorry, a little of the topic. For the future, I'm planning 
to replace the Rebol 2 UI side of my app to use libchamplain or osm-gps-map. 
Hopefully I can already use red by then (currently python is in my 
mind). Which one do you think is more mature and easy to use? My 
app would only display OSM tiles and draw some objects and lines 
on it. Thanks for your opinion and pointing me into these libraries.
Marco:
3-Dec-2011
I don't know where to post this request, so I put it here:

I am translating some .h files of useful shared library to rebol 
( fmod,sdl,opengl) so if you know of a useful-multiplatform-publi-shared 
library

please give me lonks to binaries, .h files and test programs, thanks.
Oldes:
3-Dec-2011
I'm mainly using ImageMagick in a real live (R2) - here is a minimal 
set of routines - https://github.com/Oldes/rs/blob/master/projects/imagick/minimal/imagick.r
Janko:
20-Dec-2011
is there already any way to turn block to object like data: [ a 1 
b "c" ]  ===> data: make object! [ a: 1 b: "c" ] so I could >> do 
bind [ print a ] data ; or do I have to do that "manually" ?
Geomol:
20-Dec-2011
One way:

	data: [ a 1 b "c" ]
	forskip data 2 [change data to set-word! data/1]
	data: make object! data


I don't know, if there is a simpler function call, but you could 
wrap that into your own new function.
Steeve:
20-Dec-2011
in R3:
>> append context [] [a 1 b "c"]
== make object! [
    a: 1
    b: "c"
]
Steeve:
20-Dec-2011
btw, in R2, forskip is a mezz (may be slow)
Endo:
21-Dec-2011
Is there a easy way to set REBOL Console title other than "REBOL/View"?
I want to give output to console but cannot change the title.
Endo:
21-Dec-2011
There is already a ticket on RAMBO #3660. Any easy way?
Endo:
21-Dec-2011
Thanks a lot.
Janko:
23-Dec-2011
today I discovered maybe fairly obvious thing about rebol, that was 
bugging me for long time and I thought there is no solution:
compose [ ([]) ] == []
compose [ ([ 1 2 3 ]) ] == [ 1 2 3 ] 


I just assumed taht compose functions the same way as reduce and 
never looked in details. And there were many instances where I would 
need such behaviour and I had to invent worse solutions because I 
didn't think it was possible with rebol.


I had it as one sign that rebol is not as mature as lisps because 
there you have @to deconstruct list in such a manner. But now I see 
we have even cleaner solution also.
Janko:
24-Dec-2011
I have one binding + object question that is beyond me.. .this code 
represents it:
> c2: make c1 [ a: [b] b: func a [ print b ] ]
>> c1/a
== [a]
>> c1/b
** Script Error: b is missing its a argument
** Where: open-proto
** Near: c1/b
>> c2/a
== [b]
>> c2/b
** Script Error: b is missing its b argument
** Where: open-proto
** Near: c2/b
>> c3: make c1 [ a: [b] ]
== [b]
>> c3/a
== [b]
>> c3/b
** Script Error: b is missing its a argument
** Where: open-proto
** Near: c3/b
Janko:
24-Dec-2011
Please look here instead: http://pastie.org/3065592-- the point 
is when I extend c1 with c3 and define a I want that b which I didn't 
redefine takes the a from c3 not c1 where it was created (which I 
do understand is normal behaviour). Is this even possible?
BrianH:
24-Dec-2011
In C1 and C2 you are creating new functions and assigning them to 
their 'b fields. In C3 you are just making a rebound copy of the 
function created in C1, which still has an [a] argument block. Changing 
the value of the object field a doesn't change the argument list 
of the function assigned to the object field b after that function 
has been created.
BrianH:
24-Dec-2011
What's weirder (only tested in R3 so far): Once the function is created 
its argument words are bound to the internal function context, and 
bindings are by position in the context (though BIND determines this 
position from the name at binding time). That means that after the 
function is created, the displayed argument block is just documentation 
- the real argument list is the function context. This means that 
if you create the function using MAKE directly and keep a reference 
to the spec block, then change that spec block, the changes don't 
affect the function's behavior or what WORDS-OF returns. Like this:

>> a: [a] b: make function! reduce [a [print a]]
>> b 1
1
>> change a 'b
== []
>> b 1
1
>> source b
b: make function! [[b][print a]]
>> words-of :b
== [a]

>> help b
USAGE:
        B a

DESCRIPTION:
        (undocumented)
        B is a function value.

ARGUMENTS:
        b
BrianH:
24-Dec-2011
It doesn't work that way in R2. Changes to a reference to the argument 
spec block don't change the function after it's created. Like this:
>> a: [a] b: make function! a [print a]
>> change a 'b
== []
>> source b
b: func [a][print a]
>> words-of :b
== [a]
BrianH:
24-Dec-2011
Note: In R2, if you use the old-style reflectors to get at the spec 
then you can replicate the R3 weirdness because it returns a reference 
to the original spec. The SPEC-OF reflector is much safer, even in 
R2, because it returns a deep copy instead. Have I mentioned lately 
just how bad it is to use the R2-style ordinal reflectors instead 
of the R3 style *-OF reflectors?
BrianH:
24-Dec-2011
The inconsistency between R2 and R3 is because R3's reflection model 
was changed to be more secure, and easier to sandbox. In R3 you can't 
get a reference to the real spec and body of a function after the 
function is created, at least from non-native, non-debug code. That 
is why the hack above required saving a reference to the spec from 
before the function was created; if you don't do that, you won't 
be able to get at the spec or body afterwards if your security settings 
are set to the defaults (and turned on - that's another story).
BrianH:
24-Dec-2011
The inconsistency between R2's and R3's spec and body copying behavior 
during MAKE function! was an efficiency issue. The startup code of 
R3 uses a non-copying version of FUNC, and this speeds up startup 
quite a bit. However, the function builder mezzanines copy the spec 
and body, moving the copying behavior from the MAKE action to the 
mezzanine code - it's still about as fast because the actual copying 
is done by the same native code. As a side benefit, we get a bit 
more flexibility when we need it, especially when you don't leak 
references to the original spec and body that were passed to the 
MAKE action. MAKE module! does the same non-copying behavior for 
the same reason, though MODULE doesn't make a copy because the body 
is generally even bigger, and is not saved at all in the constructed 
module.
Gregg:
27-Dec-2011
In cases where I need to launch REBOL from encapped, I have included 
config options; sometimes on a per-command basis, so I can launch 
a specific version of REBOL for different needs.
Endo:
27-Dec-2011
Ok, now I see.

If I have a encapped script and need to launch a new REBOL process 
to execute another script (not encapped), is it the correct way, 
CALL my exe with a command-line argument to execute the other script?
nve:
27-Dec-2011
I want to declare a function with several rafinments by only one 
can be selected :
myfunc: func [/r1 /r2] [...]
myfunc/f1 or myfunc/f2
I don't want to allow : myfunc/f1/f2
Henrik:
28-Dec-2011
>> a: func [/b /c] [if all [b c] [make error! "Only one refinement 
can be used."]]
>> a
== none
>> a/b
== none
>> a/c
== none
>> a/b/c
** User Error: Only one refinement can be used.
** Near: make error! "Only one refinement can be used."
nve:
28-Dec-2011
@Henrik : thanks a lot !
BrianH:
28-Dec-2011
nve, there is a built-in error that might be better for you to use. 
Try this:
>> cause-error 'script 'bad-refines none
** script error: incompatible or invalid refinements
Marco:
16-Jan-2012
Is there a way to avoid conversion of numbers to scientific notation 
by mold?
>> mold 0.004
== "4E-3"


or have you a function to convert back a string representing a number 
with exponent to one eithout it?
Gregg:
16-Jan-2012
I have a general FORMAT func I use, but it's quite heavy as it handles 
a lot of things.
Endo:
17-Jan-2012
I've also put a format-number function that I use on Checklists on 
Altme. It works well for me.
>> format-number 1 / 3
== "0.333333333333333"
Marco:
18-Jan-2012
The function by Nick is a little slow since I have a lot of numbers. 
This is faster but not very fast:

format-decimal: func [x /local e q] [
	x: form x
    if find x "E-" [ 
		e: to-integer next next q: find x "E-"
		clear q
		remove find x "."
		if #"-" = first x [x: next x]
		insert/dup x "0" e
		insert next x "."
	]
	head x
]

The idea from Ladislav is nice but I would like most a more "rebol" 
solution.
Evgeniy Philippov:
23-Jan-2012
Is there a possibility for cyrillic/Russian at Rebol/View except 
for pixelart drawing the characters?
32601 / 6460812345...325326[327] 328329...643644645646647