World: r3wp
[Core] Discuss core issues
older newer | first last |
JaimeVargas 14-Jun-2006 [4835x5] | What I need is to be able to capture the full path of the first arg passed to such script. |
Not just the filename. | |
The reason is that the script is no of the same path of /usr/local/bin the script fails to find the file. | |
Which is passed as arg | |
Hopefully this is not too convoluted... | |
Gabriele 14-Jun-2006 [4840] | if you encap it, the CD will be the dir where the program was started from. when run with a shebang though... not sure if there's a way. |
JaimeVargas 14-Jun-2006 [4841] | No SDK in OSX :-/ |
Ingo 14-Jun-2006 [4842] | Hi Jaime, I think you're looking for this system/script/path |
Volker 14-Jun-2006 [4843x2] | probe system/options |
IIRC the shell-dir is somewhere there. Or try system/options/script/parent/path. | |
JaimeVargas 14-Jun-2006 [4845] | Thx, Ingo and Volker, what I was looking for is SYSTEM/OPTIONS/PATH |
BrianW 14-Jun-2006 [4846x6] | Dumb question: When I'm printing a string, what's the best way to show special characters (^/ etcetera) in their special form, rather than just expanding them (turning ^/ into an actual newline, for example)? |
well, I know probe is the way to do it direct to stdout, but I want to save the "probe" value to a string | |
and for the public record, at least part of my answer is: raw-str: mold real-str | |
yay for "source probe" | |
How about going the other way? Turning newlines into ^/ characters and so on? | |
and again I answer my own bloody question: replace/all (mold real-text) "^/" "^^/") Guess I don't actually start thinking for myself until I ask the question somewhere that I can look dumb ;) | |
Izkata 14-Jun-2006 [4852] | But that's the best way - you're more likely to remember it then! |
james_nak 15-Jun-2006 [4853] | Is there a way to "copy" an object (already defined) so the result is a distinct object? It's probably something easy but for the life of me... |
Anton 15-Jun-2006 [4854] | make |
james_nak 15-Jun-2006 [4855] | Thanks Anton. Yep, right after I wrote that I said to myself "Self, why don't you try 'd: make c [ ]'" and it works...and it is in the docs on objects. Duh. Thanks. |
Anton 15-Jun-2006 [4856] | :-) |
BrianW 15-Jun-2006 [4857] | Good to know I'm not the only one :) |
james_nak 15-Jun-2006 [4858] | You kidding? I hate it when I spend hours trying to figure out what's up. : ( |
Anton 15-Jun-2006 [4859x2] | Just remember, strings are copied, blocks are deep copied, but sub-objects are shared. |
>> o: make object! [s: "hello" b: [there] o: make object! []] >> o2: make o [] >> same? o/s o2/s == false >> same? o/b o2/b == false >> same? o/o o2/o == true | |
james_nak 15-Jun-2006 [4861] | Thanks! Sub-objects shared. Hmmm. That would have thrown me fo sure. |
Robert 16-Jun-2006 [4862x2] | This is IMO inconsistent and should be changed: >> ? for USAGE: FOR 'word start end bump body DESCRIPTION: Repeats a block over a range of values. FOR is a function value. ARGUMENTS: word -- Variable to hold current value (Type: word) start -- Starting value (Type: number series money time date char) end -- Ending value (Type: number series money time date char) bump -- Amount to skip each time (Type: number money time char) body -- Block to evaluate (Type: block) (SPECIAL ATTRIBUTES) catch throw >> a: 2.0 == 2.0 >> for test 1 a 1 [print test] ** Script Error: for expected end argument of type: integer ** Near: for test 1 a 1 >> number? a == true It should be possible to use decimal! as well. The interpreter should implicitly convert it to an integer! |
The docs state number! and not integer! | |
BrianH 16-Jun-2006 [4864] | The type of the start and end variables must be the same. If you look at the source of for, you will see that it throws that error when they are not. |
Robert 17-Jun-2006 [4865] | Yes, but 2.0 can be converted to 2, so no problem. |
Oldes 17-Jun-2006 [4866x3] | I would like to have read-thru in Rebol?Core as well |
so at least such a simple function: | |
read-thru-to: func[url target /local data loc-path][ either exists? target [read/binary target][ loc-path: first split-path target if not exists? loc-path [make-dir/deep loc-path] write/binary target data: read/binary url ] data ] | |
MikeL 17-Jun-2006 [4869] | Oldes - on true for exists? shouldn't it be "data: read/binary target" since you return :data? |
BrianH 17-Jun-2006 [4870x2] | Robert, although 1 and 1.0 are both numbers, they are not the same type in REBOL. Sure, they can be converted, but unless you do so they aren't. It would be simpler to just rewrite your example to this: >> a: 2.0 == 2.0 >> for test 1.0 a 1 [print test] 1.0 2.0 and not have the type mismatch I was talking about. Unfortunately REBOL doesn't have type signiatures that are powerful enough to specify that these two parameters need to be the same type, so that constraint has to be enforced in the code. |
Oldes, a builtin read-thru would require Core to be installed rather than just copied somewhere, just like it does with View - view-root is set during installation. Still, all of the *-thru functions are written in REBOL, so they can be copied and adapted to your purposes quite easily. | |
Volker 17-Jun-2006 [4872] | a view-root: what-dir works quite well. |
BrianH 17-Jun-2006 [4873] | See, I told you they could be adapted easily :-) |
Volker 17-Jun-2006 [4874] | :) |
BrianH 17-Jun-2006 [4875] | Personally, I always thought view-root should be under system/options somewhere. |
Anton 17-Jun-2006 [4876x2] | Robert, what are the actual numbers you need FOR for ? |
BrianH, like system/options/home ? | |
BrianH 17-Jun-2006 [4878] | Yeah, something like that. Maybe system/user/sandbox or something. For that matter, system/user/home should be set to something useful on Windows, like %userprofile% or better yet %appdata%. |
Anton 17-Jun-2006 [4879] | Oldes, Volker, I put into my rebol/core user.r file: view-root: dirize clean-path system/options/home/../view user-prefs: context [debug: none] ; fake user-prefs vbug: func [msg [block! any-string!] /local dbg][ if not dbg: user-prefs/debug [exit] msg: head insert remold msg "view " either file? dbg [write/append dbg msg] [print msg] ] along with the source to these functions: path-thru exists-thru? read-thru load-thru read-net |
BrianH 17-Jun-2006 [4880] | For that matter Volker, you could set view-root to the standard sandbox directory like this: view-root: join to-rebol-file get-env "APPDATA" "REBOL" |
Volker 17-Jun-2006 [4881x2] | Yes, but then i get security-questions. |
And i dont like to rely on user.r . personal preference. | |
BrianH 17-Jun-2006 [4883x2] | Yeah, those security questions. |
As for relying on user.r, I prefer rebol.r for things like this. | |
older newer | first last |