[ALLY] Passing variables from window to window Re:(4)
From: greg_piney:mcgraw-hill at: 3-Aug-2000 15:44
First, let me thank Mike and the others who sent possible solutions.
It seems that the only way to solve my dilema is to send out the whole program
as it sits now.
The only data you will need is to save the following line as %admpw.conf
myuser mypasswd ftp.mysite.com MySite /MyData
Then you can try my program:
REBOL [
Title: "Standard and Poor's FTP Administration"
File: %myfirst.r
Purpose: {A Learning Experience.}
]
ftpadm: ""
ckpw: ""
admin-usr: "fredd"
admin-pass: "freddpw"
admin-site: "freddsite"
admin-root: "freddroot"
admin-ip: "freddip"
enduser-ipnum: :system/network/host-address
user-function: "newuser"
ckok: false
check-admin-logon: func [] [
admin-list: read/lines %admpw.conf
foreach line admin-list [
if find line ftpadm [
set [admin-usr
admin-pass
admin-ip
admin-site
admin-root] parse line none
if ckpw = admin-pw[
admusr-ok: true ]
return
]
]
]
my-styles: stylize [[
txt12 text [font: [color: yellow shadow: none]]
txt16 txt12 [font: [size: 16]]
name txt12 [size: 100x24 font: [align: 'right]]
namv txt12 [size: none]
inp field [size: 200x24]
pwinp field [size: 100x24]
]
main-window: func[] [view
layout [
styles my-styles
subtitle "S&P FTP Admin"
across
label "Admin User: "
t1: text "xxxxxxxx" return
label "For Site: "
t2: text "x" return
label "Subdirectory: "
t3: text "x" return
label "For Server: "
t4: text "x" return
below
box 200x2 effect [gradient 1x0 100.100.100]
button "New User" 80x30 [view/new/offset newuser-window 200x50 ]
button "Suspend User" 80x30 [ view/new/offset suspend-window 250x100]
button "Change a Password" 80x30 [view/new passwd-window]
button "Delete a User" 80x30 [view/new/offset delete-window 300x150]
button "Quit" 80x30 #"^Q" [quit]
]
]
login-popup: func[] [view dialog: layout [
styles my-styles
subtitle "FTP Administrator Login"
across
name "Login:" admin-name: inp 75x24
button "OK!" [ftpadm: admin-name/text
ckpw: admin-pw/text
check-admin-logon
unview/only dialog
show-main
]
return
name "Password:" admin-pw: inp 75x24
button "Cancel" [quit ]
]
]
show-main: func[] [
print admin-usr admin-site admin-root admin-ip
new-main-window: make main-window [ do [
t1/text: text admin-usr
t2/text: text admin-site
t3/text: text admin-root
t4/text: text admin-ip
]
]
view/new new-main-window
]
newuser-window:
layout [
styles my-styles
size 450x400
subtitle "Create a New User"
txt16 bold "Create for site: "
indent 40
txt12 bold italic "Note: ALL fields are required." return
across
guide 4x120
name "UserName:" uname: inp 75x24 return
name "Group: " ugroup: inp 75x24
text "Default is UserName"
return
name "Comment: " ucomt: inp 200x24 return
name "Shell Type: " shell1: choice "/nosuchshell" data ["/nosuchshell"
/bin/ksh
"/bin/sh"]
text "(Use /nosuchshell for FTP Only users)"
return
name "Password:" upass1: pwinp 70x24 return
name "Again: " upass2: pwinp 70x24
at 0x330 indent 10
button "OK" [check-newu-fields
send-newu-stuff
unview]
button "Apply" [check-newu-fields]
button "Reset" [clear-all-newu]
button "Quit" [unview]
]
suspend-window:
layout [
styles my-styles
size 250x200
subtitle "Suspend a User"
txt16 bold "Suspend for site: "
indent 40
txt12 bold italic "Note: ALL fields are required." return
across
guide 4x120
name "UserName:" uname: inp 75x24 return
at 0x150 indent 10
button "OK" 30x30 [check-newu-fields
send-newu-stuff
unview]
button "Apply" 50x30 [check-newu-fields]
button "Reset" 50x30 [clear-all-newu]
button "Quit" 40x30 [unview]
]
clear-all-newu: func [][[unview]-newu]ds]return
foreach nu-field reduce [uname ugroup ucomt upass1 upass2] [clear
nu-field/text]
shell1/text: copy "Shell Type"
show uname show ugroup show ucomt show upass1
show upass2 show shell1
]
send-newu-stuff: func [] [
nudata: reduce [ rejoin [
enduser-ipnum":"user-function":"
uname/text":"ugroup/text":"ucomt/text":"
upass1/text":"upass2/text":"shell1/text ]
]
print nudata
]
check-newu-fields: func [][
check-uname
check-ugroup
check-ucomt
]
bad-chars: make bitset! "`~!@#$%^&*()_+ =[{]};:'/?><,"
check-uname: func [] [
sub-field: copy "Bad Username"
field-err: copy "UserName is Required!"
if 0 = length? uname/text [inform bad-field]
field-err: copy "UserName must be 4 to 8 characters in length"
if 4 > length? uname/text [inform bad-field
clear uname/text
show uname]
if 8 < length? uname/text [inform bad-field
clear uname/text
show uname]
field-err: copy "Username cannot contain special characters"
if find uname/text bad-chars [inform bad-field
clear uname/text
show uname]
]
check-ugroup: func [] [
sub-field: copy "Bad Group!"
field-err: copy "Group must be 4 to 8 characters in length"
if 4 > length? ugroup/text [inform bad-field
clear ugroup/text
show ugroup]
if 8 < length? ugroup/text [inform bad-field
clear ugroup/text
show ugroup]
field-err: copy "Group cannot contain special characters"
if find ugroup/text bad-chars [inform bad-field
clear ugroup/text
show ugroup]
]
check-ucomt: func [] [
sub-field: copy "No Comment!"
field-err: copy "Comment field should contain clients name"
if 0 = length? ucomt/text [inform bad-field
clear ucomt/text
show ucomt]
]
bad-field: func [] [return layout [
styles my-styles
subtitle :sub-field red
txt12 yellow 200x50 :field-err
indent 60 across
button 60x24 "OK" [hide-popup]
]
]
view login-popup
***** end of Program *****
What I am trying to do is take some of the data I read from the file
and insert it as text in the second (main) window.
So Far, No Luck.
Pardon my programming style (or lack of) as I really haven't
written a program in 15-20 years. I have done my Veg-O-Matic
routine on thousands of programs, but really haven't written one
from scratch in all those years.
TIA very much,
Greg Piney
S&P Web Engineering
[mike--yaunish--home--com] on 08/02/2000 11:53:18 PM
Please respond to [ally--rebol--com]
To: [ally--rebol--com]
cc: (bcc: Greg Piney/McGraw-Hill/US)
Subject [ALLY] Passing variables from window to window
: Re:(3)
At 10:37 AM 8/2/2000 -0400, you wrote:
Try this, it may be what you are looking for:
win-2: layout/offset [
across
text "letter 1 = " t1: text "x" return
text "letter 2 = " t2: text "x" return
text "letter 3 = " t3: text "x" return
text "letter 4 = " t4: text "x" return
] 30x100
win-1: layout/offset [ across text "Enter 4 letters:"
win-1-field: field "abcd" [
new-win-2: make win-2 [ do [ t1/text: win-1-field/text/1
t2/text: win-1-field/text/2
t3/text: win-1-field/text/3
t4/text: win-1-field/text/4
]
]
view/new new-win-2
]
] 30x30
view win-1
>Mike,
>
>I guess I am a poor explainer of my problem.
>
>A better explanation of my problem is:
>
>I get a field in win-1
>Based on the contents of that field, I read a config file
>and get the matching record.
>>From that record, I get 4 new variables. ;so far, so good
>
>I want to display the contents of those 4 new variables
>in win-2 as text or labels.
>
>You got me closer, but still no banana.
>
>TIA,
>
>Greg Piney
>S&P Web Engineering
>
>[mdb--gci--net] on 08/01/2000 07:04:23 PM
>
>Please respond to [ally--rebol--com]
>
> To: [ally--rebol--com]
>
> cc: (bcc: Greg Piney/McGraw-Hill/US)
>
> Subject [ALLY] Passing variables from window to window
> : Re:
>
>Greg,
>
>This code should do what you want, with the entered name showing up in
>label1 in win-2. Note however that i had to initialise label1 with all
>those x's, it won't work if you don't ??
>
>Mike.
>
>REBOL []
>
>win-1: layout [
> size 400x100
> across
> label "Enter your name?"
> you-are: field 75x20
> return
> button "OK!" [
>
> view/new win-2
> label1/text: you-are/text
> show label1
> ]
> ]
>win-2: layout [
> across
> label "Hello"
> label1: label "xxxxxxxxxxxxxxxxxxxx"
> return
> button "ok" [quit]
>]
>system/view/vid/vid-feel/focus you-are
>view win-1
>
Mike Yaunish
[mike--yaunish--home--com]