Loading ...
Sorry, an error occurred while loading the content.

2975[NTB] Re: Arrays?

Expand Messages
  • R.S.
    Nov 1, 1998
    • 0 Attachment
      Hi David,

      At 08:02 AM 11/01/98 +0200, you wrote:

      >There was a guide somewhere to different methods for setting
      >up arrays in NTP. Anyone remember where?


      This is how it works:

      ;***********************
      H=Arrays

      ^!Set i=1

      ^!Set arr^%i%="One"
      ^!Inc i
      ^!Set arr^%i%="Two"
      ^!Inc i
      ^!Set arr^%i%="Three"

      ;ALWAYS SAVE INDEX TO LAST CREATED ITEM TO
      ;HAVE CONTROL OVER THE ARRAY:
      ^!Set iArrayTop=^%i%

      ^!Info First array item is = ^%arr1% ^p Second array item is = ^%arr2% ^p
      Third array item is = ^%arr3%



      ;YOU CAN ALSO USE A LOOP TO GET THE CONTENTS OF THE ARRAY:
      ^!SetWizardTitle Recursing array through a loop

      ^!Set i=1
      :loop
      ^!If ^%i%>^%iArrayTop% Next1
      ^!Info Array item ^%i% is = ^%arr^%i%%
      ^!inc i
      ^!Goto loop

      :Next1
      ;NOW, AS CONSCIOUS PROGRAMMERS WE ARE, WE SHOULD
      ;CLEAN AFTER OURSELVES:
      ; (notice how I'm avoiding the sloppy use of
      ; the ^!ClearVariables command -- a programmer
      ; should always know his/her variables!)

      ;DELETE THE ARRAY:
      ^!Set i=1
      :loop2
      ^!If ^%i%>^%iArrayTop% Next2
      ^!ClearVariable %arr^%i%%
      ^!inc i
      ^!Goto loop2

      :Next2

      ;THIS WILL SHOW THE VARIABLES ARE CLEARED:
      ^!SetWizardTitle After Variables were cleared:
      ^!Set i=1
      :loop3
      ^!If ^%i%>^%iArrayTop% End
      ^!Info Array item ^%i% is = ^%arr^%i%%
      ^!inc i
      ^!Goto loop3
      ;************************




      Regards,


      RS
      ------------------------------------------------------------------------
      Subscribe, unsubscribe, opt for a daily digest, or start a new e-group
      at http://www.eGroups.com -- Free Web-based e-mail groups.
    • Show all 10 messages in this topic