Solutions 2: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
(Created page with "SOLUTIONS Tutorial 2 These solutions are meant to provide a guideline as you work through the tutorial. However, there are often several ways to approach a programming chall...")
 
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
SOLUTIONS  
SOLUTIONS for the Intermediate Tutorial (Tutorial 2).
Tutorial 2


These solutions are meant to provide a guideline as you work through the tutorial. However, there are often several ways to approach a programming challenge and solve each challenge. You may find that your solutions are different.   
These solutions are meant to provide a guideline as you work through the tutorial. However, there are often several ways to approach a programming challenge and solve each challenge. You may find that your solutions are different.   
Line 7: Line 6:
The following code demonstrates this as the user chooses what kind of order will be processed:
The following code demonstrates this as the user chooses what kind of order will be processed:


00140  ! radio buttons
00140  ! radio buttons<br>
00150  let X$="Overnight"
00150  let X$="Overnight"<br>
00160  let Y$="Regular"
00160  let Y$="Regular"<br>
00170  print fields "12,5, c 30": "Shipping preference: "
00170  print fields "12,5, c 30": "Shipping preference: "<br>
00180  rinput fields "13,5,radio 9,2,8;14,5,radio 7,2,9":X$,Y$
00180  rinput fields "13,5,radio 9,2,8;14,5,radio 7,2,9":X$,Y$<br>
00190  if FKEY=8, then print fields "15,5,c 30": "It will be there tomorrow!"
00190  if FKEY=8, then print fields "15,5,c 30": "It will be there tomorrow!"<br>
00200  if FKEY=9, then print fields "16,5,c 50": “It will be there with 3 to 7 business days!"
00200  if FKEY=9, then print fields "16,5,c 50": “It will be there with 3 to 7 business days!"<br>
00220    if x$(1:1)="^" then shipping$="O"
00220    if x$(1:1)="^" then shipping$="O"<br>
00230    if y$(1:1)="^" then shipping$="R"
00230    if y$(1:1)="^" then shipping$="R"<br>


===Exercise 1.2===
===Exercise 1.2===
The following code augments our sample program with the ability to select which items to ship:
The following code augments our sample program with the ability to select which items to ship:


00002    dim boxnameform$(3)*20,boxname$(3)*20,box$(3)*20
00002    dim boxnameform$(3)*20,boxname$(3)*20,box$(3)*20<br>
00004    data "22,15,c 10","23,15,c 10","24,15,c 10"
00004    data "22,15,c 10","23,15,c 10","24,15,c 10"<br>
00005    data "Item 1","Item 2","Item 3"
00005    data "Item 1","Item 2","Item 3"<br>
00006    read mat boxnameform$
00006    read mat boxnameform$<br>
00007    read mat boxname$
00007    read mat boxname$<br>
00008    print fields "20,5,c 35": "Please select items to order:"
00008    print fields "20,5,c 35": "Please select items to order:"<br>
00009    print fields mat boxnameform$:mat boxname$
00009    print fields mat boxnameform$:mat boxname$<br>
00010  !
00010  !<br>
00011    let X$="one" : let Y$="two"
00011    let X$="one" : let Y$="two"<br>
00012    print fields "24,30,C 20": "Press Esc to quit"
00012    print fields "24,30,C 20": "Press Esc to quit"<br>
00013      do
00013      do<br>
00014    input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": box$(1),box$(2),box$(3)
00014    input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": box$(1),box$(2),box$(3)<br>
00015        print fields "24,1,N 2": Fkey
00015        print fields "24,1,N 2": Fkey<br>
00016    loop While Fkey~=99
00016    loop While Fkey~=99<br>


In this example, the DO LOOP structure allows the user to choose more than one checkbox, while the Escape key allows the user to exit the program when complete.  
In this example, the DO LOOP structure allows the user to choose more than one checkbox, while the Escape key allows the user to exit the program when complete.  


===Exercise 1.3 A===
===Exercise 1.3 A===
00260    dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20
00260    dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20<br>
00270    data "22,15,c 10","23,15,c 10","24,15,c 10"
00270    data "22,15,c 10","23,15,c 10","24,15,c 10"<br>
00280    data "Item 1","Item 2","Item 3"
00280    data "Item 1","Item 2","Item 3"<br>
00290    read Mat Boxnameform$
00290    read Mat Boxnameform$<br>
00300    read Mat Boxname$
00300    read Mat Boxname$<br>
00310    print fields "20,5,c 35": "Please select items to order:"
00310    print fields "20,5,c 35": "Please select items to order:"<br>
00320    print fields Mat Boxnameform$: Mat Boxname$
00320    print fields Mat Boxnameform$: Mat Boxname$<br>
00340    print fields "23,30,CC 8,,b99" : "Done"
00340    print fields "23,30,CC 8,,b99" : "Done"<br>
00350    do
00350    do<br>
00360        input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)
00360        input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)<br>
00370        print fields "24,1,N 2": Fkey
00370        print fields "24,1,N 2": Fkey<br>
00380    loop While Fkey~=99
00380    loop While Fkey~=99<br>
00390    For I=1 to UDIM(box$)
00390    For I=1 to UDIM(box$)<br>
00400        if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0
00400        if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0<br>
00410    next I
00410    next I<br>


===Exercise 1.3B===
===Exercise 1.3B===


00001  ! .! This is a sample for use of radio buttons, checkboxes, and buttons.  
00001  ! .! This is a sample for use of radio buttons, checkboxes, and buttons.<br>
00010  ! .! #autonumber# 10,10
00010  ! .! #autonumber# 10,10<br>
00020    print Newpage
00020    print Newpage<br>
00030    dim Clientform$(6)*20, Clientwords$(6)*20, Answerform$(6)*30, Answers$(6)*30,ordered(3)
00030    dim Clientform$(6)*20, Clientwords$(6)*20, Answerform$(6)*30, Answers$(6)*30,ordered(3)<br>
00040    data "5,3,C 20","6,3,C 20","7,3,C 20","8,3,C 10","8,36,C 10","9,3,C 10"
00040    data "5,3,C 20","6,3,C 20","7,3,C 20","8,3,C 10","8,36,C 10","9,3,C 10"<br>
00050    read Mat Clientform$
00050    read Mat Clientform$<br>
00060    data "First Name: ","Last Name: ","Address: ","City: ","State: ","Zip Code: "
00060    data "First Name: ","Last Name: ","Address: ","City: ","State: ","Zip Code: "<br>
00070    read Mat Clientwords$
00070    read Mat Clientwords$<br>
00080    data "5,20,C 30","6,20,C 30","7,20,C 30","8,20,C 15","8,43,C 2","9,20,C 7"
00080    data "5,20,C 30","6,20,C 30","7,20,C 30","8,20,C 15","8,43,C 2","9,20,C 7"<br>
00090    read Mat Answerform$
00090    read Mat Answerform$<br>
00100  ! Finame$, Lname$,Address$,City$,State$,Zipcode$
00100  ! Finame$, Lname$,Address$,City$,State$,Zipcode$<br>
00110    print fields Mat Clientform$: Mat Clientwords$
00110    print fields Mat Clientform$: Mat Clientwords$<br>
00120  !
00120  !<br>
00130    input fields Mat Answerform$: Mat Answers$
00130    input fields Mat Answerform$: Mat Answers$<br>
00140  !
00140  !<br>
00150  ! Radio Buttons
00150  ! Radio Buttons<br>
00160    let X$="^Overnight"
00160    let X$="^Overnight"<br>
00170    let Y$="Regular"
00170    let Y$="Regular"<br>
00180    print fields "12,5, c 30": "Shipping preference: "
00180    print fields "12,5, c 30": "Shipping preference: "<br>
00190    rinput fields "13,5,radio 10,2,8;14,5,radio 7,2,9": X$,Y$
00190    rinput fields "13,5,radio 10,2,8;14,5,radio 7,2,9": X$,Y$<br>
00200    if Fkey=8, then print fields "15,5,c 20": "Ok then!"
00200    if Fkey=8, then print fields "15,5,c 20": "Ok then!"<br>
00210    if Fkey=9, then print fields "16,5,c 20": "We'll do it!"
00210    if Fkey=9, then print fields "16,5,c 20": "We'll do it!"<br>
00220    if x$(1:1)="^" then shipping$="O"
00220    if x$(1:1)="^" then shipping$="O"<br>
00230    if y$(1:1)="^" then shipping$="R"
00230    if y$(1:1)="^" then shipping$="R"<br>
00240  !
00240  !<br>
00250  ! Check Boxes
00250  ! Check Boxes<br>
00260    dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20
00260    dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20<br>
00270    data "22,15,c 10","23,15,c 10","24,15,c 10"
00270    data "22,15,c 10","23,15,c 10","24,15,c 10"<br>
00280    data "Item 1","Item 2","Item 3"
00280    data "Item 1","Item 2","Item 3"<br>
00290    read Mat Boxnameform$
00290    read Mat Boxnameform$<br>
00300    read Mat Boxname$
00300    read Mat Boxname$<br>
00310    print fields "20,5,c 35": "Please select items to order:"
00310    print fields "20,5,c 35": "Please select items to order:"<br>
00320    print fields Mat Boxnameform$: Mat Boxname$
00320    print fields Mat Boxnameform$: Mat Boxname$<br>
00340    print fields "23,30,CC 8,,b99" : "Done"
00340    print fields "23,30,CC 8,,b99" : "Done"<br>
00350    do
00350    do<br>
00360        input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)
00360        input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)<br>
00370        print fields "24,1,N 2": Fkey
00370        print fields "24,1,N 2": Fkey<br>
00380    loop While Fkey~=99
00380    loop While Fkey~=99<br>
00390    For I=1 to UDIM(box$)
00390    For I=1 to UDIM(box$)<br>
00400        if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0
00400        if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0<br>
00410    next I
00410    next I<br>
00420  !
00420  !<br>
00430  ! Open File And Record Answers
00430  ! Open File And Record Answers<br>
00440  Open #1: "name=orders.int, recl=118,USE,kfname=lastfirst.int,kps=31/1,kln=30/30", internal, OUTIN, keyed
00440  Open #1: "name=orders.int, recl=118,USE,kfname=lastfirst.int,kps=31/1,kln=30/30", internal, OUTIN, keyed<br>
00450  write #1, using recform:mat answers$,shipping$,mat ordered
00450  write #1, using recform:mat answers$,shipping$,mat ordered<br>
00460  recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00460  recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1<br>
00470  close #1:
00470  close #1:<br>
00480  !
00480  !<br>




