Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Phones.CSP — MVBasic Code

Next we add an MVBasic code, inside <script></script> tags, to Phones.CSP. This routine opens MVFILE.PERSON and retrieves the record with an item-ID matching the value passed from Person.CSP in the %request object. It then displays the NAME attribute and all of the values of the PHONES attribute.

Add the following code to Phones.CSP between the closing </caption> and the closing </table> tags.


<script language="mvbasic" runat="server">
 OPEN "DICT", "PERSON" ELSE PRINT "DICT NOT OPEN";GOTO 100
 READV NAME.AMC FROM "NAME",2
 READV PHONE.AMC FROM "PHONE",2
 OPEN "PERSON" TO PERSFILE ELSE PRINT "FILE NOT OPEN";GOTO 100 
 ID = %request->Get("ID")
 READV NAME FROM PERSFILE, ID, NAME.AMC ELSE PRINT "Name Not Found";GOTO 100
 PRINT "<tr>"
 PRINT "<td>":NAME:"</td>"
 PRINT "<td>"
 GOSUB PHONES
 PRINT "</td>"
 PRINT "</tr>" 
 GOTO 100
 PHONES:
 VM=CHAR(253)
 READV ATTR FROM PERSFILE, ID, PHONE.AMC ELSE PRINT "Phone Not Found"; GOTO 100
 VNO=0
 LOOP
 VNO=VNO+1
 VALUE=FIELD(ATTR,VM,VNO)
 WHILE COL2() <>0 DO
 PRINT VALUE: "</br>"
 REPEAT
 RETURN
 100
</script>

Note the following about the code:

  1. This line of code: ID = %request->Get("ID") retrieves the item-ID value from %request. Person.CSP passes this value to Phones.CSP using the %request object.

  2. As in the case of Person.CSP the PRINT statements output HTML tags in addition to MVFILE.PERSON data. These tags format the data into HTML table cells.

Feedback