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

World: r3wp

[Core] Discuss core issues

Graham
28-Aug-2009
[14628]
if you're lazy, your code will break!
james_nak
28-Aug-2009
[14629]
I know. And when I do add things like new fields I'm just asking 
for trouble.
Gregg
28-Aug-2009
[14630]
Graham, this should work.

o: make object! [
    page: "1"
    total: 4
    records: "22"
    rows: reduce [

        context [id: none cell: ["Quantum of Solace" "Marc Forster" "2008" 
        "Daniel Craig" "200"]]

        context [id: none cell: ["Casino Royale" "Martin Campbell" "2006" 
        "Daniel Craig" "150"]]

        context [id: none cell: ["Licence to Kill" "John Glen" "1989" "Timothy 
        Dalton" "36"]]
    ]
]


i.e. objects become objects and blocks become arrays. What exactly 
was breaking?
james_nak
28-Aug-2009
[14631]
Gregg, Hello. He was trying to help me.
Graham
28-Aug-2009
[14632x2]
I'll give it a go.
Hmm.  Seems to work .. but it help to have an example of how it is 
supposed to work!  no docs.
Graham
1-Sep-2009
[14634]
Just wondering what it takes to write a "printer driver".  If I pretend 
to be a network printer listening on port 9100 ... can I just capture 
all the data coming to me or do I have to respond to interrogation 
as well?
Dockimbel
1-Sep-2009
[14635x2]
RFC covering Internet Printing Protocol are listed here : http://en.wikipedia.org/wiki/Internet_Printing_Protocol
I'm not sure that IPP uses port 9100.
sqlab
1-Sep-2009
[14637]
http://tools.ietf.org/html/rfc1179

I remember that I  did once a rudimentary lpd/lpr, but i forgot on 
which pc
Geomol
1-Sep-2009
[14638]
Graham, because we can write to a printer with:
Graham
1-Sep-2009
[14639]
Interesting .. I never bothered before to find out what IPP was.
Geomol
1-Sep-2009
[14640]
write tcp://<ip-number>:9100 <some data>


it should be straight forward to act as a printer listening on port 
9100.
Graham
1-Sep-2009
[14641x4]
Since you can dump to a port on a jet print server on port 9100 ... 
I assumed it was dumb.
Yes, that's how I do it now .. I just write to port 9100 to print 
PS on a  network printer.
so if I have a daemon listening on port 9100 will windows recognise 
it as a IP printer??
basically the idea is to try and write a fax driver by acting as 
a printer port, and then sending the print to an internet fax.
Dockimbel
1-Sep-2009
[14645]
Ah, good idea...a virtual printer in REBOL! That would make a nice 
framework if you can expose a simple API.
Graham
1-Sep-2009
[14646x3]
I was just thinking that as soon as the driver receives a file, just 
popup a requester asking where to send it to ....
and pehaps a simple address book.
Cyphre's systray code could come in useful into making this a systray 
application
Graham
7-Sep-2009
[14649]
Any value in a function that swaps the values of two variables?

a: 1
b: 2
swap a b
b => 1, a => 2
BrianH
7-Sep-2009
[14650x2]
a: also b b: a
In R3:
>> help swap
USAGE:
        SWAP series1 series2

DESCRIPTION:
        Swaps elements of a series. (Modifies)
        SWAP is an action value.

ARGUMENTS:
        series1 (series! gob!)
        series2 (series! gob!)
>> swap a: "abc" skip a 2 a
== "cba"
Anton
7-Sep-2009
[14652]
Graham, I say yes. R3's SWAP could be extended to support words and 
enable your example to work.
Geomol
8-Sep-2009
[14653x2]
Or we can do this:
set [a b] reduce [b a]
But SWAP is probably more neat.
Graham
8-Sep-2009
[14655x4]
for english speaking countries, is it  a reasonable assumption that 
if you have a negative timezone you use mm/dd/yyyy but if you're 
not negative, you use dd/mm/yyyy ?
excluding western samoa .. but I don't have any users there AFAIK
and hawaii ...
oh well.... I guess I have to read the windows registry.
Geomol
8-Sep-2009
[14659]
http://en.wikipedia.org/wiki/Date_and_time_notation_by_country
Graham
8-Sep-2009
[14660]
Looks good to me ... I think I'll just keep my rule :)
Geomol
8-Sep-2009
[14661]
Graham, write a format-date function, that also take country code 
as input and produce the correct viewing format for a date. Then 
upload it to the library.
Graham
8-Sep-2009
[14662x4]
parse-out-date: func [trial [string!]
	/local day month year tmp white
] [
	; look for dd/mm/yy and dd/mm/yyyyy and dd/mmm/yyyy formats
	white: charset [#"/" #" " #"-" #"," ]
	either parse/all trial [
		copy day 1 2 digit white
		copy month [3 8 alpha | 2 digit]
		white
		copy year [4 digit | 2 digit]
		to end
	] [
            print [ day month year ]
            
		if parse/all month digits [
			; month is numeric
			if negative? now/zone [
				; swap the month and dd around
				tmp: month
				month: copy day
				day: copy tmp
			]
		]
		if error? set/any 'err try [
			return to-date rejoin [day "-" month "-" year]
		] [
			return none
		]
	] [
		; did't parse the date
		return none
	]
]
this is extracting the date from OCR'd text ...
also copes with 1 January, 2010
Hmm.. perhaps I need 

1 2 white copy year ....
Steeve
8-Sep-2009
[14666x4]
I think it's doing the same...

parse-out-date: func [
	trial [string!] /local day
][
	trial: parse trial "-,/"	

 if all [negative? now/zone day: take next trial][insert trial day]
	try [to-date form trial]
]
sorry, replace TRY by ATTEMPT
hum, didin't check if month is a number before swapping it...
Anyway, you see you don't need to make complex parse rules
more clean...

parse-out-date: func [
	trial [string!] /local day
][
	trial: parse trial "-,/"	
	all [
		negative? now/zone 
		integer? attempt [first to block! trial/2]
		;** swap day/month
		insert trial take next trial
	]
	attempt [to-date form trial]
]
Graham
8-Sep-2009
[14670x3]
nice if it works ... shall try it out :)
Ahh... can use spaces to separate date values .. forgot about that 
one.
don't even need the /local !
Steeve
8-Sep-2009
[14673]
and replace 
>> integer? attempt [first to block! trial/2]
by
>> attempt [to integer! trial/2]

Optimizations are a never ending task with Rebol ;-)
Graham
8-Sep-2009
[14674]
:)
Steeve
8-Sep-2009
[14675]
hum wrong !!!

don't do that optimization cause it returns TRUE if there is no trial/2 
value
Graham
8-Sep-2009
[14676]
don't you hate it when this happens??

>> do %synapse.r
** Syntax Error: Missing ] at end-of-script
** Near: (line 64507) [
Steeve
8-Sep-2009
[14677]
ahah, a pain in the ass