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

World: r3wp

[Core] Discuss core issues

Ladislav
3-Jul-2010
[17210x5]
(you just need to read above)
Note: all versions work just in (auto-adjusting) R2
I am mentioning that, since there were some versions of R2 that did 
not auto-adjust
(long time ago)
But, it is possible to write a modified version, which would work 
regardless of auto-adjustment
BrianH
3-Jul-2010
[17215]
In 2.7.7, indexes auto-adjust if you clear the series from the beginning, 
but not if you clear from later on. In the same interpreter.
Ladislav
3-Jul-2010
[17216x2]
Wrong, see above
You did not check Henrik's example as I did
BrianH
3-Jul-2010
[17218]
I did, but got different results than I am getting now.
Ladislav
3-Jul-2010
[17219]
Actually, you did not, it was just an error
BrianH
3-Jul-2010
[17220x2]
With the same code, no less, I am getting different resulta now.
I didn't post the the old results.
Ladislav
3-Jul-2010
[17222x3]
You are getting the same results you got before, it was just your 
error, resulting from the fact, that auto-adjustment adjusts past-tail 
series to tail indices, i.e. to 2 in case Henrik posted
Nevertheless, it is easy to write code that would work regardless 
of auto-adjustment
(which means, it would work in R2, old R2, and R3)
BrianH
3-Jul-2010
[17225x2]
Well, I don't know why the results are different from the same code, 
but your code works now, so if it's alright with you I'll update 
R2/Forward with it.
I'll just chock up the old results to a momentary glitch until they 
recur.
Ladislav
3-Jul-2010
[17227x3]
E.g. this modification works regardless of auto-adjustment: (i.e. 
even in R3)

past?: func [
	"Returns TRUE if a series is past its tail."
	series [series! gob! port!]
] [
	and~ greater-or-equal? index? :series index? tail :series
	    not same? :series tail :series
]
but, pick whichever version you like
BTW, "returns true if a series index is past its tail" mixes different 
datatypes - series index is integer, while tail is a series, so, 
my opinion is, that the shorter wording is less misleading
BrianH
3-Jul-2010
[17230]
The not same? :series skip :series 0 line works well enough, afaict. 
Do you have a case for which it doesn't work and the larger test 
is required?
Ladislav
3-Jul-2010
[17231x5]
aha, it looks, that it works even in R3...
Case for which it does not work... - only in ancient versions of 
R2
nevertheless, I see it as a bug, that it works even in R3
That is actually an auto-adjustment test, and I thought, that no 
auto-adjustment was taking place in R3
Nevermind, I will declare it "a feature"
BrianH
3-Jul-2010
[17236]
Well, in R3 PAST? is built-in. And auto-adjustment was taken away 
in R3 on purpose, at the same time that PAST? was added.
Ladislav
3-Jul-2010
[17237x3]
Yes, but skip :series 0 auto-adjusts still, but, as I said, I do 
not mind
How about the help text? The longer one (currently used in R3) looks 
misleading.
(comparing series index - an integer, to series tail - a series)
BrianH
3-Jul-2010
[17240]
It's not misleading without the auto--adjustment. With the auto-adjustment 
a past-tail index will auto-adjust, which should be mentioned somehow.
Ladislav
3-Jul-2010
[17241x2]
OK, nevermind, I do not want the text to be longer, a "series is 
past its tail" looks better to me, than any reference to series index
, and it relates to the problem better, since in the case below:

>> b
== ** Script Error: Out of range or past end


what is past tail is just the series not any "series index", which 
should be an integer value, and as such it cannot be "past tail"
Ladislav
4-Jul-2010
[17243]
I adjusted the http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Series
article to mention the past-tail series and to explain differences 
between series with fast indexed access and series with fast insert/remove 
operations.
Vladimir
5-Jul-2010
[17244x3]
Is there a way to find out types of drives present in windows from 
rebol ?
I managed to get list of all drives using read %/.
I would like to know which of those are flash drives or memory cards...
Henrik
5-Jul-2010
[17247]
I suppose you need to dig into the registry for that.
Sunanda
5-Jul-2010
[17248]
This is _a_ way in windows (but you need to be running in admin mode 
.... so not so usefu):
    capture-call: copy ""
    call/output/info "fsutil fsinfo drivetype e:" capture-call
    print capture-call
    == "e: - CD-ROM Drive^/"
Gregg
6-Jul-2010
[17249x2]
FSUTIL or APIs, with the caveat that Sunanda noted.
REBOL []

do %../library-dialect/lib-dialect.r

make-routines [
    lib %kernel32.dll
    def-rtn-type long
    ; returns available drive flags as a bitset (in a long)
    get-logical-drives "GetLogicalDrives"
    get-logical-drive-strings "GetLogicalDriveStringsA" [
        buff-len [integer!]
        buffer   [string!]
    ]
    get-drive-type [drive [string!]] "GetDriveTypeA"
]


drive-types: [
    Unknown     ; 0 We don't know what kind of drive it is
    NoRootDir   ; 1 Probably not a valid drive if there's no
                ;   root directory
    Removable   ; 2 It's a removable drive
    Fixed       ; 3 It's a fixed disk
    Remote      ; 4 It's out there on the network somewhere
    CDROM       ; 5 It's a CD ROM drive
    RAMDisk     ; 6 It's not a real drive, but a RAM drive.
]

drive-type?: func [drive /word /local res] [
    res: get-drive-type join first trim/with form drive "/" ":"
    either word [pick drive-types add res 1] [res]
]

get-drive-strings: func [
    /trim "Return only the drive letters, no extra chars"
    /local len buff res
][

    ; Call it once, with 0, to find out how much space we need in our 
    buffer
    len: get-logical-drive-strings 0 "^@"
    ; Init our buffer to the required length
    buff: head insert/dup copy "" #"^@" len
    ; Make the call for real, to get the data
    len: get-logical-drive-strings length? buff buff
    res: parse/all copy/part buff len "^@"
    if trim [foreach item res [clear at item 2]]
    res
]

;print enbase/base to binary! get-logical-drives 2
foreach id [a b "C" 'c "D" d: %E %F %/F] [
    print [mold :id tab drive-type? :id tab drive-type?/word :id]
]
print mold get-drive-strings
print mold get-drive-strings/trim
print read %/
Graham
6-Jul-2010
[17251x2]
Is this a bug?

>> o: construct [ a: true b: yes c: yes ]
>> probe o
make object! [
    a: true
    b: 'yes
    c: 'yes
]


http://www.rebolforum.com/index.cgi?f=printtopic&topicnumber=47&archiveflag=new
>> o: construct [ a: true b: yes c: on ]
>> probe o
make object! [
    a: true
    b: 'yes
    c: true
]
Maxim
6-Jul-2010
[17253]
replied there...

I usually mold/all for such things...
    
o: construct [ a: true b: yes c: on ]
    
>> print mold/all o
#[object! [
     a: #[true]
     b: yes
     c: #[true]
]]
Graham
6-Jul-2010
[17254]
construct should not evaluate .. but it is
Maxim
6-Jul-2010
[17255x2]
true values are a specific special case... they are not evaluated.
construct exiplictely looks for the words none, true, false, yes, 
no   and replaces them with their value equivalents.
Graham
6-Jul-2010
[17257]
So, why is yes not evaluated but true and and on are?
Maxim
6-Jul-2010
[17258x2]
sorry... that would be on, off (not yes no)
probably because Carl forgot to include yes/no into the construct 
special case... its possible he did it on purpose.