===1.4 SAMPLIST.BR===
===1.4 SAMPLIST.BR===
00001  !  Print "this is a sample list then a grid"
00001  !  Print "this is a sample list then a grid"<br>
00010  ! .! #autonumber# 10,10
00010  ! .! #autonumber# 10,10<br>
00020  print newpage
00020  print newpage<br>
00030  dim  HEADINGS$(10), WIDTHS(10), FORMS$(10), Answers$(6)*30,ordered(3), head, f$*100
00030  dim  HEADINGS$(10), WIDTHS(10), FORMS$(10), Answers$(6)*30,ordered(3), head, f$*100<br>
00040  data "First Name”,”Last Name”,”Address”,”City”,”State”,”Zip Code”,”Shipping”,”Item 1”,”Item 2”,”Item 3"
00040  data "First Name”,”Last Name”,”Address”,”City”,”State”,”Zip Code”,”Shipping”,”Item 1”,”Item 2”,”Item 3"<br>
00045 read mat headings$
00045 read mat headings$<br>
00050  data 10,10,10,10,4,9,3,3,3,3
00050  data 10,10,10,10,4,9,3,3,3,3<br>
00060  read mat widths
00060  read mat widths<br>
00070  f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"
00070  f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"<br>
00080  str2mat(f$,mat forms$,",")
00080  str2mat(f$,mat forms$,",")<br>
00090  !
00090  !<br>
00100  dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)
00100  dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)<br>
00110  !
00110  !<br>
00120      open #1:"name=orders.int, recl=118,USE", internal, outin
00120      open #1:"name=orders.int, recl=118,USE", internal, outin<br>
00130  !
00130  !<br>
00140      mat FirstName$(0)
00140      mat FirstName$(0)<br>
00150      mat LastName$(0)
00150      mat LastName$(0)<br>
00160      mat Address$(0)
00160      mat Address$(0)<br>
00170      mat City$(0)
00170      mat City$(0)<br>
00180      mat state$(0)
00180      mat state$(0)<br>
00190      mat zipcodes$(0)
00190      mat zipcodes$(0)<br>
00200      mat shipmethod$(0)
00200      mat shipmethod$(0)<br>
00210      mat item1(0)
00210      mat item1(0)<br>
00220      mat item2(0)
00220      mat item2(0)<br>
00230      mat item3(0)
00230      mat item3(0)<br>
00240  !
00240  !<br>
00250      ReadTheNextOne:  ! ok
00250      ReadTheNextOne:  ! ok<br>
00260        read #1, using recform:mat answers$,shipping$,mat ordered eof DoneReading
00260        read #1, using recform:mat answers$,shipping$,mat ordered eof DoneReading<br>
00270        recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00270        recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1<br>
00280  !
00280  !<br>
00290        let NewSize=udim(FirstName$)+1
00290        let NewSize=udim(FirstName$)+1<br>
00300  !
00300  !<br>
00310        mat FirstName$(NewSize)
00310        mat FirstName$(NewSize)<br>
00320        mat LastName$(NewSize)
00320        mat LastName$(NewSize)<br>
00330        mat Address$(NewSize)
00330        mat Address$(NewSize)<br>
00340        mat City$(NewSize)
00340        mat City$(NewSize)<br>
00350        mat state$(newsize)
00350        mat state$(newsize)<br>
00360        mat zipcodes$(NewSize)
00360        mat zipcodes$(NewSize)<br>
00370        mat shipmethod$(NewSize)
00370        mat shipmethod$(NewSize)<br>
00380        mat item1(NewSize)
00380        mat item1(NewSize)<br>
00390        mat item2(NewSize)
00390        mat item2(NewSize)<br>
00400        mat item3(NewSize)
00400        mat item3(NewSize)<br>
00410  !
00410  !<br>
00420        FirstName$(NewSize)=Answers$(1)
00420        FirstName$(NewSize)=Answers$(1)<br>
00430        LastName$(NewSize)=Answers$(2)
00430        LastName$(NewSize)=Answers$(2)<br>
00440        Address$(NewSize)=Answers$(3)
00440        Address$(NewSize)=Answers$(3)<br>
00450        City$(NewSize)=Answers$(4)
00450        City$(NewSize)=Answers$(4)<br>
00460        state$(newsize)=answers$(5)
00460        state$(newsize)=answers$(5)<br>
00470        zipcodes$(NewSize)=Answers$(6)
00470        zipcodes$(NewSize)=Answers$(6)<br>
00480        shipmethod$(NewSize)=shipping$
00480        shipmethod$(NewSize)=shipping$<br>
00490        item1(NewSize)=ordered(1)
00490        item1(NewSize)=ordered(1)<br>
00500        item2(NewSize)=ordered(2)
00500        item2(NewSize)=ordered(2)<br>
00510        item3(NewSize)=ordered(3)
00510        item3(NewSize)=ordered(3)<br>
00520  !
00520  !<br>
00530      goto ReadTheNextOne
00530      goto ReadTheNextOne<br>
00540  !
00540  !<br>
00550      DoneReading: ! We're done reading, go to the next part, print them on the list
00550      DoneReading: ! We're done reading, go to the next part, print them on the list<br>
00560  !
00560  !<br>
00570  !
00570  !<br>
00580  print fields "2,2,list 10/80,headers": (MAT HEADINGS$,MAT WIDTHS,MAT FORMS$)
00580  print fields "2,2,list 10/80,headers": (MAT HEADINGS$,MAT WIDTHS,MAT FORMS$)<br>
00590  print fields "2,2,list 10/80,=r": (mat FirstName$, mat LastName$,mat Address$,mat City$,mat state$,mat zipcodes$,mat shipmethod$,mat item1,mat item2,mat item3)
00590  print fields "2,2,list 10/80,=r": (mat FirstName$, mat LastName$,mat Address$,mat City$,mat state$,mat zipcodes$,mat shipmethod$,mat item1,mat item2,mat item3)<br>
00600  !
00600  !<br>
00610    print fields "23,30,CC 8,,b99" : "Done"
00610    print fields "23,30,CC 8,,b99" : "Done"<br>
00620    do
00620    do<br>
00630    input fields "2,2,list 10/80,rowsub,selone": selection
00630    input fields "2,2,list 10/80,rowsub,selone": selection<br>
00640    loop while FKEY~=99
00640    loop while FKEY~=99<br>
00650    print selection
00650    print selection<br>
00660  !
00660  !<br>
00670    close #1:
00670    close #1:<br>
00680  !
00680  !<br>




