! Text Conversion Examples   
! This has examples of:
!       1) Reading and Writting to a Format Text field.
!       2) Reading from a Source-IV Document
!       3) Reading from an Idol-IV Help Document                                                                                                              
 
LN   UTCUST                          ! Sample link 
DN   NUM-LINES(3.0)                  ! Temporary Data_name                                                                                                  
 
MAINLINE
   OPEN LINK UTCUST                  ! Opens Links
 
   DO ASKKEYWRITE                    ! Get a Key and Text
 
   DO ADDKEY                         ! Add Key to file
 
   DO ADDTEXT                        ! Add Text to file                        
   
   DO ASKKEYREAD                     ! Get a Key to Read                       
 
   DO GETTEXT                        ! Read the Text field
 
   DO GETSOURCE                      ! Read Source-IV Document                
 
   DO GETHELP                        ! Read Idol-IV Help Document
 
   DO ENDIT                          ! End Script                                                                                                           
 
ASKKEYWRITE
  INPUT "ENTER A KEY: ",K$          !Prompt for Key
  INPUT "ENTER SOME TEXT: ",T$      ! Prompt for Text 
 
ASKKEYREAD
  INPUT "ENTER A KEY: ",K$          ! Prompt for Key
 
ADDKEY
  LET UTCUST.CUST-CODE = PAD(K$,4)  ! Assign the Key to the Link
  ADD UTCUST USING KEY UTCUST.CUST-CODE  ! Add the Key to the file
 
ADDTEXT
  DIM MSG$[2]                       ! Dimension MSG$
  LET MSG$[0]="WRITE LINK UTCUST, " + ! Setup MSG$[0] to: WRITE to the 
              QUO + PAD(K$,4) + QUO + ! link UTCUST with the key of K$ and
                   ", A"               ! Text ID of "A"
  LET MSG$[1]= T$                   ! Assing MSG$[1] the Text to add
  CONNECT METHOD "OO41"             ! Connect to OO41
 
  DO METHERR                        ! Error Routine                                                                                                        
 
GETTEXT
  DIM MSG$[2]                         ! Dimension MSG$
  LET MSG$[0]="READ LINK UTCUST, " +  ! Setup  MSG$[0] to Read from the
              QUO + PAD(K$,4) + QUO + ! link UTCUST with the key of K$ and
                ", A"                 ! Text ID of "A"
    CONNECT METHOD "OO41"             ! Connect to OO41
 
     DO METHERR                        ! Error Routine
 
  PRINT "TEXT RETURNED: ", MSG$[1]  ! Print the Text contained in MSG$[1]
  INPUT " ---PAUSE --- ",*          ! Wait for user to hit
  
GETSOURCE
  DIM MSG$[2]                       ! Dimension MSG$
  LET MSG$[0] = "READ   PJ.PJPTEXT "! Setup MSG$[0] to Read from a 
                                    ! Source-IV Docutment
  CONNECT METHOD "OO41"             ! Connect to OO41
 
  DO METHERR                        ! Error Routine
 
  DO PRINTRESULT                    ! Print Results
 
PRINTRESULT
  PRINT "TEXT RETURNED: "           ! Start printing Output
  LET NUM-LINES = NEA("MSG$",1)     ! Get the number of Array elements
  LET COUNT = 1                     ! Set Counter
     DO LOOP WHILE COUNT =< NUM-LINES  ! Start loop for printing
  PRINT MSG$[COUNT]              ! Print Text Line
  LET COUNT = COUNT + 1          ! Increment counter
     ENDLOOP                           ! End Loop
  INPUT "---PAUSE---",*             ! Pause
 
GETHELP
  DIM MSG$[2]                       ! Dimension MSG$
  LET MSG$[0] = "READ PJHHTML ,"    ! Setup MSG$[0] to Read from a
                                    ! Idol-IV Help Document
  CONNECT METHOD "OO41"             ! Connect to OO41
 
  DO METHERR                        ! Error Routine
  DO PRINTRESULT                    ! Print Results
 
METHERR
  IF MSG$[0] <> "." THEN            ! Test to see if Connect complete OK
     PRINT "METHOD FAILED.  ERROR NUMBER: ",MSG$[0] ! Print Error Message
  ENDIF
                                                                                                                                                    ENDIT 
  INPUT "FINISHED ",*               ! Finished