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

World: r3wp

[Core] Discuss core issues

Graham
8-Sep-2009
[14656x3]
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
Graham
8-Sep-2009
[14678x2]
And it's only 10k LOC near the end ...
What I need is a utility that will take a rebol script, and parse 
it out by function, attempting to intepret it until it reaches an 
error.
Steeve
8-Sep-2009
[14680]
ok i do it now
Graham
8-Sep-2009
[14681x3]
hehe
With forth, you could at least tell by the words in the dictionary 
where things had gone sour
I've spent the last hour trying to find this unmatched bracket
Henrik
8-Sep-2009
[14684]
We could use a static analyzer, like LLVM has:

http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/9
Anton
8-Sep-2009
[14685]
It took you an hour?! What technique were you using to find the missing/extra 
bracket?
Graham
8-Sep-2009
[14686x2]
binary chop
doesn't work well when your gui code is about 10k long
BrianH
8-Sep-2009
[14688]
I use bracket matching in Notepad++, and a little patience. Still 
slow, but not that slow.
Anton
8-Sep-2009
[14689]
Hmm. I find it hard to visualize how it could take so long.
Graham
8-Sep-2009
[14690x2]
shall I send you a picture of me tearing my hair out??
help the visualization process a little
Anton
8-Sep-2009
[14692x2]
That would be definitive.
:)
Henrik
8-Sep-2009
[14694]
this is where dividing code in smaller bits helps as well as an easy 
to debug startup procedure :-)
BrianH
8-Sep-2009
[14695]
%synapse.r is large by REBZOL standards.
Graham
8-Sep-2009
[14696]
I am using notepad++ at present to do the binary chop
BrianH
8-Sep-2009
[14697]
(sorry, I'm having a typo day)
Graham
8-Sep-2009
[14698x3]
Actually Henrik, it is composed of 1000s of nodes of small amounts 
of code .. which is reassembled to the final source.  But I don't 
have a way of syntax checking each node.
finally found it!
One of the reasons I don't like code being mixed with GUI display 
elements.
Anton
8-Sep-2009
[14701]
Is your code in strings? Because otherwise you can just use LOAD 
to syntax check your program..
Graham
8-Sep-2009
[14702x2]
I get a stack overflow when I run the source from the interpreter
so I can't use that method.
Anton
8-Sep-2009
[14704]
You mean, from the rebol console, you

	>> do %synapse.r


and you always get a stack overflow (not just when you have a bug 
like this)?
Graham
8-Sep-2009
[14705]
Yes... but it's caused by my redefining 'now