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

World: r3wp

[Core] Discuss core issues

Maxim
11-May-2010
[16555]
late but here is an equivalent working example:

names: [
	["zz" "bb"] ["cc" "zz"] ["aa" "aa"]["bb" "ee"]
	["zz" "tt"] ["cc" "aa"] ["aa" "yy"]["bb" "aa"]
]
sort/compare names func [a b][
	either a/1 = b/1 [a/2 < b/2][a/1 < b/1]
]
probe names

== [ ["aa" "aa"] ["aa" "yy"] ["bb" "aa"] ["bb" "ee"] ["cc" "aa"] 
["cc" "zz"]  ["zz" "bb"] ["zz" "tt"] ]
amacleod
11-May-2010
[16556]
that limits it to comparisons on two fields...right?
Maxim
11-May-2010
[16557x2]
yep... as sunanda said, you need to chain the compares.


there might be a way of using ANY/ALL functions too, but it can be 
tricky ... though usually yields less code.
yields = requires
Sunanda
11-May-2010
[16559]
Something like this will sort on all fields
 

sort/compare s func [a b] [for n 1 length? a 1 [if a/:n < b/:n [return 
-1] if a/:n > b/:n [return +1]] return 0]
Maxim
11-May-2010
[16560x2]
refining sunanda's example, sorting on selected fields

sort/compare s func [a b] [
	repeat n [2 4] [
		if a/:n < b/:n [return -1] if a/:n > b/:n [return +1]
	] 
	return 0
]


I just indented it to make it a bit easier to break up
note, the order of the fields given is the order in which they are 
weighted
Sunanda
11-May-2010
[16562]
Thanks, Maxim -- that's nice.
Maxim
11-May-2010
[16563]
I wouldn't have thought of your idea, so I thought *yours* was really 
nifty  :-)
amacleod
11-May-2010
[16564]
That awsome...thanks guys
Izkata
11-May-2010
[16565x2]
I've used 'case statements for multiple levels of sorting, like that
...although I can't seem to find where right now
amacleod
13-May-2010
[16567]
can you use get-modes over ftp?
Graham
13-May-2010
[16568]
try it ..
amacleod
13-May-2010
[16569x2]
i get errors
>> nodes: get-modes port 'file-modes
** Script Error: Invalid argument: file-modes
** Where: halt-view
** Near: system/words/get-modes port/sub-port modes
BrianH
13-May-2010
[16571]
You might not be able to get file-modes. Try some of the other modes.
Graham
13-May-2010
[16572]
You might be able to modify my ftp protocol for R3 to add the SITE 
command so that you can do CHMOD if that's the aim
BrianH
13-May-2010
[16573]
modify my ftp protocol

 for R2. R3 doesn't have anything like GET-MODES yet, though something 
 is planned.
Graham
13-May-2010
[16574x2]
or you could modify the ftp protocol for r2 to display all the file 
modes sent back by the LIST commands
I think my r3 protocol does currently display all the file attributes
BrianH
13-May-2010
[16576x2]
That might be tricky though, because different FTP servers format 
that information differently. A large portion of the source for FileZilla 
or other FTP clients that have GUIs for file listings is different 
parsers for the file listings of different FTP server software.
But we have PARSE, so it doesn't have to be that bad :)
Maxim
13-May-2010
[16578]
IIRC mozilla's ftp server code is like 1MB of source code.
Graham
13-May-2010
[16579]
practically speaking though if you only have the one ftp server .. 
you only have to do it once
Maxim
13-May-2010
[16580]
ftp server.... should read   ftp server specific
Graham
13-May-2010
[16581]
the r2 formatting code is a page of parse rules
BrianH
13-May-2010
[16582]
Practically speaking, there are probably over a hundred different 
FTP server platforms, and the R2 parsing code only supports (hopefully) 
most of them.
Graham
13-May-2010
[16583]
So, if you're not looking for a generalized solution.. then it's 
quite doable.
Maxim
13-May-2010
[16584]
I've had issues where paths misaligned between list, read and write 
ops !
BrianH
13-May-2010
[16585]
It would have been great if the output format of the FTP commands 
had been part of the FTP spec. C'est la vie.
Maxim
13-May-2010
[16586]
one of the problem is the ftp RFC which changed too many times and 
some older servers which forked between those changes.
BrianH
13-May-2010
[16587]
Plus the stuff not covered by any of the RFCs at all, like file listing 
formats. There are Windows FTP servers that format their listings 
like DOS DIR listings, Unix servers that actually call ls, etc.
Maxim
13-May-2010
[16588]
yep
amacleod
13-May-2010
[16589]
I wanted to get modification-date on file for sycing...any other 
popular methods for this type of thing?
BrianH
13-May-2010
[16590]
'net-modes ?
amacleod
13-May-2010
[16591]
network-modes? I do not see a ref erence to file dates.
Maxim
13-May-2010
[16592x2]
info?  returns file date in the block
block = object
amacleod
13-May-2010
[16594]
Are we still in "get-modes"/
BrianH
13-May-2010
[16595]
INFO? is a different function than GET-MODES.
amacleod
13-May-2010
[16596]
i'll try it thanks
Anton
14-May-2010
[16597x3]
>> print mold get-modes %user.r get-modes %"" 'file-modes

[status-change-date: 10-May-2009/16:24:13+10:00 modification-date: 
10-May-2009/16:24:13+10:00 access-date: 14-May-2010/21:42:52+10:00 
owner-name: "anton" group-name: "anton" owner-id: 1000 group-id: 
1000 owner-read: true owner-write: true owner-execute: false group-read: 
true group-write: false group-execute: false world-read: true world-write: 
false world-execute: false set-user-id: false set-group-id: false 
full-path: %/home/anton/dev/rebol/view/user.r]
Much easier to read if you do PRINT MOLD CONTEXT ...
Oops, you wanted FTP, sorry.
Graham
14-May-2010
[16600]
if the file is also available by http, I check the file date that 
way ...
amacleod
15-May-2010
[16601]
Can you send html email via rebol SEND?
Graham
15-May-2010
[16602]
sure ...
amacleod
15-May-2010
[16603]
I tried using an html doc as the message but it just displayed the 
code
Graham
15-May-2010
[16604]
You probably need a custom header