WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Arrays
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ArrayInsert Examples

 Keywords: ArrayInsert One Two 1 2 Dimension Array Insert Paste Append Row Column Element

;***************************************************************************
;**
;**   Insert an Element into a one Dimensional Array
;**
;***************************************************************************
strList = 'a b c A B C 1 0 -1'
value = 'D' ; (uppercase letter D)
; Create an array to Insert data
arrList = Arrayize( strList, ' ' )
; insert value in the array
result = ArrayInsert(arrList,6,1,value)
strNewList = ArrayToStr(arrList)
; Display results
Pause( 'ArrayInsert of value: ' : value, strNewList)
Exit


;***************************************************************************
;**
;**   Insert a Row into a two Dimensional Array
;**
;***************************************************************************
; Dynamically create a two dimensional array from CSV data
; using the FilePut & ArrayFilePutCSV trick
data = 'A0,A1,A2,A3':@LF:'B0,B1,B2,B3':@LF:'D0,D1,D2,D3':@LF:'E0,E1,E2,E3' ; missing row C
tmpfile = "tempfile.tmp"
FilePut( tmpfile, data )
arrA = ArrayFileGetCSV( tmpfile, 1)
FileDelete( tmpfile )

; Now insert a blank row into arrA
row = 2 ;third row
rowflag = 1
initval = ""
ArrayInsert( arrA, row, rowflag, initval )

; Define row data in an seperate 1 - dimensional array
newdata = 'C0,C1,C2,C3'
arrB = Arrayize( newdata, ',' )

; Insert arrB data into arrA
For element = 0 To ArrInfo( arrB, 1 )-1
    arrA[row,element] = arrB[element]
Next
; Display Results
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`ArrayInsert Row`
MyDialogX=002
MyDialogY=059
MyDialogWidth=438
MyDialogHeight=195
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`157,165,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`217,165,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`013,011,402,142,REPORTVIEW,"ReportView_1",arrA,DEFAULT,DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")
Exit


;***************************************************************************
;**
;**   Insert a column into a two Dimensional Array
;**
;***************************************************************************
; Dynamically create a two dimensional array from CSV data
; using the FilePut & ArrayFilePutCSV trick
data = 'A0,A1,A3':@LF:'B0,B1,B3':@LF:'C0,C1,C3':@LF:'D0,D1,D3' ; missing column 2
tmpfile = "tempfile.tmp"
FilePut( tmpfile, data )
arrA = ArrayFileGetCSV( tmpfile, 1)
FileDelete( tmpfile )

; Now insert a blank column into arrA
col = 2 ;third column
colflag = 2
initval = ""
ArrayInsert( arrA, col, colflag, initval )

; Define column data in an seperate 1 - dimensional array
newdata = 'A2,B2,C2,D2'
arrB = Arrayize(newdata, ',')
; Insert arrB data into arrA
For element = 0 To ArrInfo( arrB, 1 )-1
    arrA[element,col] = arrB[element]
Next

; Display Results
MyDialogFormat=`WWWDLGED,6.2`
MyDialogCaption=`ArrayInsert Row`
MyDialogX=002
MyDialogY=059
MyDialogWidth=438
MyDialogHeight=195
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0
MyDialog001=`157,165,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`217,165,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`013,011,402,142,REPORTVIEW,"ReportView_1",arrA,DEFAULT,DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ButtonPushed=Dialog("MyDialog")
Exit

Article ID:   W17656
Filename:   ArrayInsert Examples.txt
File Created: 2013:05:24:11:38:34
Last Updated: 2013:05:24:11:38:34