CTX library BigJohnArscott.com to BigJohn (problems not solved for import) " Exception at line 2026"

modified file you tell me

*questions°

1e ? where can I download new pdf file ctx7
2e ? I change the file doesn't I don't see any entries in the table.
I get error
3e ? How can I write this file to 2D array
(find out what is in array$(,) )
so I can find out every entrie.

Exception 2001 caused at line 2026 in -ct_table_readfile; entering immediate mode.
Type "continue" or click on default output window to exit immediate mode

error
Subscript out of bounds(2001) 2026 in ct_table_readfile,43 in Main program

error in this file
CALL CT_Table_ReadFile(ct16,s$,"","")

whats wrong

REM: CTX DATA TABLE DEMO PROGRAM
option nolet
! change these library paths to suit
REM: change the pathnames to suit
LIBRARY "D:\prog\TB Gold\TBLibs\ctx7\CTX7.trc"
LIBRARY "D:\prog\TB Gold\TBLibs\ctx7\truectrl.trc"

DECLARE PUBLIC CTbx

DIM pw(6)
DIM array$(0:25,7)

CALL TC_init
CALL TC_setunitstopixels

REM: how big is the screen
CALL TC_getscreensize(lscr,rscr,bscr,tscr)
LET midxscr=int((lscr+rscr)/2) ! mid x axis
LET midyscr=int((tscr+bscr)/2) ! mid y axis

REM: create a working window
CALL TC_win_create(progwin,"TITLE|CLOSE",midxscr-300,midxscr+320,midyscr+210,midyscr-190)

CALL TC_pushbtn_create(pw(6),"Exit Demo",250,370,380,360)
CALL TC_pushbtn_create(pw(1),"Remove",160,240,380,360)
CALL TC_pushbtn_create(pw(2),"Insert",70,150,380,360)
CALL TC_pushbtn_create(pw(3),"Order",380,460,380,360)
CALL TC_pushbtn_create(pw(4),"Format",470,550,380,360)

CALL TC_show(progwin)
CALL TC_win_switch(progwin)

REM: set title for window
CALL TC_Win_SetTitle (progwin,"Demo Data Table")
REM: set background color gray
CALL TC_win_setbrush(progwin,7,7,"SOLID")
CLEAR
CALL TC_show(pw(6))
s$="D:\prog\TB Gold\Book1.csv"
CALL CT_Table_ReadFile(ct16,s$,"","")
LET option$="VSCROLL|HSCROLL|RECESS|VRULE|HRULE"
CALL CT_Table_create(ct16,option$,50,550,340,20)
CALL CT_Table_setcolor(ct16,-1,20,4,0,22,21)
CALL CT_setfont(ct16,"Arial",8,"plain")
CALL CT_Table_WriteFile(ct16,s$,"","")
CALL CT_show(ct16)

REM: create event loop

DO

CALL CT_event(event$,window,x1,x2,id,type)
IF event$="KEYPRESS" and x1=335 then
LET CTbx=1
END IF

IF event$ = "HIDE" then ! close window button has been pressed
IF window=0 or window=progwin then
EXIT DO
END IF

ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF

ELSEIF event$="SINGLE" then

IF type=7 then ! must be data table
REM: remember id
LET tableID=id
END IF

ELSEIF event$="CONTROL DESELECTED" then

IF x2=pw(6) then ! push button has been pressed
EXIT DO
ELSEIF x2=pw(1) then ! remove
CALL CT_Table_RemoveData(tableid,0,datarow$)

ELSEIF x2=pw(2) then ! insert
CALL CT_Table_InsertData(tableid,0,datarow$)

ELSEIF x2=pw(3) then ! order strings alphabetically
REM: method 1=alphabetic A-Z
REM: method 2=reverse alph Z-A
REM: method 3=ascii & numeric ascending
REM: method 4=reverse ascii & numeric descending

CALL CT_Table_DataOrder(tableid,0,1)

ELSEIF x2=pw(4) then ! format numbers
CALL CT_Table_DataFormat(tableid,0,"#########")

END IF
END IF

LET x1=0
LET x2=0

LOOP

CALL TC_cleanup

END
//////////////////////////////////////////////////////////////////////////////////////////////////
file
BOOk1.csv

Surname,First name,Middle name,Gender,UPN,DoB,Class

Comments

DataOrder

Hi Peter,

In the code you have created a data table object:
CALL CT_Table_create(ct16,option$,50,550,340,20)
The data table object ID = ct16

Later in the program you have used:
CALL CT_Table_DataOrder(tableid,0,1)

You must tell the program what tableid is, e.g.
CALL CT_Table_DataOrder(ct16,0,1)

You will then find that the DataOrder routine works.

Regards
Big John

CTX table object

Hi Peter,

You have used CALL CT_Table_WriteFile(ct16,s$,"","")

This is incorrect. You must use:
CALL CT_Table_ReadFile(ct16,s$,"","")

Readfile means you are reading an external file and putting the contents into the data table.

WriteFile means you are copying the contents of the data table and writing the contents to a file.

Regards
Big John

thanks a lot

thanks a lot