September 26, 2022, 12:26:55 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Loading a file into the grid

Started by RitchieF, November 25, 2014, 04:46:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RitchieF

SUB DoFillAfterLoad
for xx = 1 to linecount 'rows
for yy = 1 to len(CelticLine[xx])'columns
'IWG_DeleteCell(main,502,xx,yy)
'IWG_InitCellDat(main,502, xx, yy," ")
IWG_SetCellDat(main,502, xx, yy,MID$(CelticLine[xx], yy, 1))
next yy
next xx
ENDSUB


Larry,
executing the above code even with the rem'd lines unrem'd doesn't fill the grid starting at row1,column1 but appends the second file behind the first.
What's wrong?

Thanks,
Richard

LarryMc

I need to see how /what you load into the CelticLine[xx] array.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

This is my Load code
SUB DoLoad
for rr = 1 to IWG_GetRows(main, 502)
CelticLine[rr] =""
next rr
        linecount = 0
filename = filerequest("Load File",main,1)
IF(OPENFILE(CelticFile,filename,"R") = 0)
'--------------------------------------------------------
Do :
IF(READ(CelticFile,ln[x]) = 0)
linenum = linenum+1
CelticLine[linenum]=ln[x]
ENDIF
Until EOF(CelticFile)
linecount = linenum
'--------------------------------------------------------
CLOSEFILE CelticFile
   'PRINT "File read successfully!"
ELSE
   'PRINT "File not found!"
ENDIF


Richard

LarryMc

I'm not seeing what the problem.
Hate to be a bother but can you rig me up a test program with just thee code you have shown me and the file you are reading so I can do some testing.
Email it to me if you like.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

RitchieF

Larry,
I'm using an array in my code and didn't care for the index is zero based .
Sorry for the hazzle!

Richard

LarryMc

this is the only places I made changes and it works fine:

SUB DoLoad
for rr = 1 to IWG_GetRows(main, 502)
CelticLine[rr] =""
next rr
    linecount = 0
filename = filerequest("Load File",main,1)
linenum = 0 '<===========this missing caused the addon @ row 13
IF(OPENFILE(CelticFile,filename,"R") = 0)
'--------------------------------------------------------
Do :
IF(READ(CelticFile,ln[x]) = 0)
'count lines
linenum = linenum+1
'store line in new array element
CelticLine[linenum]=ln[x]
ENDIF
Until EOF(CelticFile)
linecount = linenum
'--------------------------------------------------------
CLOSEFILE CelticFile
'PRINT "File read successfully!"
ELSE
   'PRINT "File not found!"
ENDIF
RETURN
ENDSUB


SUB DoFillAfterLoad
'<====== and I cleaned this up to just what you need==================
IWG_DeleteAllCells(main,  502)
for xx = 1 to linecount 'rows
for yy = 1 to len(CelticLine[xx])'columns
IWG_InitCellDat(main,502, xx, yy," ")
IWG_SetCellDat(main,502, xx, yy,MID$(CelticLine[xx], yy, 1))
next yy
next xx
ENDSUB

it doesn't matter if you start at 0 or 1 as long as your array is define big enough and you are consistent where you start

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library