===1.5 GRID1===
===1.5 GRID1===
GRID1, part one:
GRID1, part one:
00001  !  Print "this is a sample list then a grid"
 
00002  ! This Is A Sample Sort And Print File.
00001  !  Print "this is a sample list then a grid"<br>
00010  ! .! #autonumber# 10,10
00002  ! This Is A Sample Sort And Print File.<br>
00020    print Newpage
00010  ! .! #autonumber# 10,10<br>
00030    dim Headings$(10), Widths(10), Forms$(10), Answers$(6)*30,Ordered(3), Head
00020    print Newpage<br>
00040    data "First Name","Last Name","Address","City","State","Zip Code","Shipping","Item 1","Item 2","Item 3"
00030    dim Headings$(10), Widths(10), Forms$(10), Answers$(6)*30,Ordered(3), Head<br>
00050    read Mat Headings$
00040    data "First Name","Last Name","Address","City","State","Zip Code","Shipping","Item 1","Item 2","Item 3"<br>
00060    data 10,10,10,10,4,9,3,3,3,3
00050    read Mat Headings$<br>
00070    read Mat Widths
00060    data 10,10,10,10,4,9,3,3,3,3<br>
00080    data "cc 30","cc 30","cc 30","cc 15","cc 2","cc 7","cc 1","n 1","n 1","n 1"
00070    read Mat Widths<br>
00090    read Mat Forms$
00080    data "cc 30","cc 30","cc 30","cc 15","cc 2","cc 7","cc 1","n 1","n 1","n 1"<br>
00100  !
00090    read Mat Forms$<br>
00110    dim Firstname$(1)*30,Lastname$(1)*30,Address$(1)*30,City$(1)*15,State$(1)*2,Zipcodes$(1)*7,Shipmethod$(1)*1,Item1(1),Item2(1),Item3(1),Recordnum(1)
00100  !<br>
00120  !
00110    dim Firstname$(1)*30,Lastname$(1)*30,Address$(1)*30,City$(1)*15,State$(1)*2,Zipcodes$(1)*7,Shipmethod$(1)*1,Item1(1),Item2(1),Item3(1),Recordnum(1)<br>
00130    open #1: "name=orders.INT", internal, outin, relative
00120  !<br>
00140  !
00130    open #1: "name=orders.INT", internal, outin, relative<br>
00150    mat Firstname$(0)
00140  !<br>
00160    mat Lastname$(0)
00150    mat Firstname$(0)<br>
00170    mat Address$(0)
00160    mat Lastname$(0)<br>
00180    mat City$(0)
00170    mat Address$(0)<br>
00190    mat State$(0)
00180    mat City$(0)<br>
00200    mat Zipcodes$(0)
00190    mat State$(0)<br>
00210    mat Shipmethod$(0)
00200    mat Zipcodes$(0)<br>
00220    mat Item1(0)
00210    mat Shipmethod$(0)<br>
00230    mat Item2(0)
00220    mat Item1(0)<br>
00240    mat Item3(0)
00230    mat Item2(0)<br>
00250    mat Recordnum(0)
00240    mat Item3(0)<br>
00260  !
00250    mat Recordnum(0)<br>
00270  !
00260  !<br>
00280  READTHENEXTONE: ! Ok
00270  !<br>
00290    read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING
00280  READTHENEXTONE: ! Ok<br>
00300  RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1
00290    read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING<br>
00310  !
00300  RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1<br>
00320    let Newsize=Udim(Firstname$)+1
00310  !<br>
00330  !
00320    let Newsize=Udim(Firstname$)+1<br>
00340    mat Firstname$(Newsize)
00330  !<br>
00350    mat Lastname$(Newsize)
00340    mat Firstname$(Newsize)<br>
00360    mat Address$(Newsize)
00350    mat Lastname$(Newsize)<br>
00370    mat City$(Newsize)
00360    mat Address$(Newsize)<br>
00380    mat State$(Newsize)
00370    mat City$(Newsize)<br>
00390    mat Zipcodes$(Newsize)
00380    mat State$(Newsize)<br>
00400    mat Shipmethod$(Newsize)
00390    mat Zipcodes$(Newsize)<br>
00410    mat Item1(Newsize)
00400    mat Shipmethod$(Newsize)<br>
00420    mat Item2(Newsize)
00410    mat Item1(Newsize)<br>
00430    mat Item3(Newsize)
00420    mat Item2(Newsize)<br>
00440    mat Recordnum(Newsize)
00430    mat Item3(Newsize)<br>
00450  !
00440    mat Recordnum(Newsize)<br>
00460    let Firstname$(Newsize)=Answers$(1)
00450  !<br>
00470    let Lastname$(Newsize)=Answers$(2)
00460    let Firstname$(Newsize)=Answers$(1)<br>
00480    let Address$(Newsize)=Answers$(3)
00470    let Lastname$(Newsize)=Answers$(2)<br>
00490    let City$(Newsize)=Answers$(4)
00480    let Address$(Newsize)=Answers$(3)<br>
00500    let State$(Newsize)=Answers$(5)
00490    let City$(Newsize)=Answers$(4)<br>
00510    let Zipcodes$(Newsize)=Answers$(6)
00500    let State$(Newsize)=Answers$(5)<br>
00520    let Shipmethod$(Newsize)=Shipping$
00510    let Zipcodes$(Newsize)=Answers$(6)<br>
00530    let Item1(Newsize)=Ordered(1)
00520    let Shipmethod$(Newsize)=Shipping$<br>
00540    let Item2(Newsize)=Ordered(2)
00530    let Item1(Newsize)=Ordered(1)<br>
00550    let Item3(Newsize)=Ordered(3)
00540    let Item2(Newsize)=Ordered(2)<br>
00560    let Recordnum(Newsize)=Rec(1)
00550    let Item3(Newsize)=Ordered(3)<br>
00570  !
00560    let Recordnum(Newsize)=Rec(1)<br>
00580    goto READTHENEXTONE
00570  !<br>
00590  !
00580    goto READTHENEXTONE<br>
00600  DONEREADING: ! We're done reading, go to the nexst part, print them on the list
00590  !<br>
00610  !
00600  DONEREADING: ! We're done reading, go to the nexst part, print them on the list<br>
00620    print fields "2,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)
00610  !<br>
00630    print fields "2,2,grid 10/80,=r": (Mat Firstname$, Mat Lastname$,Mat Address$,Mat City$,Mat State$,Mat Zipcodes$,Mat Shipmethod$,Mat Item1,Mat Item2,Mat Item3)
00620    print fields "2,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)<br>
00640  !
00630    print fields "2,2,grid 10/80,=r": (Mat Firstname$, Mat Lastname$,Mat Address$,Mat City$,Mat State$,Mat Zipcodes$,Mat Shipmethod$,Mat Item1,Mat Item2,Mat Item3)<br>
00650    print fields "23,30,CC 8,,b99" : "Done" ! Done Button
00640  !<br>
00660  !
00650    print fields "23,30,CC 8,,b99" : "Done" ! Done Button<br>
00670    do
00660  !<br>
00680  ! .  ! writing changed selections to the file
00670    do<br>
00690        input fields "2,2,GRID 10/80,ROWCNT,CHG": Rows ! # Of Changed Rows
00680  ! .  ! writing changed selections to the file<br>
00700        mat Subscr(Rows) ! Redimension
00690        input fields "2,2,GRID 10/80,ROWCNT,CHG": Rows ! # Of Changed Rows<br>
00710        input fields "2,2,GRID 10/80,ROWSUB,CHG,NOWAIT": Mat Subscr ! Read Subscripts
00700        mat Subscr(Rows) ! Redimension<br>
00720  !
00710        input fields "2,2,GRID 10/80,ROWSUB,CHG,NOWAIT": Mat Subscr ! Read Subscripts<br>
00730  ! .  ! redimension
00720  !<br>
00740        mat Firstname$(Rows)
00730  ! .  ! redimension<br>
00750        mat Lastname$(Rows)
00740        mat Firstname$(Rows)<br>
00760        mat Address$(Rows)
00750        mat Lastname$(Rows)<br>
00770        mat City$(Rows)
00760        mat Address$(Rows)<br>
00780        mat State$(Rows)
00770        mat City$(Rows)<br>
00790        mat Zipcodes$(Rows)
00780        mat State$(Rows)<br>
00800        mat Shipmethod$(Rows)
00790        mat Zipcodes$(Rows)<br>
00810        mat Item1(Rows)
00800        mat Shipmethod$(Rows)<br>
00820        mat Item2(Rows)
00810        mat Item1(Rows)<br>
00830        mat Item3(Rows)
00820        mat Item2(Rows)<br>
00840  !
00830        mat Item3(Rows)<br>
00850        input fields "2,2,GRID 10/80,ROW,CHG,NOWAIT": (Mat Firstname$, Mat Lastname$, Mat Address$, Mat City$, Mat State$, Mat Zipcodes$, Mat Shipmethod$, Mat Item1, Mat Item2, Mat Item3) ! Read Changed Rows
00840  !<br>
00860  !
00850        input fields "2,2,GRID 10/80,ROW,CHG,NOWAIT": (Mat Firstname$, Mat Lastname$, Mat Address$, Mat City$, Mat State$, Mat Zipcodes$, Mat Shipmethod$, Mat Item1, Mat Item2, Mat Item3) ! Read Changed Rows<br>
00870  ! Write To File
00860  !<br>
00880        for Index=1 to Udim(Mat Firstname$)
00870  ! Write To File<br>
00890          let Thesubscriptnumber=Subscr(Index)
00880        for Index=1 to Udim(Mat Firstname$)<br>
00900          let Therecordnumber=Recordnum(Thesubscriptnumber)
00890          let Thesubscriptnumber=Subscr(Index)<br>
00910          rewrite #1, using RECFORM, rec=Therecordnumber: Firstname$(Index), Lastname$(Index), Address$(Index), City$(Index), State$(Index), Zipcodes$(Index), Shipmethod$(Index), Item1(Index), Item2(Index), Item3(Index)
00900          let Therecordnumber=Recordnum(Thesubscriptnumber)<br>
00920        next Index
00910          rewrite #1, using RECFORM, rec=Therecordnumber: Firstname$(Index), Lastname$(Index), Address$(Index), City$(Index), State$(Index), Zipcodes$(Index), Shipmethod$(Index), Item1(Index), Item2(Index), Item3(Index)<br>
00930    loop Until Fkey=99
00920        next Index<br>
00940  !
00930    loop Until Fkey=99<br>
00950    dim Newfirstname$(1)*30, Newlastname$(1)*30, Newaddress$(1)*30, Newcity$(1)*15, Newstate$(1)*2, Newzipcodes$(1)*7, Newshipmethod$(1)*1, Newitem1(1), Newitem2(1), Newitem3(1)
00940  !<br>
00960  !
00950    dim Newfirstname$(1)*30, Newlastname$(1)*30, Newaddress$(1)*30, Newcity$(1)*15, Newstate$(1)*2, Newzipcodes$(1)*7, Newshipmethod$(1)*1, Newitem1(1), Newitem2(1), Newitem3(1)<br>
00970    print Newpage
00960  !<br>
00980    let Newfirstname$(1)=" "
00970    print Newpage<br>
00990    let Newlastname$(1)=" "
00980    let Newfirstname$(1)=" "<br>
01000    let Newaddress$(1)=" "
00990    let Newlastname$(1)=" "<br>
01010    let Newcity$(1)=" "
01000    let Newaddress$(1)=" "<br>
01020    let Newstate$(1)=" "
01010    let Newcity$(1)=" "<br>
01030    let Newzipcodes$(1)=" "
01020    let Newstate$(1)=" "<br>
01040    let Newshipmethod$(1)=" "
01030    let Newzipcodes$(1)=" "<br>
01050    let Newitem1(1)=0
01040    let Newshipmethod$(1)=" "<br>
01060    let Newitem2(1)=0
01050    let Newitem1(1)=0<br>
01070    let Newitem3(1)=0
01060    let Newitem2(1)=0<br>
01080  !
01070    let Newitem3(1)=0<br>
01080  !<br>


