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

World: r3wp

[Core] Discuss core issues

Maxim
28-Aug-2009
[14606]
doh.... sorry... my mind mixed-up /part with /skip...
Sunanda
28-Aug-2009
[14607]
Thanks. What was confusing me is an inconsistency between R2 and 
R3 -- was not sure if R3 was the bug fix or the problem.
R2:
    select/part series "c" at series 4
    == "d"
R3: 
    >> select/part series "c" at series 4
     == none

*** Do we agree R3 is right in this case?
Steeve
28-Aug-2009
[14608x2]
yep
i use /part a lot, for example when i want to to find something in 
the first line of a text.
>> find/part text "something" any [find text newline tail text]
Sunanda
28-Aug-2009
[14610]
Looks like its a RAMBO report then, rather than curecode :)
james_nak
28-Aug-2009
[14611]
Bind. I often use blocks of field (column) names from a db table 
in functions. Trouble is when I add a field I have to go back and 
add that field name to every place where I am using my fields.  I 
was thinking of just creating a block at the beginning of my code 
and then using "bind" to create a local context. I just can't seem 
to make it local. It behaves as a global. Is there some trick?
Steeve
28-Aug-2009
[14612]
columns: [a b c d e f]
>> c1: use columns copy/deep reduce [columns]
== [a b c d e f]
>> c2: use columns copy/deep reduce [columns]
== [a b c d e f]
>> set c1 1
== 1
>> set c2 2
== 2
>> reduce c1
== [1 1 1 1 1 1]
>> reduce c2
== [2 2 2 2 2 2]
>> c1
== [a b c d e f]
>> c2
== [a b c d e f]

C1 and C2 are locals
james_nak
28-Aug-2009
[14613]
Thank you Steeve. Never used "use" before and Bindology 101 was like 
Bindology 596 for me. :-)  (no offense Ladislav ) Thanks. I also 
didn't know you could set all the members of a block like that.  
Appreciate your help.
Graham
28-Aug-2009
[14614x3]
James, in my functions that fetch sql data I just setup all the variables 
as local and do a set on the record

eg.

func: [ get-sql /local name dob address ][
	foreach record records copy db-port [ 
		set [ name dob address ] record
	]	
]
>> name
** Script Error: name has no value
** Near: name

>> get-sql: func [/local name dob ][ set [ name dob ] [ "Graham" 
now/date ]]
>> get-sql
== ["Graham" now/date]
>> name
** Script Error: name has no value
** Near: name
ooops .. need a reduce in there .. but you get the idea.
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
[14655]
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 ?