• 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
r4wp4382
r3wp44224
total:48606

results window for this page: [start: 24601 end: 24700]

world-name: r3wp

Group: I'm new ... Ask any question, and a helpful person will try to answer. [web-public]
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
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
CIsco operating systems are IOS or CATOS on switches and output formats 
are very different.
PeterWood:
14-May-2009
I think the advice to break the problem down and use more than one 
parse statement is good advice. Let's see how we can do that.


I'll go through how I would approach the problem step by step. Sorry 
that I'll be squashing things on to one line but AltME paste doesn't 
work well on Mac.
PeterWood:
14-May-2009
So what we need to look for are the patterns 2/number and 2/number-number.
PeterWood:
14-May-2009
Let's start with 2/ and see how we get on 


>> parse/all inp [ any [copy range "2/" some digit  (print range) 
| skip ]]
2/

2/

2/
PeterWood:
14-May-2009
Now we can change the parse rule to work with 3/. 4 and  /12:


> parse/all inp [ any [copy range [["2/" | "3/" | "4/" | "12/"]  
some digit]  (print range) | skip ]]                             
              
2/2
2/4
2/33
== true
PeterWood:
14-May-2009
Ladislav's will select values 1 to 13 from any numbers and so is 
more correct.
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).
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
one more thing we need to make agreement on: do we want to rely on 
the default whitespace handling or be more specific and say exactly 
where whitespace may be?
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
Steeve:
14-May-2009
agree, but if repeated part begins and ends with digits, it will 
not failed
mhinson:
14-May-2009
first I am extracting the ports & ranges from the data. after that 
I need to recreate the actual ports and key information & do that 
for several types of input & colate it.
Maxim:
14-May-2009
if you need parts of the data in your parens, the you add pointers 
to the data within the rules (use copy or here:) and se those within 
the processing parens.
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.
Maxim:
14-May-2009
but steeve's might actually be simpler and already includes the basis 
for what you want to do... it you try his rules on your data?
mhinson:
14-May-2009
I think one of the most confusing things about leaning Parse, is 
the occurance of  some & any & | , and the use of [ ]  

the constructs are quite straight forward, but the need for [ ]  
etc is a raw mystery to me.
Maxim:
14-May-2009
or a roll back occurs at the start of the [ ]  and tries the next 
rule following a "|" in the current rule (if any)
mhinson:
14-May-2009
it is installing non aproved applications that is the issue, and 
the need for a proxy config? perhaps that is covered.  I may just 
install it I suppose.
Maxim:
14-May-2009
almost.  if one of the options match (  [option1 | option2 | option3] 
)

then the rule itself is considered a match and it won't attempt the 
other option.
Maxim:
14-May-2009
so the any actually didn't fail, and thus the skip never go to do 
its stuff.
Maxim:
14-May-2009
:-)  I missed such a big feature of rebol for sooo long, just because 
I didn't get these nuances.  and its hard to make a tutorial out 
of this, cause it sooooo boring, and you don't realize why its so 
important until you really start to use parse.
Maxim:
14-May-2009
btw, I keep logging off, cause the winds are wreaking havoc on the 
electricity lines!  there is probably a loose connector on some junction 
and my whole house has rebooted at least 15 times in the last 2 hours 
 :-/