===GRID1 Part 2===
===GRID1 Part 2===


01090    print fields "2,2,c 42": "Would you like to add a new record?"
01090    print fields "2,2,c 42": "Would you like to add a new record?"<br>
01100    print fields "2,46,cc 8,,b98;2,55,cc 8,,b9": "Yes","No"
01100    print fields "2,46,cc 8,,b98;2,55,cc 8,,b9": "Yes","No"<br>
01110    let Kstat$(1)
01110    let Kstat$(1)<br>
01120    if Fkey=9 then
01120    if Fkey=9 then<br>
01130        goto ENDALL
01130        goto ENDALL<br>
01140    end if
01140    end if<br>
01150  !
01150  !<br>
01160    print fields "4,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)
01160    print fields "4,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)<br>
01170    print fields "4,2,grid 10/80,=": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)
01170    print fields "4,2,grid 10/80,=": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)<br>
01180    print fields "23,30,CC 8,,b99" : "Done"
01180    print fields "23,30,CC 8,,b99" : "Done"<br>
01190  !
01190  !<br>
01200    do While Fkey=98
01200    do While Fkey=98<br>
01210        input fields "4,2,grid 10/80,row,chg": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)
01210        input fields "4,2,grid 10/80,row,chg": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)<br>
01220        write #1, using RECFORM: Newfirstname$(1), Newlastname$(1), Newaddress$(1), Newcity$(1), Newstate$(1), Newzipcodes$(1), Newshipmethod$(1), Newitem1(1), Newitem2(1), Newitem3(1)
01220        write #1, using RECFORM: Newfirstname$(1), Newlastname$(1), Newaddress$(1), Newcity$(1), Newstate$(1), Newzipcodes$(1), Newshipmethod$(1), Newitem1(1), Newitem2(1), Newitem3(1)<br>
01230    loop
01230    loop<br>
01240  !
01240  !<br>
01250  ENDALL: ! Close File And End Program
01250  ENDALL: ! Close File And End Program<br>
01260    close #1:
01260    close #1:<br
01270  !
01280  justchecking: !ok
 


===2.3 NAMEFIND===
===2.3 NAMEFIND===


00002    dim prinform$(12)*12,prinform2$(8)*12,lastname$*30, first$*30, last$*30, address$*30
00002    dim prinform$(12)*12,prinform2$(8)*12,lastname$*30, first$*30, last$*30, address$*30<br>
00003    data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"
00003    data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"<br>
00004    read mat prinform$
00004    read mat prinform$<br>
00005    data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00005    data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"<br>
00006    read mat prinform2$
00006    read mat prinform2$<br>
00007    print fields "2,2,c 50":"Which last name do you wish to search for?"
00007    print fields "2,2,c 50":"Which last name do you wish to search for?"<br>
00008    input fields "4,2,c 30":lastname$
00008    input fields "4,2,c 30":lastname$<br>
00009  !
00009  !<br>
00010    open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed
00010    open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed<br>
00011    read #1, using readform, search=lastname$: first$,last$,address$,city$,state$,zipcode$,shipmethod$,item1,item2,item3
00011    read #1, using readform, search=lastname$: first$,last$,address$,city$,state$,zipcode$,shipmethod$,item1,item2,item3<br>
00012    readform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00012    readform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1<br>
00013  !
00013  !<br>
00014    print fields mat prinform$: "Name: ",first$," ",last$,"Address: ",address$,"City: ",city$,"State: ",state$,"Zipcode: ",zipcode$
00014    print fields mat prinform$: "Name: ",first$," ",last$,"Address: ",address$,"City: ",city$,"State: ",state$,"Zipcode: ",zipcode$<br>
00015    print fields mat prinform2$: "Overnight or Regular? ", shipmethod$,"Item 1? ",item1,"Item 2? ",item2,"Item 3? ",item3
00015    print fields mat prinform2$: "Overnight or Regular? ", shipmethod$,"Item 1? ",item1,"Item 2? ",item2,"Item 3? ",item3<br>


===Namefind Version two===
===Namefind Version two===
This part accounts for two of the same last names.
This part accounts for two of the same last names.


