World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
sqlab 15-May-2009 [2446x2] | So you first want to generate a table with 13 * 48 elements? |
array/initial 13 array/initial 48 none | |
mhinson 15-May-2009 [2448] | and each of the 13 * 48 elements will have up to 3 different bits of information |
sqlab 15-May-2009 [2449] | array/initial 13 array/initial 48 array/initial 3 none |
mhinson 15-May-2009 [2450] | that looks great! I will just have to give the 3 bits of data numbers instead of names. |
sqlab 15-May-2009 [2451x3] | Otherwise make it flat array/initial 13 * 48 * 3 none and access it with data/(x * 13 + (y * 48) + z) |
You can acces the your free items of the last group with names you can use e.g alias 'first "portn" alias 'second "disabled" alias 'third "vlan" | |
sorry three not free | |
mhinson 15-May-2009 [2454] | thats a handy trick to make it more readable... |
sqlab 15-May-2009 [2455] | or use port: 1 diabled: 2 then /../:port |
mhinson 15-May-2009 [2456] | so much choice.. I wonder if that is both the best & the worst thing about Rebol. :-) Thanks very much for your help & Geomol & Graham. This is a crucial bit of my script & it should start producing the output I need very soon.. I have been learning Rebol to solve a problem, instead of spending my time to sole the problem manualy. But now I am nearly out of time so I a comitted to the scripted aproach. |
sqlab 15-May-2009 [2457] | you're welcome I guess as a beginner you would have reached your goal faster without parse with simple loops and finds |
mhinson 15-May-2009 [2458] | I heard about Rebol because of parse, & it seems right to learn about it. I am stll very much a noob & appreciate the intensive help I get here very much. I think the only way I could have got more help would have been to use a cute girls name as my login. ;-) |
sqlab 15-May-2009 [2459x2] | Unfortunately you can infer from the name to the look.) But I will give you another hint, try to use new-line/all with your data |
should read "you cannot .." .) | |
Henrik 15-May-2009 [2461] | 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 [2462x4] | 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] |
That will give you 13x48 unique objects in nested blocks. | |
>> x: 0 == 0 >> array/initial [2 3] does [x: x + 1] == [[1 2 3] [4 5 6]] | |
One interesting thing to note is that because the data in the objects is blocks, MAKE will bind/copy the blocks to the new object. This is why you don't have to copy the blocks explicitly when you make a new object based on the proto. | |
Steeve 15-May-2009 [2466] | i should use array too now, i didn't noticed those usefull evolutions |
Henrik 15-May-2009 [2467] | oh, I didn't know that one. |
Izkata 15-May-2009 [2468] | Wow, I was looking for something like that.. |
mhinson 15-May-2009 [2469x2] | Have I broken REBOL ? >> print round 2 ** Script Error: Cannot use subtract on decimal! value ** Where: throw-on-error |
I put Protect-System on & found what I had done... It was a bit confusing what I was seeing till I worked this out. | |
Maxim 15-May-2009 [2471] | did you replace the value of round by any chance? |
mhinson 15-May-2009 [2472] | no mod |
Steeve 15-May-2009 [2473] | SHAME ON YOU ;-) |
mhinson 15-May-2009 [2474x2] | I used mod to recieve date from copy in a parse |
I almost didnt because I know mod is maths term... I supose modifying the system is not on your mind till you are more of a Rebol. | |
BrianH 15-May-2009 [2476] | 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. |
Steeve 15-May-2009 [2477] | SHAME ON US :-) |
BrianH 15-May-2009 [2478] | Hey, if I hadn't written it myself I wouldn't have noticed either :) |
mhinson 15-May-2009 [2479] | I like the sound of that Brian, but as your example dosn't work I dont really understand the syntax.. >> switch-module: array/initial [13 48] does [make object! port-proto] ** Script Error: Invalid argument: object |
BrianH 15-May-2009 [2480x2] | First, which version of REBOL are you using? If not 2.7.6, it won't work. |
Oh wait, it's the contents of the does. Try this: does [make port-proto []] | |
mhinson 15-May-2009 [2482x2] | 2.7.6.3.1 it is new like me |
That works, thank you. | |
BrianH 15-May-2009 [2484] | Even the old guard makes newbie mistakes sometimes :) |
Steeve 15-May-2009 [2485] | 10 push-ups for Brian |
mhinson 15-May-2009 [2486] | I nearly guessed it, but as a noob there are so many options that I could be a while wondering if it is my typing or something too basic to notice. |
BrianH 15-May-2009 [2487] | Clearly the latter :) |
mhinson 15-May-2009 [2488] | These hordes of newbies, always asking foolish questions & never looking at the documentation. ;-) |
Steeve 15-May-2009 [2489] | they are not so much (newbies) there, they faint after some days usually |
BrianH 15-May-2009 [2490] | I'm not sure how well-documented the change to ARRAY is. I didn't handle the documentation of the 2.7.6 release. |
Maxim 15-May-2009 [2491] | someone did? ;-) |
mhinson 15-May-2009 [2492] | if I have this mike: array/initial 3 array/initial 3 array/initial 3 none modAndPort: "2/2" UpState: 2 data: "disabled" How do I use the variables to create this logic please mike/2/2/:UpState: data mike/ModAndPort/:UpState: data Something like this I was hoping mike/(ModAndPort)/:UpState: data ** Script Error: Invalid path value: 2/2 |
BrianH 15-May-2009 [2493x2] | I don't know, Maxim. We have to do better about that in future R2 releases. |
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]. | |
mhinson 15-May-2009 [2495] | More typing saved, thats good. |
older newer | first last |