Guidance
指路人
g.yi.org
software / rapidq / Examples / Algorithm & Maths / arrins.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' How to insert elements into Array the fast/easy way
' Change the data type to suit your needs


     SUB ArrayInsert (Array() AS LONG, Element AS LONG, Value AS LONG)
      DIM M AS QMEMORYSTREAM

      M.Position = 0
    '-- Save previous elements
      M.SaveArray(Array(LBOUND(Array)), Element-1)
    '-- Insert new element
      M.Write(Value)
    '-- Save rest of elements
      M.SaveArray(Array(Element), UBOUND(Array) - Element)
      M.Position = 0
    '-- Retrieve them
      M.LoadArray(Array(LBOUND(Array)), UBOUND(Array)+1)
     END SUB


     DIM A(1 TO 100) AS LONG

     A(1) = 10
     A(2) = 20
     A(3) = 30
     A(4) = 40
     A(5) = 50
     A(6) = 60

     ArrayInsert(A, 3, 99)   '-- Insert value 99 in array A at element 3

     FOR I = 1 TO 7
      PRINT A(I)
     NEXT

     PRINT: PRINT "Press any key to continue..."
     DO: LOOP UNTIL INKEY$<>""
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:40:18