00001  !  Print "this program will find specific records based on names"
00001  !  Print "this program will find specific records based on names"<br>
00002    dim Prinform$(12)*12,Prinform2$(8)*12,Lastname$*30, First$*30, Last$*30, Address$*30
00002    dim Prinform$(12)*12,Prinform2$(8)*12,Lastname$*30, First$*30, Last$*30, Address$*30<br>
00003    data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"
00003    data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"<br>
00004    read Mat Prinform$
00004    read Mat Prinform$<br>
00005    data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00005    data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"<br>
00006    read Mat Prinform2$
00006    read Mat Prinform2$<br>
00007    print fields "2,2,c 50": "Which last name do you wish to search for?"
00007    print fields "2,2,c 50": "Which last name do you wish to search for?"<br>
00008    input fields "4,2,c 30": Lastname$
00008    input fields "4,2,c 30": Lastname$<br>
00009  ! .! let lastname$=UPRC$(lastname$)
00009  ! .! let lastname$=UPRC$(lastname$)<br>
00010  !  Open #1: "name=orders.INT, RECL=118, USE, kfname=firstlast.int,kps=31/1,kln=30/30", Internal, Input, Keyed        ! For Two Keys
00010  !  Open #1: "name=orders.INT, RECL=118, USE, kfname=firstlast.int,kps=31/1,kln=30/30", Internal, Input, Keyed        ! For Two Keys<br>
00011    open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed
00011    open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed<br>
00012    print fields "17,2,c 15":"Next record?"
00012    print fields "17,2,c 15":"Next record?"<br>
00013    print fields "18,2,cc 10,,b8":"Yes"
00013    print fields "18,2,cc 10,,b8":"Yes"<br>
00014    print fields "18,14,cc 10,,b9":"Quit"
00014    print fields "18,14,cc 10,,b9":"Quit"<br>
00015  !
00015  !<br>
00016      read #1, using READFORM, search=Lastname$: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3
00016      read #1, using READFORM, search=Lastname$: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3<br>
00017    READFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1
00017    READFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1<br>
00018      print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$
00018      print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$<br>
00019      print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3
00019      print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3<br>
00020  !
00020  !<br>
00021  !  Prinform2: Form "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00021  !  Prinform2: Form "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"<br>
00022  again: !
00022  again: !<br>
00023      do
00023      do<br>
00024        input fields "24,1,c 1": nomatter$
00024        input fields "24,1,c 1": nomatter$<br>
00025      loop until fkey=8 or fkey=9
00025      loop until fkey=8 or fkey=9<br>
00026  !
00026  !<br>
00027    if FKEY=8 then
00027    if FKEY=8 then<br>
00028      read #1, using READFORM: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3
00028      read #1, using READFORM: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3<br>
00029      print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$
00029      print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$<br>
00030      print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3
00030      print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3<br>
00031      goto again
00031      goto again<br>
00032    else end
00032    else end<br>




===3.1 KSTAT===
===3.1 KSTAT===


00001    dim words$(5)*40,form$(5)*25
00001    dim words$(5)*40,form$(5)*25<br>
00002    print Newpage
00002    print Newpage<br>
00003    data "5,5,c 30","6,5,c 30","7,5,c 30","8,5,c 30","9,5,c 30"
00003    data "5,5,c 30","6,5,c 30","7,5,c 30","8,5,c 30","9,5,c 30"<br>
00004    read mat form$
00004    read mat form$<br>
00005    data "1. Edit transactions","2. Print receipt copies","3. Print invoices","4. Print balances","5.  Return to main menu"
00005    data "1. Edit transactions","2. Print receipt copies","3. Print invoices","4. Print balances","5.  Return to main menu"<br>
00006    read mat words$
00006    read mat words$<br>
00007    print fields mat form$:mat words$
00007    print fields mat form$:mat words$<br>
00008    print fields "12,5,c 40":"Enter menu number"
00008    print fields "12,5,c 40":"Enter menu number"<br>
00009    print kstat$(1)
00009    print kstat$(1)<br>




Line 396: Line 393:


Answers will vary. When writing the record, you will have to add TIME$ to the WRITE line and n 8 to the form line, also update the record length in the OPEN statement.  
Answers will vary. When writing the record, you will have to add TIME$ to the WRITE line and n 8 to the form line, also update the record length in the OPEN statement.  


===5.1 STR2MAT===
===5.1 STR2MAT===
Line 402: Line 398:


Lines 30 to 70 of our example above could be replaced by the following:
Lines 30 to 70 of our example above could be replaced by the following:
str2mat("First Name,Last Name,Address,City,State,Zip Code,Shipping,Item 1,Item 2,Item 3", mat headings$,",")
 
data 10,10,10,10,4,9,3,3,3,3
str2mat("First Name,Last Name,Address,City,State,Zip Code,Shipping,Item 1,Item 2,Item 3", mat headings$,",")<br>
read mat widths
data 10,10,10,10,4,9,3,3,3,3<br>
f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"
read mat widths<br>
str2mat(f$,mat forms$,",")
f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"<br>
str2mat(f$,mat forms$,",")<br>


===5.2 SRCH===
===5.2 SRCH===
Note, your program might be different, but this is one successful option. With a short file, this task could be accomplished with FOR/NEXT and not SRCH, but in a very long list of clients, SRCH will speed it up considerably. The relevant code begins at line 380
Note, your program might be different, but this is one successful option. With a short file, this task could be accomplished with FOR/NEXT and not SRCH, but in a very long list of clients, SRCH will speed it up considerably. The relevant code begins at line 380


00010 !  #autonumber# 10,10
00010 !  #autonumber# 10,10<br>
00020    print Newpage
00020    print Newpage<br>
00030      dim  Answers$(6)*30,ordered(3), head, f$*100
00030      dim  Answers$(6)*30,ordered(3), head, f$*100<br>
00040    open #1: "name=orders.INT", internal, input, relative
00040    open #1: "name=orders.INT", internal, input, relative<br>
00050    dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)
00050    dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)<br>
00060  !
00060  !<br>
00070    readthenextone: ! read next record
00070    readthenextone: ! read next record<br>
00080  !
00080  !<br>
00090    read #1, using openform: mat answers$,shipping$,mat ordered eof DoneReading
00090    read #1, using openform: mat answers$,shipping$,mat ordered eof DoneReading<br>
00100        openform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00100        openform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1<br>
00110  !
00110  !<br>
00120        let NewSize=udim(FirstName$)+1
00120        let NewSize=udim(FirstName$)+1<br>
00130  !
00130  !<br>
00140        mat FirstName$(NewSize)
00140        mat FirstName$(NewSize)<br>
00150        mat LastName$(NewSize)
00150        mat LastName$(NewSize)<br>
00160        mat Address$(NewSize)
00160        mat Address$(NewSize)<br>
00170        mat City$(NewSize)
00170        mat City$(NewSize)<br>
00180        mat state$(newsize)
00180        mat state$(newsize)<br>
00190        mat zipcodes$(NewSize)
00190        mat zipcodes$(NewSize)<br>
00200        mat shipmethod$(NewSize)
00200        mat shipmethod$(NewSize)<br>
00210        mat item1(NewSize)
00210        mat item1(NewSize)<br>
00220        mat item2(NewSize)
00220        mat item2(NewSize)<br>
00230        mat item3(NewSize)
00230        mat item3(NewSize)<br>
00240  !
00240  !<br>
00250        FirstName$(NewSize)=Answers$(1)
00250        FirstName$(NewSize)=Answers$(1)<br>
00260        LastName$(NewSize)=Answers$(2)
00260        LastName$(NewSize)=Answers$(2)<br>
00270        Address$(NewSize)=Answers$(3)
00270        Address$(NewSize)=Answers$(3)<br>
00280        City$(NewSize)=Answers$(4)
00280        City$(NewSize)=Answers$(4)<br>
00290        state$(newsize)=answers$(5)
00290        state$(newsize)=answers$(5)<br>
00300        zipcodes$(NewSize)=Answers$(6)
00300        zipcodes$(NewSize)=Answers$(6)<br>
00310        shipmethod$(NewSize)=shipping$
00310        shipmethod$(NewSize)=shipping$<br>
00320        item1(NewSize)=ordered(1)
00320        item1(NewSize)=ordered(1)<br>
00330        item2(NewSize)=ordered(2)
00330        item2(NewSize)=ordered(2)<br>
00340        item3(NewSize)=ordered(3)
00340        item3(NewSize)=ordered(3)<br>
00350  !
00350  !<br>
00360      goto ReadTheNextOne
00360      goto ReadTheNextOne<br>
00370  !
00370  !<br>
00380      DoneReading: ! We're done reading the file into arrays, next search for items.
00380      DoneReading: ! We're done reading the file into arrays, next search for items.<br>
00390  !
00390  !<br>
00400      print "The following people ordered all three items:"
00400      print "The following people ordered all three items:"<br>
00410      print "Row ";"Name"
00410      print "Row ";"Name"<br>
00420  !
00420  !<br>
00430      do while SRCH(item1,1,y)>0
00430      do while SRCH(item1,1,y)>0<br>
00440        let x=SRCH(item1,1,y)
00440        let x=SRCH(item1,1,y)<br>
00450        if item2(x)=1 and item3(x)=1 then
00450        if item2(x)=1 and item3(x)=1 then<br>
00460          print x;" ";firstname$(x);" ";lastname$(x)
00460          print x;" ";firstname$(x);" ";lastname$(x)<br>
00470        end if
00470        end if<br>
00480        let y=x+1
00480        let y=x+1<br>
00490      loop
00490      loop<br>


