IonicWind Software

IWBasic => IWGrid => IWGrid Issues => Topic started by: RitchieF on November 25, 2014, 04:46:24 PM

Title: Loading a file into the grid
Post by: RitchieF on November 25, 2014, 04:46:24 PM
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
Title: Re: Loading a file into the grid
Post by: LarryMc on November 25, 2014, 05:53:18 PM
I need to see how /what you load into the CelticLine[xx] array.
Title: Re: Loading a file into the grid
Post by: RitchieF on November 26, 2014, 01:53:55 AM
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
Title: Re: Loading a file into the grid
Post by: LarryMc on November 26, 2014, 09:22:17 AM
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
Title: Re: Loading a file into the grid
Post by: RitchieF on November 26, 2014, 12:37:24 PM
Larry,
I'm using an array in my code and didn't care for the index is zero based .
Sorry for the hazzle!

Richard
Title: Re: Loading a file into the grid
Post by: LarryMc on November 26, 2014, 12:59:22 PM
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