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

World: r3wp

[Core] Discuss core issues

Gregg
12-Apr-2006
[3940]
; used in SHIFT below
    dup: func [value len [integer!] /local type] [

        type: either series? value [value] [either char? value [""] [[]]]
		head insert/only/dup make type len value len
    ]

    ; used in SHIFT below
    make-blank-value: func [type] [
        any [
            attempt [make type 0]
            attempt [make type ""]
            attempt [make type []]
            attempt [make type none]
        ]
    ]


    ; The new PAD/JUSTIFY func might be used to implement this as well.
    shift: func [
        "Shift values in a series; length doesn't change."
        series [series!]
        /left   "Shift left (the default)"
        /right  "Shift right"

        /part range [number!] "Shift this many positions"  ; TBD series! 
        support?
        /with fill "Fill vacated slots with this value"
        /local pad
    ][
        range: any [range 1]
        if any [empty? series  0 = range] [return series]
        pad: dup any [fill  make-blank-value last series] range
        either right [

            head insert head clear skip tail series negate range pad
        ][
            append remove/part series range pad
        ]
    ]

    rotate: func [
        "Rotate values in a series."
        series [series!]
        /left   "Rotate left (the default)"
        /right  "Rotate right"

        /part range [number!] "Rotate this many positions"  ; TBD series! 
        support?
        /local offset pad
    ][
        range: any [all [range  range // length? series] 1]
        if any [empty? series  zero? range] [return series]
        either right [
            offset: does [skip tail series negate range]
            pad: copy offset
            head insert head clear offset pad
        ][
            pad: copy/part series range
            append remove/part series range pad
        ]
    ]
Anton
12-Apr-2006
[3941x3]
I am trying right now to write a file to an FTP server. What I would 
like to do is:
- open the port 
- try to write the file
- if that fails, create the parent directory if necessary
- try to write the file again
- close the port
The difficult part is keeping the port open.
... and I have my head deep in FTP handler... :)
Anton
16-Apr-2006
[3944x2]
Ah... figured out how to do that :) The solution is to disable close-on-fail 
in the handler, so that a failure in open does not close the ports. 
This allows the command port to be reused for other commands, such 
as make-dir.
Now to make it nice...
Graham
16-Apr-2006
[3946]
Anyone know how to write to the parallel port ?
PeterWood
16-Apr-2006
[3947]
I don't know if this will help: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlGBVQ
Graham
16-Apr-2006
[3948]
Gregg says write %//prn .. I'll give that a go.
JeffM
17-Apr-2006
[3949]
With image/rgb I can get all the RGB (24-bit) data. With /alpha I 
can get all the (8-bit) alpha data. Is there one to get RGBA (or 
ARGB) so the alpha data is interleaved with the RGB data (32-bit)?
Anton
17-Apr-2006
[3950]
Try to-binary logo.gif
JeffM
17-Apr-2006
[3951]
So simple -- like most things with REBOL. Don't know why I didn't 
try that. Thanks.
Anton
18-Apr-2006
[3952]
Not everything is simple - yet...
JeffM
18-Apr-2006
[3953]
Like bit shifting. I do appreciate Gregg's functions. However, when 
something that boils down to a single instruction in hardware requires 
6 lines of code and multiple function calls, something is wrong. 
;)
Henrik
18-Apr-2006
[3954]
indeed why bit shifting is needed, at least as built in mezzanine 
functions
Graham
18-Apr-2006
[3955x4]
Hmm.  Does 'send have a forward option?
ie. forward an existing email?
how to bind this correctly ?
>> b: { (blue)}
== " (blue)"
>> compose to-block  b
** Script Error: blue word has no context
** Where: halt-view
** Near: blue
Volker
18-Apr-2006
[3959]
Oh, 'to-block does still not bind? good to know. Use 'load .
Graham
18-Apr-2006
[3960x2]
Can't use 'load as other stuff in the block.
will cause errors.
Anton
18-Apr-2006
[3962]
Ye must bind to an example worde, as it is written in the olde texte.
Graham
18-Apr-2006
[3963x2]
need to get this working for my postscript dialect to be able to 
use rebol colours
instead of tuples
Gregg
18-Apr-2006
[3965]
Can you use REDUCE/ONLY?
Graham
18-Apr-2006
[3966x5]
let me try.
same problem
this is what I want to do
{ font (red) } => [ font 255.0.0 ]
It may be that I have to include the colour words in my parser.
Ingo
19-Apr-2006
[3971]
Do you mean like this?

>> b: "(blue)"
== "(blue)"
>> compose bind to block! b 'white
== [0.0.255]


You just have to give any word from the same context to bind ... 
so inthis case any word from the global context (i.e. system/words).

The only point to be aware of: If all this happens in a different 
context, and you happen to have a word named 'white in this context, 
then you have to use another word.
Graham
19-Apr-2006
[3972x2]
hey thanks Ingo!
Anyone written a fetchmail in Rebol?
Gabriele
19-Apr-2006
[3974x2]
does send have a forward option
 - maybe you are looking at RESEND
at = for
Graham
19-Apr-2006
[3976]
ahh.. a new function :)
Henrik
19-Apr-2006
[3977]
this is probably outside of core and more at the OS level, but it 
would be nice to somehow check if a script is already running via 
LAUNCH, to make sure it's only launched one instance at a time. Is 
this possible?
Anton
19-Apr-2006
[3978]
maybe try to launch a dummy script and catch the error.
Henrik
19-Apr-2006
[3979]
another thing could be to have a masterscript running and let the 
other scripts report to it via LNS, but that's not very elegant...
Gregg
19-Apr-2006
[3980]
You could use a semaphore of some kind (port/file).
Anton
19-Apr-2006
[3981]
- the original script will be able to launch the dummy script and 
thus no error

- the launched script will not be able to launch the dummy script 
and thus an error
Henrik
19-Apr-2006
[3982]
a script can't launch itself?
Anton
19-Apr-2006
[3983]
So you won't have to fiddle with files or ports and worry about deadlock 
conditions etc.
Henrik
19-Apr-2006
[3984]
or "cascade launch" scripts
Anton
19-Apr-2006
[3985x2]
A launched script cannot launch further scripts.
So:
	do original-script
		-> launch sub-script
			-> launch ---> failure
Henrik
19-Apr-2006
[3987]
what if I have a menu system which launches subscripts A, B, C, D 
and E. I launch A and C. Then the menu crashes or is accidentally 
quit. I launch the menu system again, but then it should know the 
state of the running programs.
Gregg
19-Apr-2006
[3988]
Sounds like you want an IPC mechanism of some kind.
Henrik
19-Apr-2006
[3989]
seems it would be necessary...