===5.3 DIDX===
===5.3 DIDX===
 
nexttry:  ! this<br>
    nexttry:  ! this
restore nexttry<br>
    restore nexttry
dim salestotal(12)<br>
    dim salestotal(12)
data 300,500,66,789,1023,24,56,72,800,945,15,7<br>
    data 300,500,66,789,1023,24,56,72,800,945,15,7
read mat salestotal<br>
    read mat salestotal
mat changed(12)=DIDX(salestotal)<br>
 
for I=1 to 12<br>
    mat changed(12)=DIDX(salestotal)
print salestotal(changed(I))<br>
 
next I<br>
for I=1 to 12
      print salestotal(changed(I))
    next I


===10.3 Sample webpage===
===10.3 Sample webpage===
index.html
[[image:samplewebpage.jpg]]
      <!doctype html>
<html>
<head>
<title>Travel Survey</title>
</head>
 
<body>
<h1>Conference Suggestions</h1>
<p>Please complete the following survey:</p>
 
<form action="?BR_FUNC=fntravelsurvey" method="post">
<input type="hidden" name="BR_FUNC" value="fntravelsurvey">
 
<p>Where would you like to have the next conference?</p>
  <input type="checkbox" name="Dallas"> Dallas
  <input type="checkbox" name="Stlouis"> St.Louis
  <input type="checkbox" name="Sanfran"> San Francisco
 
<p>How many people will be attending?</p>
  <input type="radio" name="one"> 1
  <input type="radio" name="two"> 2
  <input type="radio" name="more"> 3 or More
 
<p>Other Comments:</p>
<textarea value="comments" name="commentfield" cols="50" rows="5" >
</textarea> <br>
<input type="submit" value="Click to Record">
</form>


<p><a href="?BR_FUNC=fnthankyoupage"</a>Click to go to the page named
[[Tutorial 2|Table of Contents]]
FirstPage</p>


</body>
<noinclude>
</html>
[[Category:Tutorial]]
</noinclude>

Latest revision as of 15:25, 16 July 2013

SOLUTIONS for the Intermediate Tutorial (Tutorial 2).

These solutions are meant to provide a guideline as you work through the tutorial. However, there are often several ways to approach a programming challenge and solve each challenge. You may find that your solutions are different.

Exercise 1.1

The following code demonstrates this as the user chooses what kind of order will be processed:

00140  ! radio buttons
00150 let X$="Overnight"
00160 let Y$="Regular"
00170 print fields "12,5, c 30": "Shipping preference: "
00180 rinput fields "13,5,radio 9,2,8;14,5,radio 7,2,9":X$,Y$
00190 if FKEY=8, then print fields "15,5,c 30": "It will be there tomorrow!"
00200 if FKEY=9, then print fields "16,5,c 50": “It will be there with 3 to 7 business days!"
00220 if x$(1:1)="^" then shipping$="O"
00230 if y$(1:1)="^" then shipping$="R"

Exercise 1.2

The following code augments our sample program with the ability to select which items to ship:

00002 dim boxnameform$(3)*20,boxname$(3)*20,box$(3)*20
00004 data "22,15,c 10","23,15,c 10","24,15,c 10"
00005 data "Item 1","Item 2","Item 3"
00006 read mat boxnameform$
00007 read mat boxname$
00008 print fields "20,5,c 35": "Please select items to order:"
00009 print fields mat boxnameform$:mat boxname$
00010  !
00011 let X$="one" : let Y$="two"
00012 print fields "24,30,C 20": "Press Esc to quit"
00013 do
00014 input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": box$(1),box$(2),box$(3)
00015 print fields "24,1,N 2": Fkey
00016 loop While Fkey~=99

In this example, the DO LOOP structure allows the user to choose more than one checkbox, while the Escape key allows the user to exit the program when complete.

Exercise 1.3 A

00260 dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20
00270 data "22,15,c 10","23,15,c 10","24,15,c 10"
00280 data "Item 1","Item 2","Item 3"
00290 read Mat Boxnameform$
00300 read Mat Boxname$
00310 print fields "20,5,c 35": "Please select items to order:"
00320 print fields Mat Boxnameform$: Mat Boxname$
00340 print fields "23,30,CC 8,,b99" : "Done"
00350 do
00360 input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)
00370 print fields "24,1,N 2": Fkey
00380 loop While Fkey~=99
00390 For I=1 to UDIM(box$)
00400 if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0
00410 next I

Exercise 1.3B

00001  ! .! This is a sample for use of radio buttons, checkboxes, and buttons.
00010  ! .! #autonumber# 10,10
00020 print Newpage
00030 dim Clientform$(6)*20, Clientwords$(6)*20, Answerform$(6)*30, Answers$(6)*30,ordered(3)
00040 data "5,3,C 20","6,3,C 20","7,3,C 20","8,3,C 10","8,36,C 10","9,3,C 10"
00050 read Mat Clientform$
00060 data "First Name: ","Last Name: ","Address: ","City: ","State: ","Zip Code: "
00070 read Mat Clientwords$
00080 data "5,20,C 30","6,20,C 30","7,20,C 30","8,20,C 15","8,43,C 2","9,20,C 7"
00090 read Mat Answerform$
00100  ! Finame$, Lname$,Address$,City$,State$,Zipcode$
00110 print fields Mat Clientform$: Mat Clientwords$
00120  !
00130 input fields Mat Answerform$: Mat Answers$
00140  !
00150  ! Radio Buttons
00160 let X$="^Overnight"
00170 let Y$="Regular"
00180 print fields "12,5, c 30": "Shipping preference: "
00190 rinput fields "13,5,radio 10,2,8;14,5,radio 7,2,9": X$,Y$
00200 if Fkey=8, then print fields "15,5,c 20": "Ok then!"
00210 if Fkey=9, then print fields "16,5,c 20": "We'll do it!"
00220 if x$(1:1)="^" then shipping$="O"
00230 if y$(1:1)="^" then shipping$="R"
00240  !
00250  ! Check Boxes
00260 dim Boxnameform$(3)*20,Boxname$(3)*20,Box$(3)*20
00270 data "22,15,c 10","23,15,c 10","24,15,c 10"
00280 data "Item 1","Item 2","Item 3"
00290 read Mat Boxnameform$
00300 read Mat Boxname$
00310 print fields "20,5,c 35": "Please select items to order:"
00320 print fields Mat Boxnameform$: Mat Boxname$
00340 print fields "23,30,CC 8,,b99" : "Done"
00350 do
00360 input fields "22,14,CHECK 8,,10;23,14,CHECK 8,,11;24,14,CHECK 8,,12": Box$(1),Box$(2),Box$(3)
00370 print fields "24,1,N 2": Fkey
00380 loop While Fkey~=99
00390 For I=1 to UDIM(box$)
00400 if box$(I)(1:1)="^" then ordered(I)=1 else ordered(I)=0
00410 next I
00420  !
00430  ! Open File And Record Answers
00440 Open #1: "name=orders.int, recl=118,USE,kfname=lastfirst.int,kps=31/1,kln=30/30", internal, OUTIN, keyed
00450 write #1, using recform:mat answers$,shipping$,mat ordered
00460 recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00470 close #1:
00480  !


1.4 SAMPLIST.BR

