[REBOL] Re: percent! - new datatype request
On 08-Jun-02, Jason Cunliffe wrote: Why we're on the subject of new datatypes, what others are needed? Degrees (and minutes) perhaps? GPS Location = YES PLEASE!!! I'd second that. And I've been wondering why there isn't already a font! datatype. Cross-platform issues perhaps? -- Carl Read -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: Dealing with email subject lines greater than 65 characters...
Ed, How about: all [ mail/subject/66 = # remove at mail/subject 66 ] This way, the most you will be losing is a space if this behavior ever changes. Hope this helps! -Bo Lechnowsky Technical Consulting At 07:47 AM 6/8/02 -0700, you wrote: I've modified the REBOL MailSniff program to scan a mailbox and print the subject line. The problem is, for subject lines over 65 characters in length, REBOL appears to be inserting a space in the 66th position. Kinda like this: [REBOL] Dealing with email subject lines greater than 65 characte rs... I've fixed it by inserting this line into the code: Join (Copy/Part Mail/Subject 65) (Copy/Part At Mail/Subject 67 100) It solves the problem of the moment, but if this bug ever gets fixed, then I'm gonna loose the 66th character needlessly. Anyone got any better ideas on how to fix this? Just wondering... -- Sincerely, | Ed Dana| Courage is fear holding on a minute longer. Software Developer | -- General George S. Patton 1Ghz Athlon Amiga | === http://members.cox.net/edanaii/Home/Default.html === -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
Hi Jason, On Saturday, June 08, 2002, 10:10:10 PM, you wrote: JC Q1: How to catch the missing param so the script won't crash? Well, there's a way, but I don't recommend it as it can create more problems than it solves. somefunc: func [inp [number! unset!]] [print either value? 'inp [inp * 3.14159] [no value passed]] somefunc 4 12.56636 somefunc no value passed No I ask, what would you expect to get from: somefunc print done. Do you expect this: do [ [somefunc [print done. [] done. no value passed Maybe you better get what's going on if I write it as: somefunc print done. done. no value passed Regards, Gabriele. -- Gabriele Santilli [EMAIL PROTECTED] -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
Hi Romano and everyone somefunc: func [inp [any-type!]] [if value? 'inp [print [inp * 3.14159]]] ..damn that's clever.. thanks! It's a very interesting idiom the way it depends upon those two quite different but crucial parts any-type! 'inp Doing quite a lot of Vanilla programming, so it's sometimes cgi, some times internal functions. But the more flexible the args, the better - you don't have to remember, and it makes modular API development easier. Before REBOL, I was in love with Python, which has some great features for function args: 1. Keyword arguments with defaults 2. - Variable Length arguments Here's an example from Core Python Programming by Wesley Chun [good book] def tupleVarArgs(arg1, arg2='defaultB', *theRest) 'display regular args and non-keyword variable args' print 'formal arg1:', arg1 print 'formal arg2:', arg2 for eachXtrArg in theRest: print 'another arg:', eachXtrArg When a double ** is used it signifies variable Keyword arguments [Python Dictionary]. Python dicts are close to REBOL blocks depending how you use them, so I guess variable keyword args could be done with a combination of REBOL's refinements and some other magic. REBOL makes one work harder for the defaults. Perhaps you already know some more cool idioms ;-) thanks ./Jason -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
somefunc print done. done. no value passed ..yikes! Gabriele that's a very good point. I guess it's back to the drawing board to think about this some more. REBOL is so full of funny surprises. cheers ./Jason -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
hmm.. Q: How to tell if a word already exists or if is just an argument value being passed? somefunc: func [inp [any-type!]][if value? 'inp [print inp do stuff]] somefunc == none somefunc hello hello == do stuff somefunc print now 9-Jun-2002/8:32:33-4:00 == none When the input to somefunc is something like 'print' or any word in the rebol dictionary, we might assume that it is not a valid argument. Arguments we would be expecting would usually be a number, a name, a time, a block, etc.. So we could check for an existing known word, then perhaps it is not an argument. I don't know how to do that kind of lookup and could be slow.. It seems pretty limiting unless we are only passing in very simple strings and numbers, which in fact we often are in cgi work. But the obvious escape is just put all args in a block. somefunc exists? %test.xml ;;; empty argument, keep going.. somefunc [exists? %test.xml];;; evaluate block and use as argument somefunc [1 love now ];;; evaluate block and use as argument somefunc [name jason email [EMAIL PROTECTED] startdir %.] ;;; name, email are keywords arguments Which creates Python's **Kw variable keyword arguments very nicely. Except for a concise local way to embed default handling. if error? try [startdir] [startdir: %/home/jasonic] That works, but it's verbose next to Python. Any idiom suggestions to improve upon it within a function? Anyway feel like I just reinvented some primal rebol wheel here! Must be time to study scope and context more.. I suppose I need an 'arg-block tool I can use widely. Can anyone point me to examples using blocks as arguments, and techniques for parsing them? thanks ./Jason -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
Hi Jason, On Sunday, June 09, 2002, 7:11:36 AM, you wrote: JC REBOL makes one work harder for the defaults. Perhaps you already know some more JC cool idioms ;-) f: func [/opt optional-arg] [ optional-arg: any [optional-arg default value] print optional-arg ] Regards, Gabriele. -- Gabriele Santilli [EMAIL PROTECTED] -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
Hi Jason, On Sunday, June 09, 2002, 3:21:28 PM, you wrote: JC When the input to somefunc is something like 'print' or any word in the rebol JC dictionary, we might assume that it is not a valid argument. Arguments we would JC be expecting would usually be a number, a name, a time, a block, etc.. So we JC could check for an existing known word, then perhaps it is not an argument. I JC don't know how to do that kind of lookup and could be slow.. It seems pretty JC limiting unless we are only passing in very simple strings and numbers, which in JC fact we often are in cgi work. I don't think that what you want to do can be done, at least easily (even if you get the word 'PRINT, and decide to leave it alone, how do you tell REBOL to evaluate it AFTER your function?). REBOL does not support variable number of arguments because of its freeform syntax. If you like parens, then you can workaround the problem with variable args with them: (somefunc) print done no value passed done JC Which creates Python's **Kw variable keyword arguments very nicely. Yes, and you can even create your own dialect, which can make things even better. JC Except for a concise local way to embed default handling. See my earlier post. :) Of course it needs to be modified if you want to use it with varargs, get-or: func [word default] [either value? word [get word] [default]] somefunc: func [inp [any-type!]] [inp: get-or 'inp default value print inp] somefunc default value somefunc 1 1 or any variation, set-default: func [word default] [if not value? word [set word default] word] get-or2: func [word default] [any [if value? word [word] default]] JC Anyway feel like I just reinvented some primal rebol wheel here! Must be time to JC study scope and context more.. I suppose I need an 'arg-block tool I can use JC widely. I still think you'd better go with refinements, or just pass NONE to mean default; if your function is complex enough to make this a problem, then pass a single block and PARSE it (i.e. make your own dialect :). JC Can anyone point me to examples using blocks as arguments, and techniques for JC parsing them? LAYOUT? ;-) Regards, Gabriele. -- Gabriele Santilli [EMAIL PROTECTED] -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] mailing list oddness
weird ... my last 3 messages just got posted in reverse order of sending?? ./Jason -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: ftp read fails
* Anton [EMAIL PROTECTED] [020608 21:18]: Tim, I see not passive in the trace. Ftp usually fails first because active transfers are not supported by the server. Not sure if this works, but I think if you set passive mode in the ftp scheme: system/schemes/ftp/passive: true it might help. Hello Anton. Indeed it did. Thank you! :-) Just curious, I would be appreciated being pointed towards more detailed documentation on FTP. Is any available or are there archives. I'm currently using Core User's Guide 2.2.0... Thanks again. Regards -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com http://www.johnsons-web.com -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: Newbie: Trouble filling a form using http-post.r
Matthew, I don't know if you got Scott's approach working or not. He is using the more native approach rather than what is in %http-port.r For the rogers message, this html seems to allow a post with all | most of the extraneous html (and javascript) removed htmlheadtitleMr Rogers/title/head body bgcolor=linen form ACTION=http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new; method=POST INPUT TYPE=submit VALUE=send message INPUT type=hidden name=msisdn value=4165551212 input type=hidden name=num1 value=416 input type=hidden name=num2 value=5551212 input type=hidden name=text value=This is a test input type=hidden name=sizebox value=14 input type=hidden name=sm_title value=Rogers | Wireless input type=hidden name=sm_header_ok value=Thank You input type=hidden name=sm_header_fail value=Sorry input type=hidden name=sm_ym value=Your Message: input type=hidden name=sm_status_ok value=has been sent to: input type=hidden name=sm_status_fail value=cannot presently be sent to: input type=hidden name=sm_logo value=/att-logo.gif input type=hidden name=sm_pcs_link value=http://www.rogers.com/english/wireless/sendpcs.html; input type=hidden name=sm_pcs_text value=Send a PCS message input type=hidden name=sm_home_link value=http://www.rogers.com; input type=hidden name=sm_home_text value=home /form /body/html I did not look at their approach too long but I think they are passing some parameters to the cgi message that are then echoed back on the response. So the original posting message already knows the logo, and possible error or success messages. For example, you can change the success message to has, we think, really been sent to: I think this is clever ... allowing you to control some output on the response page and make your parsing work easier. And making you a bit more independent of changes to the processing program. If you want to use the functions in http-post.r then you can add a new one that allows a message to be sent For example, this send-message function works for me using the values show and it uses the http-post-form function from http-post.r send-message: func [ {Sends a message} area-code phone-number message ][ not-lt-gt: complement charset [# #] tag-rule: [ some not-lt-gt ] tmp: http-post-form http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new? reduce [ msisdn join area-code phone-number num1 area-code num2 phone-number oldtext text message SIZEBOX to-string length? message submit send message sm_ym Your Message: sm_status_ok has been sent to: sm_status_fail cannot presently be sent to: sm_logo /att-logo.gif sm_home_link http://www.rogers.com; sm_home_text home ] if none? find tmp/HTTP-Response 200 [return join Error: tmp/HTTP-Response] either parse tmp/content [ ; very ugly parsing attempt thru Your Message: br to {/bbr} thru br copy trans to {/font} to end ; changed parse value ][ return trans ][ print [Content was: tmp/content] return Error: Unable to parse HTML result page ] ] print send-message 416 5551212 This is a test but note the comment about the parsing... very ugly and very specific (and limited) to this example. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: mailing list oddness
Jason: weird ... my last 3 messages just got posted in reverse order of sending?? You're lucky! My last post hasn't appeared after 48 hours. Not on the archive either, Sunanda. -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: How to check function arguments ?
Hi Jason, Jason Cunliffe wrote: hmm.. Q: How to tell if a word already exists or if is just an argument value being passed? somefunc: func [inp [any-type!]][if value? 'inp [print inp do stuff]] somefunc == none somefunc hello hello == do stuff somefunc print now 9-Jun-2002/8:32:33-4:00 == none When the input to somefunc is something like 'print' or any word in the rebol dictionary, we might assume that it is not a valid argument. Well, trouble is, some-func never gets to see 'print, let's walk through it: somefunc print hello The interpreter finds 'somefunc, and sees that it's a function which would be happy to get an argument (in our example it would be equally happy without one, but that will only be checked _after_ nothing at all has been found). Now it stumbles on 'print ahh, that's word, now let's find the value of that word. The value happens to be a function, this function wants one argument, too, so it eats the string hello, does its work, and the return value of print (which is nothing at all, by the way), is given to somefunc as an argument. You could change somefunc like this somefunc: func['inp[any-type!]][if value? 'inp [print inp do stuff]] (Notice the 'tick in front of inp) Now you'll get: somefunc print hello print == hello - somefunc eats the _word_ 'print, without evaluating it, and hello is just returned, because there's nothing left to do with it. It is possible to do the print command now, but the problem is to get to prints argument. And now for something completely different. Your real problem is, that Rebol functions just try to get all their arguments, and there seems to be no way to tell a function where to stop searching, while most other languages have a means for that, be it semicolons, parents, or what not. Now Rebol has some Lisp ancestry, so you can always use those lispy parens: (somefunc) == none (somefunc) print hello hello .. But the obvious escape is just put all args in a block. Well, that's the most rebolious way, I think. I hope that shines a little light on the subject, Ingo -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.
[REBOL] Re: mailing list oddness
On 10-Jun-02, [EMAIL PROTECTED] wrote: Jason: weird ... my last 3 messages just got posted in reverse order of sending?? You're lucky! My last post hasn't appeared after 48 hours. Not on the archive either, Sunanda. If it does arrive, check its header to see if you can spot where it was held up. I'd thought this problem had gone away, but I guess it hasn't. A week or so ago I subscribed to the list with a second email address to see if posts would ever arrive at different times. They never did though, so I discontinued the experiment after a few days. (For obvious reasons:) But while I was doing this there weren't any complaints about slowness, so it may have just been chance. Won't be trying it again though... -- Carl Read -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with unsubscribe in the subject, without the quotes.