r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Gregg
25-Oct-2008
[11182x2]
It can in cases where I use it. e.g., cascading calls that may mod 
the date to UTC more than once.
Partly legacy as well. I can't remember if REBOL used to set the 
zone to none, rather than 0:00, or if that was something I did originally.
Graham
25-Oct-2008
[11184]
better to be safe than sorry!
Oldes
25-Oct-2008
[11185]
Rebol zone can be none in some cases.
Graham
25-Oct-2008
[11186]
do you know which?
Oldes
25-Oct-2008
[11187x2]
I'm probably wrong.. it looks it should not be none. It returns 0:0 
instead of none in all cases (event if there is no zone)
>> d: 1-1-2006/1:0:0+0:0
== 1-Jan-2006/1:00
>> d/zone
== 0:00
>> d: 1-1-2006 d/zone
== 0:00
>> d: now d/zone: none d/zone
== 0:00
Graham
25-Oct-2008
[11189]
the problem with dates is that if zone is 0, then it does not display. 
 I wasn't aware of any 'none issue.
Chris
25-Oct-2008
[11190]
do http://www.rebol.org/download-a-script.r?script-name=form-date.r
form-date now "%Y-%m-%dT%H:%M:%SZ%Z"
form-date/gmt now "%Y-%m-%dT%H:%M:%s"
Graham
25-Oct-2008
[11191x4]
didn't know about that one ... but
>> form-date/gmt now "%Y-%m-%dT%H:%M:%s"
== "2008-10-25T20:27:11.000000"
whereas I need
2008-10-25T20:27:11.0Z
Chris
25-Oct-2008
[11195x3]
Yep, you'd have to modify Brian's 'pad-precise...
do http://www.rebol.org/download-a-script.r?script-name=form-date.r

pad-precise: func [s [number!]][
skip tail rejoin ["0" round/to s 
0.1] -4]
form-date now "%Y-%m-%dT%H:%M:%SZ%Z"
form-date/gmt now "%Y-%m-%dT%H:%M:%s"
(a hack -- 'pad-precise shouldn't be global)
Graham
25-Oct-2008
[11198x5]
anyone have a nice word that does this
string: copy/part string n
maybe 'cut ?
more traditionally 'left
I do this a lot to make sure there is no text overflow in database 
fields
Chris
25-Oct-2008
[11203]
'truncate, or just 'clip ?
btiffin
26-Oct-2008
[11204]
Go controversial; use 'only  ;)
Gregg
26-Oct-2008
[11205]
'left is very BASIC-like. One of the first things I did in REBOL 
was some string funcs like that. e.g.

    left: func [s len][copy/part s len]
    right: func [s len] [copy skip tail s negate len]
    mid: func [s start len][copy/part at s start len]
Graham
26-Oct-2008
[11206]
Actually what I would like to do is modify in-situ

cut: func [ 'c n ][
    set c copy/part get c n
]


but this only works for standalone series and not when series are 
part of an object
Anton
27-Oct-2008
[11207x2]
Can't you just use a word ?
>> cut: func [ w n ][ set w copy/part get w n]
>> o: context [s: "hello"]
>> cut in o 's 3
== "hel"
>> o/s
== "hel"
>> t: "bonjour"
== "bonjour"
>> cut 't 3
== "bon"
Graham
27-Oct-2008
[11209]
Ok
Anton
27-Oct-2008
[11210x4]
Navigating my public directory:
>> change-dir %"~niclasen/"
** Access Error: Bad file path: ~niclasen/
** Where: clean-path
** Near: get-modes target 'full-path
The ~niclasen directory was created automatically by path-thru (via 
load-thru).
CLEAN-PATH doesn't like the leading tilde '~'.
It's not in RAMBO.

R3 doesn't have this problem, but it seems that clean-path doesn't 
do anything with tildes. (Maybe R3 clean-path is not using the operating 
system to do path expansion.)
ChristianE
27-Oct-2008
[11214]
If by working in situ you mean you'd like to modify the series directly 
instead of copying parts of it, maybe you can use

cut-left: func [series length] [clear skip series length series]
cut-right: func [series length] [remove/part series length]

cut-middle: func [series start length] [cut-right series start - 
1 cut-left series length]
BrianH
27-Oct-2008
[11215]
Anton, the R3 clean-path is a mezzanine which only applies REBOL 
expansion rules, not OS-specific ones.
Anton
27-Oct-2008
[11216]
Aha, I see, clean-path is a much longer function, now that it's not 
using get-modes.
BrianH
27-Oct-2008
[11217x4]
Tilde expansion could be added using system/options/home if you like.
~ is a valid character for filenames on some platforms though.
Graham, try TAKE for your cut function.
Never mind, TAKE is the opposite of what you want. Try this:
cut: func [s [series!] n [number!]] [clear skip s max 0 n  s]
Gregg
27-Oct-2008
[11221]
'Cut doesn't seem like a good name for this. 'Cut is a *nix command 
that lets you "cut out" the columns you want from data. And if you 
say "cut ["Gregg Irwin" 5], does that mean to cut five chars or keep 
them, and from which end? I think 'keep is a better word for this, 
or maybe 'cut-to.


BTW, I have the same naming issue with my PAD func. i.e. does pad/right 
mean pad *to* the right, or *on* the right. Sometimes you just have 
to live with a bit of ambiguity.
BrianH
27-Oct-2008
[11222]
KEEP is used elsewhere. This is more of a constraint. Perhaps cut-length 
or something like that.
Graham
27-Oct-2008
[11223]
Trim is also taken
Anton
27-Oct-2008
[11224]
BrianH, I actually didn't want tilde expansion for that case (an 
actual directory in the public cache), so R3's behaviour would have 
been good for me. Just wondering if anyone has any thoughts about 
the issue in R2.
Gregg
28-Oct-2008
[11225]
Where is KEEP used? Under R3 it may still be in the COLLECT spec, 
but I don't recall it in R2.
Anton
28-Oct-2008
[11226]
What about FIT ?
Graham
28-Oct-2008
[11227]
I was also thinking of fit
DideC
28-Oct-2008
[11228]
clear-at
Anton
28-Oct-2008
[11229]
discard
BrianH
28-Oct-2008
[11230x2]
COLLECT will be back-ported to R2. At the time of the 2.7.6 release 
the function was still under discussion - now it is finalized. We 
only backport final functions. I'm thinking that FOLD will probably 
make it too :)
How about TRIM-LENGTH ?