00001  ! Print "this is a sample list then a grid"
00010  ! .! #autonumber# 10,10
00020 print newpage
00030 dim HEADINGS$(10), WIDTHS(10), FORMS$(10), Answers$(6)*30,ordered(3), head, f$*100
00040 data "First Name”,”Last Name”,”Address”,”City”,”State”,”Zip Code”,”Shipping”,”Item 1”,”Item 2”,”Item 3"
00045 read mat headings$
00050 data 10,10,10,10,4,9,3,3,3,3
00060 read mat widths
00070 f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"
00080 str2mat(f$,mat forms$,",")
00090  !
00100 dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)
00110  !
00120 open #1:"name=orders.int, recl=118,USE", internal, outin
00130  !
00140 mat FirstName$(0)
00150 mat LastName$(0)
00160 mat Address$(0)
00170 mat City$(0)
00180 mat state$(0)
00190 mat zipcodes$(0)
00200 mat shipmethod$(0)
00210 mat item1(0)
00220 mat item2(0)
00230 mat item3(0)
00240  !
00250 ReadTheNextOne:  ! ok
00260 read #1, using recform:mat answers$,shipping$,mat ordered eof DoneReading
00270 recform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00280  !
00290 let NewSize=udim(FirstName$)+1
00300  !
00310 mat FirstName$(NewSize)
00320 mat LastName$(NewSize)
00330 mat Address$(NewSize)
00340 mat City$(NewSize)
00350 mat state$(newsize)
00360 mat zipcodes$(NewSize)
00370 mat shipmethod$(NewSize)
00380 mat item1(NewSize)
00390 mat item2(NewSize)
00400 mat item3(NewSize)
00410  !
00420 FirstName$(NewSize)=Answers$(1)
00430 LastName$(NewSize)=Answers$(2)
00440 Address$(NewSize)=Answers$(3)
00450 City$(NewSize)=Answers$(4)
00460 state$(newsize)=answers$(5)
00470 zipcodes$(NewSize)=Answers$(6)
00480 shipmethod$(NewSize)=shipping$
00490 item1(NewSize)=ordered(1)
00500 item2(NewSize)=ordered(2)
00510 item3(NewSize)=ordered(3)
00520  !
00530 goto ReadTheNextOne
00540  !
00550 DoneReading: ! We're done reading, go to the next part, print them on the list
00560  !
00570  !
00580 print fields "2,2,list 10/80,headers": (MAT HEADINGS$,MAT WIDTHS,MAT FORMS$)
00590 print fields "2,2,list 10/80,=r": (mat FirstName$, mat LastName$,mat Address$,mat City$,mat state$,mat zipcodes$,mat shipmethod$,mat item1,mat item2,mat item3)
00600  !
00610 print fields "23,30,CC 8,,b99" : "Done"
00620 do
00630 input fields "2,2,list 10/80,rowsub,selone": selection
00640 loop while FKEY~=99
00650 print selection
00660  !
00670 close #1:
00680  !


1.5 GRID1

GRID1, part one:

00001  ! Print "this is a sample list then a grid"
00002  ! This Is A Sample Sort And Print File.
00010  ! .! #autonumber# 10,10
00020 print Newpage
00030 dim Headings$(10), Widths(10), Forms$(10), Answers$(6)*30,Ordered(3), Head
00040 data "First Name","Last Name","Address","City","State","Zip Code","Shipping","Item 1","Item 2","Item 3"
00050 read Mat Headings$
00060 data 10,10,10,10,4,9,3,3,3,3
00070 read Mat Widths
00080 data "cc 30","cc 30","cc 30","cc 15","cc 2","cc 7","cc 1","n 1","n 1","n 1"
00090 read Mat Forms$
00100  !
00110 dim Firstname$(1)*30,Lastname$(1)*30,Address$(1)*30,City$(1)*15,State$(1)*2,Zipcodes$(1)*7,Shipmethod$(1)*1,Item1(1),Item2(1),Item3(1),Recordnum(1)
00120  !
00130 open #1: "name=orders.INT", internal, outin, relative
00140  !
00150 mat Firstname$(0)
00160 mat Lastname$(0)
00170 mat Address$(0)
00180 mat City$(0)
00190 mat State$(0)
00200 mat Zipcodes$(0)
00210 mat Shipmethod$(0)
00220 mat Item1(0)
00230 mat Item2(0)
00240 mat Item3(0)
00250 mat Recordnum(0)
00260  !
00270  !
00280 READTHENEXTONE: ! Ok
00290 read #1, using RECFORM: Mat Answers$,Shipping$,Mat Ordered eof DONEREADING
00300 RECFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1
00310  !
00320 let Newsize=Udim(Firstname$)+1
00330  !
00340 mat Firstname$(Newsize)
00350 mat Lastname$(Newsize)
00360 mat Address$(Newsize)
00370 mat City$(Newsize)
00380 mat State$(Newsize)
00390 mat Zipcodes$(Newsize)
00400 mat Shipmethod$(Newsize)
00410 mat Item1(Newsize)
00420 mat Item2(Newsize)
00430 mat Item3(Newsize)
00440 mat Recordnum(Newsize)
00450  !
00460 let Firstname$(Newsize)=Answers$(1)
00470 let Lastname$(Newsize)=Answers$(2)
00480 let Address$(Newsize)=Answers$(3)
00490 let City$(Newsize)=Answers$(4)
00500 let State$(Newsize)=Answers$(5)
00510 let Zipcodes$(Newsize)=Answers$(6)
00520 let Shipmethod$(Newsize)=Shipping$
00530 let Item1(Newsize)=Ordered(1)
00540 let Item2(Newsize)=Ordered(2)
00550 let Item3(Newsize)=Ordered(3)
00560 let Recordnum(Newsize)=Rec(1)
00570  !
00580 goto READTHENEXTONE
00590  !
00600 DONEREADING: ! We're done reading, go to the nexst part, print them on the list
00610  !
00620 print fields "2,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)
00630 print fields "2,2,grid 10/80,=r": (Mat Firstname$, Mat Lastname$,Mat Address$,Mat City$,Mat State$,Mat Zipcodes$,Mat Shipmethod$,Mat Item1,Mat Item2,Mat Item3)
00640  !
00650 print fields "23,30,CC 8,,b99" : "Done" ! Done Button
00660  !
00670 do
00680  ! .  ! writing changed selections to the file
00690 input fields "2,2,GRID 10/80,ROWCNT,CHG": Rows ! # Of Changed Rows
00700 mat Subscr(Rows) ! Redimension
00710 input fields "2,2,GRID 10/80,ROWSUB,CHG,NOWAIT": Mat Subscr ! Read Subscripts
00720  !
00730  ! .  ! redimension
00740 mat Firstname$(Rows)
00750 mat Lastname$(Rows)
00760 mat Address$(Rows)
00770 mat City$(Rows)
00780 mat State$(Rows)
00790 mat Zipcodes$(Rows)
00800 mat Shipmethod$(Rows)
00810 mat Item1(Rows)
00820 mat Item2(Rows)
00830 mat Item3(Rows)
00840  !
00850 input fields "2,2,GRID 10/80,ROW,CHG,NOWAIT": (Mat Firstname$, Mat Lastname$, Mat Address$, Mat City$, Mat State$, Mat Zipcodes$, Mat Shipmethod$, Mat Item1, Mat Item2, Mat Item3) ! Read Changed Rows
00860  !
00870  ! Write To File
00880 for Index=1 to Udim(Mat Firstname$)
00890 let Thesubscriptnumber=Subscr(Index)
00900 let Therecordnumber=Recordnum(Thesubscriptnumber)
00910 rewrite #1, using RECFORM, rec=Therecordnumber: Firstname$(Index), Lastname$(Index), Address$(Index), City$(Index), State$(Index), Zipcodes$(Index), Shipmethod$(Index), Item1(Index), Item2(Index), Item3(Index)
00920 next Index
00930 loop Until Fkey=99
00940  !
00950 dim Newfirstname$(1)*30, Newlastname$(1)*30, Newaddress$(1)*30, Newcity$(1)*15, Newstate$(1)*2, Newzipcodes$(1)*7, Newshipmethod$(1)*1, Newitem1(1), Newitem2(1), Newitem3(1)
00960  !
00970 print Newpage
00980 let Newfirstname$(1)=" "
00990 let Newlastname$(1)=" "
01000 let Newaddress$(1)=" "
01010 let Newcity$(1)=" "
01020 let Newstate$(1)=" "
01030 let Newzipcodes$(1)=" "
01040 let Newshipmethod$(1)=" "
01050 let Newitem1(1)=0
01060 let Newitem2(1)=0
01070 let Newitem3(1)=0
01080  !

GRID1 Part 2

01090 print fields "2,2,c 42": "Would you like to add a new record?"
01100 print fields "2,46,cc 8,,b98;2,55,cc 8,,b9": "Yes","No"
01110 let Kstat$(1)
01120 if Fkey=9 then
01130 goto ENDALL
01140 end if
01150  !
01160 print fields "4,2,grid 10/80,headers": (Mat Headings$,Mat Widths,Mat Forms$)
01170 print fields "4,2,grid 10/80,=": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)
01180 print fields "23,30,CC 8,,b99" : "Done"
01190  !
01200 do While Fkey=98
01210 input fields "4,2,grid 10/80,row,chg": (Mat Newfirstname$, Mat Newlastname$, Mat Newaddress$, Mat Newcity$, Mat Newstate$, Mat Newzipcodes$, Mat Newshipmethod$, Mat Newitem1, Mat Newitem2, Mat Newitem3)
01220 write #1, using RECFORM: Newfirstname$(1), Newlastname$(1), Newaddress$(1), Newcity$(1), Newstate$(1), Newzipcodes$(1), Newshipmethod$(1), Newitem1(1), Newitem2(1), Newitem3(1)
01230 loop
01240  !
01250 ENDALL: ! Close File And End Program
01260 close #1:<br

2.3 NAMEFIND

00002 dim prinform$(12)*12,prinform2$(8)*12,lastname$*30, first$*30, last$*30, address$*30
00003 data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"
00004 read mat prinform$
00005 data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00006 read mat prinform2$
00007 print fields "2,2,c 50":"Which last name do you wish to search for?"
00008 input fields "4,2,c 30":lastname$
00009  !
00010 open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed
00011 read #1, using readform, search=lastname$: first$,last$,address$,city$,state$,zipcode$,shipmethod$,item1,item2,item3
00012 readform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00013  !
00014 print fields mat prinform$: "Name: ",first$," ",last$,"Address: ",address$,"City: ",city$,"State: ",state$,"Zipcode: ",zipcode$
00015 print fields mat prinform2$: "Overnight or Regular? ", shipmethod$,"Item 1? ",item1,"Item 2? ",item2,"Item 3? ",item3

Namefind Version two

This part accounts for two of the same last names.

00001  ! Print "this program will find specific records based on names"
00002 dim Prinform$(12)*12,Prinform2$(8)*12,Lastname$*30, First$*30, Last$*30, Address$*30
00003 data "8,2,c 6","8,9,c 30","8,39,c 1","8,40,c 30","9,2,c 9","9,12,c 30","9,43,c 6","9,50,c 15","9,65,c 7","9,73,c 2","10,2,c 9","10,12,c 7"
00004 read Mat Prinform$
00005 data "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00006 read Mat Prinform2$
00007 print fields "2,2,c 50": "Which last name do you wish to search for?"
00008 input fields "4,2,c 30": Lastname$
00009  ! .! let lastname$=UPRC$(lastname$)
00010  ! Open #1: "name=orders.INT, RECL=118, USE, kfname=firstlast.int,kps=31/1,kln=30/30", Internal, Input, Keyed  ! For Two Keys
00011 open #1: "name=orders.INT, kfname=firstlast.int,kps=1,kln=60", internal, input, keyed
00012 print fields "17,2,c 15":"Next record?"
00013 print fields "18,2,cc 10,,b8":"Yes"
00014 print fields "18,14,cc 10,,b9":"Quit"
00015  !
00016 read #1, using READFORM, search=Lastname$: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3
00017 READFORM: form C 30,C 30,C 30,C 15,C 2,C 7,C 1,N 1,N 1,N 1
00018 print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$
00019 print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3
00020  !
00021  ! Prinform2: Form "11,2,c 22","11,25,c 1","13,2,c 8","13, 12,n 1","14,2,c 8","14,12,n 1","15,2,c 8","15,12,n 1"
00022 again: !
00023 do
00024 input fields "24,1,c 1": nomatter$
00025 loop until fkey=8 or fkey=9
00026  !
00027 if FKEY=8 then
00028 read #1, using READFORM: First$,Last$,Address$,City$,State$,Zipcode$,Shipmethod$,Item1,Item2,Item3
00029 print fields Mat Prinform$: "Name: ",First$," ",Last$,"Address: ",Address$,"City: ",City$,"State: ",State$,"Zipcode: ",Zipcode$
00030 print fields Mat Prinform2$: "Overnight or Regular? ", Shipmethod$,"Item 1? ",Item1,"Item 2? ",Item2,"Item 3? ",Item3
00031 goto again
00032 else end


3.1 KSTAT

00001 dim words$(5)*40,form$(5)*25
00002 print Newpage
00003 data "5,5,c 30","6,5,c 30","7,5,c 30","8,5,c 30","9,5,c 30"
00004 read mat form$
00005 data "1. Edit transactions","2. Print receipt copies","3. Print invoices","4. Print balances","5. Return to main menu"
00006 read mat words$
00007 print fields mat form$:mat words$
00008 print fields "12,5,c 40":"Enter menu number"
00009 print kstat$(1)


3.2 UPRCS

Answers may vary. One solution is to change the following line:

00470 let Lastname$(Newsize)=uprc$(Answers$(2))

3.3 LREC

Add a similar line to your program:

00655 print fields "21,30,n 4":lrec(1)

3.4 TIME$

Answers will vary. When writing the record, you will have to add TIME$ to the WRITE line and n 8 to the form line, also update the record length in the OPEN statement.

5.1 STR2MAT

Two different possibilities are shown below, for mat headings$ and mat forms$

Lines 30 to 70 of our example above could be replaced by the following:

str2mat("First Name,Last Name,Address,City,State,Zip Code,Shipping,Item 1,Item 2,Item 3", mat headings$,",")
data 10,10,10,10,4,9,3,3,3,3
read mat widths
f$="cc 30,cc 30,cc 30,cc 15,cc 2,cc 7,cc 1,n 1,n 1,n 1"
str2mat(f$,mat forms$,",")

5.2 SRCH

Note, your program might be different, but this is one successful option. With a short file, this task could be accomplished with FOR/NEXT and not SRCH, but in a very long list of clients, SRCH will speed it up considerably. The relevant code begins at line 380

00010 ! #autonumber# 10,10
00020 print Newpage
00030 dim Answers$(6)*30,ordered(3), head, f$*100
00040 open #1: "name=orders.INT", internal, input, relative
00050 dim FirstName$(1)*30,LastName$(1)*30,Address$(1)*30,City$(1)*15,state$(1)*2,zipcodes$(1)*7,shipmethod$(1)*1,item1(1),item2(1),item3(1)
00060  !
00070 readthenextone: ! read next record
00080  !
00090 read #1, using openform: mat answers$,shipping$,mat ordered eof DoneReading
00100 openform: form c 30,c 30,c 30,c 15,c 2,c 7,c 1,n 1,n 1,n 1
00110  !
00120 let NewSize=udim(FirstName$)+1
00130  !
00140 mat FirstName$(NewSize)
00150 mat LastName$(NewSize)
00160 mat Address$(NewSize)
00170 mat City$(NewSize)
00180 mat state$(newsize)
00190 mat zipcodes$(NewSize)
00200 mat shipmethod$(NewSize)
00210 mat item1(NewSize)
00220 mat item2(NewSize)
00230 mat item3(NewSize)
00240  !
00250 FirstName$(NewSize)=Answers$(1)
00260 LastName$(NewSize)=Answers$(2)
00270 Address$(NewSize)=Answers$(3)
00280 City$(NewSize)=Answers$(4)
00290 state$(newsize)=answers$(5)
00300 zipcodes$(NewSize)=Answers$(6)
00310 shipmethod$(NewSize)=shipping$
00320 item1(NewSize)=ordered(1)
00330 item2(NewSize)=ordered(2)
00340 item3(NewSize)=ordered(3)
00350  !
00360 goto ReadTheNextOne
00370  !
00380 DoneReading: ! We're done reading the file into arrays, next search for items.
00390  !
00400 print "The following people ordered all three items:"
00410 print "Row ";"Name"
00420  !
00430 do while SRCH(item1,1,y)>0
00440 let x=SRCH(item1,1,y)
00450 if item2(x)=1 and item3(x)=1 then
00460 print x;" ";firstname$(x);" ";lastname$(x)
00470 end if
00480 let y=x+1
00490 loop

5.3 DIDX

nexttry:  ! this
restore nexttry
dim salestotal(12)
data 300,500,66,789,1023,24,56,72,800,945,15,7
read mat salestotal
mat changed(12)=DIDX(salestotal)
for I=1 to 12
print salestotal(changed(I))
next I

10.3 Sample webpage

Table of Contents