跳转到内容

Rebol 编程/set-net

来自维基教科书,自由的教科书
SET-NET settings 

网络设置。默认值之后的任何值都是可选的。单词可以用于服务器名称。

SET-NET 是一个函数值。

  • settings -- [email-addr default-server pop-server proxy-server proxy-port-id proxy-type esmtp-user esmtp-pass] (类型:块)

源代码

[编辑 | 编辑源代码]
set-net: func [
    {Network setup.  All values after default are optional.  Words OK for server names.} 
    settings [block!] {[email-addr default-server pop-server proxy-server proxy-port-id proxy-type esmtp-user esmtp-pass]} 
    /local actions item
][
    actions: [
        [system/user/email: item] 
        [system/schemes/default/host: item] 
        [system/schemes/pop/host: item] 
        [system/schemes/default/proxy/host: item] 
        [system/schemes/default/proxy/port-id: item] 
        [system/schemes/default/proxy/type: item] 
        [system/schemes/esmtp/user: item] 
        [system/schemes/esmtp/pass: item]
    ] 
    forall settings [
        if (item: first settings) = 'none [item: none] 
        if word? item [item: form item] 
        do first actions 
        if tail? actions: next actions [break]
    ] 
    if string? system/schemes/default/proxy/type [
        system/schemes/default/proxy/type: to-word system/schemes/default/proxy/type
    ] 
    if all [system/schemes/default/proxy/host none? system/schemes/default/proxy/type] [
        system/schemes/default/proxy/type: 'socks
    ] 
    if system/user/email [
        system/schemes/ftp/pass: system/user/email
    ] 
    all [
        none? get in system/schemes/default/proxy 'user 
        system/schemes/default/proxy/user: func [] [
            system/schemes/default/proxy/user: 
            ask "Enter proxy authentication username: "
        ]
    ] 
    all [
        none? get in system/schemes/default/proxy 'pass 
        system/schemes/default/proxy/pass: func [] [
            system/schemes/default/proxy/pass: 
            ask/hide "Enter proxy authentication password: "
        ]
    ] 
    if 'ask = pick head settings 7 [
        system/schemes/esmtp/user: func [] [
            system/schemes/esmtp/user: 
            ask "Enter ESMTP authentication username: "
        ] 
        system/schemes/esmtp/pass: func [] [
            system/schemes/esmtp/pass: 
            ask/hide "Enter ESMTP authentication password: "
        ]
    ] 
    exit
]

使用 set-user,它是一个带有表单的窗口。它对人类更友好。

华夏公益教科书