Maxim:
14-May-2009
all of northern usa should be affected the same way, it snowed yesterday 
in central canada!  yet we are already at temperatures of 65-70 on 
average... its just clash of northern and southern winds... creating 
a massive disruption here.
Geomol:
15-May-2009
And then probably PARSE should be used to scan the input and put 
values in the data block structure (maybe building the structure 
along the way, if it's known beforehand).
Geomol:
15-May-2009
You can also do it without using PARSE, if that's too much to start 
with. Read the input as lines with READ/LINES
A line could then be:

line: "vlan 3"

And you can pick the parts with something like:

>> copy/part line find line " "
== "vlan"
>> next find line " "
== "3"


Using PARSE is the elegant way to do it, but can be a bit tricky, 
until you've used it a few times.
Geomol:
15-May-2009
If you use integers and words as your indexâÊyou don't have colon, 
like in:

data/2/35/vlan


If you have a variable with the index, you need the colon to get 
the value of the variable, else REBOL will see it as a word, like 
in:

idx1: 2
idx2: 35
data/:idx1/:idx2/vlan
Geomol:
15-May-2009
If you write

data/idx1/idx2/vlan

REBOL will look for the word idx1 in data, and it's not there.
Geomol:
15-May-2009
data: [ [ [] [vlan 0] ] ]

Your data has nothing in it. To be able to write

data/1/2/vlan: 3


you need to have at least one entry in data, and inside that two 
entries and inside that the word vlan and a value.
Graham:
15-May-2009
you need to create your data structures or objects and then probe 
them to make sure you have it right.
Graham:
15-May-2009
well, one way would be to create the top level object and then add 
the other objects to the first object's members
Graham:
15-May-2009
Now if i2 were an object, you need to instantiate 30 instances and 
append each instance to the i1 member
sqlab:
15-May-2009
then you would need a different structure
with flat 13 * 48 elements first
and you would get 13 * 48 lines output
sqlab:
15-May-2009
But you have always 13 * 48 groups and this is your index
  
1/1 
1/2
..
1/48
2/1
..
2/48
..
13/48

is it?
mhinson:
15-May-2009
and each of the 13 * 48 elements will have up to 3 different bits 
of information
sqlab:
15-May-2009
Otherwise make it flat
array/initial 13 * 48 * 3 none

and access it with data/(x * 13 + (y  * 48) + z)
sqlab:
15-May-2009
you're welcome

I guess as a beginner you would have reached your goal faster without 
parse with simple loops and finds
Henrik:
15-May-2009
mhinson, for your next scripts, maybe you should work a bit more 
on things that are completely unrelated to parse. it helps to get 
away from it a while and then get back to it later.
BrianH:
15-May-2009
ARRAY can take a function as the initial parameter, and that function 
will be called. Try this:
port-proto: make object! [

 vlan: copy []     ;; will hold a number or perhaps a list of numbers 
 e.g. 20 or 3,5,7
	UpState: copy []  ;; none or "disabled"
	name: copy []     ;; any string
]


switch-module: array/initial [13 48] does [make object! port-proto]
BrianH:
15-May-2009
I made that change to ARRAY over a year ago for R3, then backported 
it to R2 for the 2.7.6 release. EXTRACT/default and REPLACE too.
BrianH:
15-May-2009
Mhinson, your first line can be this: ARRAY [3 3 3]

The none value is the default, and the multiple calls can be replaced 
by the [3 3 3].
BrianH:
15-May-2009
>> source array
array: func [
    "Makes and initializes a series of a given size."

    size [integer! block!] "Size or block of sizes for each dimension"
    /initial "Specify an initial value for all elements"
    value "Initial value"
    /local block rest
][
    if block? size [
        rest: next size
        if tail? rest [rest: none]
        size: first size

        if not integer? size [make error! "Integer size required"]
    ]
    block: make block! size
    case [
        block? rest [

            loop size [block: insert/only block array/initial rest :value]
        ]
        series? :value [
            loop size [block: insert/only block copy/deep value]
        ]
        any-function? :value [
            loop size [block: insert/only block value]
        ]
        insert/dup block value size
    ]
    head block
]
Maxim:
15-May-2009
every single day (and often a few times that day):

- I open up a rebol console from quick-launch bar in windows (taking 
about 0.1 sec to appear)
- type help 'some-func 
- test the 'some-func with some-data I'm using. 
- close the console.  


overall it takes about a few seconds, to do a unit test of something 
I'm adding.
 no bloat,  no dangling window.

python offers something similar... but:
- python takes anywhere from 3-10 secs on load.  

- then you have to know in what lib the most basic function is (alread 
half as usefull) 
- the console itself is really bad, 
- previous commands browsing is really stupid

- having to type so much more code to get the simplest function test 
going is a pain
- in the end, its a non-feature.
BrianH:
15-May-2009
I leave a R2 and R3 console open full-time while I'm working. It 
helps to have R3 open too since I don't always remember how much 
of R3 I've backported to R2, so sometimes I remember a function that 
doesn't exist in R2.
Maxim:
15-May-2009
I was just pointing out that rebol is sooo fast to launch that you 
can close it and its not a pain... I easily get up to 10-15 windows 
open at a time, and when you've got half of them as rebol consoles, 
its easier not to guess which one is the help window  :-)
Group: Rebol School ... Rebol School [web-public]
Kaj:
5-Oct-2011
Model and controller would be functions, that you can then connect 
to the View GUI
todun:
5-Oct-2011
@Kaj, thanks. This is begining to make sense. The view is like a 
template, something static the user will see. The MODEL, is a function, 
the controller coordinates with Model and View somehow.
Kaj:
5-Oct-2011
The GUI dialect has places for actions. That's where your model and 
controller functions would go
Kaj:
5-Oct-2011
If you have little experience with all the forms of MVC, it's better 
to forget it and just follow the REBOL tutorials
todun:
5-Oct-2011
Kaj, I have looked at several REBOL tutorialss and I cannot seem 
to be able to make them do exactly what I wanted, hence my pining 
for a paradigm like MVC.
Geomol:
6-Oct-2011
Anyway, pretty much everything is possible in REBOL, so just specify 
as precise as you can, what you want, and someone will come up with 
an idea how to do it.
Pekr:
6-Oct-2011
todun - a little bit more dynamic version of counter:


counter: func ['var add-value][if not value? var [set var 0] set 
var (get var) + add-value]


counter x 10   ; --- x does not have to exist, and if is inicialised 
and set to 0
Geomol:
6-Oct-2011
A mistake is sometimes, that part of REBOL was changed, as everything 
can be redefined. If that's the case, you can try restart REBOL and 
see, if the error is still there.


And yes, you can post code, but most don't like it, if it's too long.
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.
Geomol:
6-Oct-2011
But try put the DO [..] block in, as I suggested, and tell us, if 
it works then.
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)?
todun:
6-Oct-2011
but I want to be able to always go round around the list, go round 
around the file and also write to file the current location I am 
at.
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
For example, if I press question button(displays the question in 
an info view), and then I press answer button(which displays the 
corresponding answer), when next I press question, I want the answer 
info view to go back to being blank. How can I do this? thanks.
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
Henrik:
8-Oct-2011
try SET-FACE and CLEAR-FACE instead of setting and clearing face/text 
directly.
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???
Pekr:
23-Nov-2011
hmm, I tried call/output "start ping 10.10.10.10 -n 2" tmp: copy 
"", and R2 hangs too ....
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 :))
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
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.
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.
Singy:
23-Nov-2011
Well guys, I gotta go now, but thanks for all your help and for the 
stimulating discussion!
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.
Kaj:
30-Nov-2011
Champlain is much more complete and generic, except maybe the GPS 
track functionality. However, it uses Clutter, so OpenGL, so that 
must be available on your target platform
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.
GrahamC:
3-Dec-2011
Oldes and R3 https://github.com/Oldes/R3-extension-FMOD
Oldes:
3-Dec-2011
For imageMagick you can find useful parsed specs for magick_wand 
and pixel_wand routines https://github.com/Oldes/R3-extension-iMagick
Oldes:
3-Dec-2011
I guess it could be even more minimalized.. this subset was enough 
for my needs. As you can see in the parsed routines, there is much 
more what can be done, but it requires time to work on it. Also I 
don't consider R3 evolving so I stoped experimenting with it and 
in the free time I would rather play with Red (but Red is missing 
decimal support so it cannot be used with bindings like FMOD or imageMagick)
Janko:
20-Dec-2011
and I was thinking that there has to be something default already 
made .. thanks! I will create some func our of your code
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 am using rebol for quite few years now and I didn't know it :)
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
Janko, don't worry, I got it. The message beginning with "In C1 and 
C2 you are " was in answer to your question.
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.
BrianH:
24-Dec-2011
The main built-in function that takes advantage of the flexibility 
is FUNCT, which copies the spec and body before it does its collection 
of locals and binding to the static local object. In R2, the spec 
and body are copied again after that by the MAKE action, doubling 
the copying overhead. In R3, they aren't.
Endo:
27-Dec-2011
Is it possible to send command -line arguments to the new REBOL process 
using LAUNCH?
launch "test.r" ;this one works

launch "-s test.r" ;REBOL starts in TRACE ON mode (I don't know if 
%test.r will start or not, too much trace log to wait)

launch "--secure allow test.r" ;shows USAGE and doesn't start %test.r
launch "-q test.r" ; trace mode again.
Gregg:
27-Dec-2011
I standardized on using CALL some time back, as RUN and LAUNCH weren't 
available or consistent in all REBOL versions. system/options/boot 
makes using CALL easy for LAUNCH-like behavior.
Endo:
27-Dec-2011
You put rebol.exe into your encapped file? Or into the same folder?
And how do you put license.key to enable /Pro features?
Gregg:
27-Dec-2011
I haven't done that for commercial products where I would have to 
redistribute REBOL; only systems where the environment is controlled 
and REBOL is in use/licensed.
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?
Gregg:
16-Jan-2012
Many people have examples and funcs out there for it.
Endo:
18-Jan-2012
Scientific notation of numbers and automatic reformating time! values 
(00:00:00 --> 0:00) are the most annoying parts of REBOL for me.
It would be more useful if it doesn't happen when FORMing.
Kaj:
23-Jan-2012
In R3/View, but it's currently buggy and limited to Windows and Amiga
24601 / 4860612345...245246[247] 248249...483484485486487