[ALLY] Passing variables from window to window Re:
[1/8] from: mdb:gci at: 1-Aug-2000 15:04
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
[2/8] from: greg_piney::mcgraw-hill::com at: 2-Aug-2000 10:37
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
[3/8] from: mike:yaunish:home at: 2-Aug-2000 21:53
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.
<<quoted lines omitted: 42>>
>system/view/vid/vid-feel/focus you-are
>view win-1
Mike Yaunish
[mike--yaunish--home--com]
[4/8] 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.
<<quoted lines omitted: 42>>
>system/view/vid/vid-feel/focus you-are
>view win-1
Mike Yaunish
[mike--yaunish--home--com]
[5/8] from: mdb:gci at: 3-Aug-2000 15:50
Thanks for the code, Greg. Now all is clear.
1. The code in check-admin-logon that set's the fields is incorrect.
I replaced it with
blk: to-block line
admin-usr: blk/1
admin-pass: blk/2
admin-ip: blk/3
admin-site: blk/4
admin-root: blk/5
2. the code 'main-window: func[] [view'
take out the view and all will be well
replace with main-window: func[] [
Does it really have to be a func? works just as well without it!
Also, expand the number of x's in t2 t3 and t4 otherwise only part of the
data will show.
Mike.
[6/8] from: mdb:gci at: 3-Aug-2000 16:04
Ooops, sorry, Greg, ignore Note 1, your code in check-admin-logon is
correct, my mistake.
Mike.
[7/8] from: mdb:gci at: 3-Aug-2000 16:12
I forget to mention another change
in the show-main func, take out the word text in the 4 assignments,
leaving:
t1/text: admin-usr
t2/text: admin-site
...
[8/8] from: greg_piney:mcgraw-hill at: 4-Aug-2000 9:28
Thanks Mike,
Now We're Cookin!
Greg Piney
S&P Web Engineering
[mdb--gci--net] on 08/03/2000 08:12:46 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:(7)
I forget to mention another change
in the show-main func, take out the word text in the 4 assignments,
leaving:
t1/text: admin-usr
t2/text: admin-site
...
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted