World: r3wp
[Core] Discuss core issues
older newer | first last |
james_nak 28-Aug-2009 [14617x2] | Yes, that's the way I do it. exactly. My problem is that I often add some field and have to go back and add it to all the functions. |
And so I was looking for a global way without the global (if you know what I mean) | |
Graham 28-Aug-2009 [14619x2] | well, you can create a context inside your functions |
nope .. that won't work. | |
james_nak 28-Aug-2009 [14621] | I looked at that and it creates an object. Would be ok then my laziness shows up and I don't want to have to use object paths. |
Graham 28-Aug-2009 [14622] | won't work anyway |
james_nak 28-Aug-2009 [14623] | Looking at "bind" it appears it should work. It even describes an example which is what I want to do: Binds meaning to words in a block. That is, it gives words a context in which they can be interpreted. This allows blocks to be exchanged between different contexts, which permits their words to be understood. For instance a function may want to treat words in a global database as being local to that function. |
Graham 28-Aug-2009 [14624x2] | unless you declare the variables as local , or use [ local-variables .. ] |
well, you still have to bind either using 'use or 'bind | |
james_nak 28-Aug-2009 [14626x2] | Graham, it's really about laziness on my part. |
BTW, sorry to hear about your site. | |
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 [14666] | 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] ] |
older newer | first last |