IonicWind Software

IWBasic => General Questions => Topic started by: aurelCB on January 20, 2011, 09:31:20 AM

Title: How store file variable in Linked List
Post by: aurelCB on January 20, 2011, 09:31:20 AM
Hi...
I want store file variable into linked list?
My linked list list for file looks like this:
'DEfine Linked List for FILE variable --------------------------------------------
TYPE fileType
   STRING fileName
   FILE fileValue
ENDTYPE
' create File List
fileList=ListCreate()
POINTER fileVar
SETTYPE fileVar,fileType


So i think that i set this list properly.
String variable fileName is not problem but FILE variable is ....
What i can use as fileValue ?

I create new int variable in list on this way:
intVar=ListAdd(intList,NEW(intType,1))
#intVar.intName=varName
#intvar.intValue=0
'-------------------------------------

 


So what add as filevariable value ?
Any help or suggestion are welcome....

all best...
Aurel
Title: Re: How store file variable in Linked List
Post by: LarryMc on January 20, 2011, 12:17:40 PM
Aurel
this part is correct:'DEfine Linked List for FILE variable --------------------------------------------
TYPE fileType
  STRING fileName
  FILE fileValue
ENDTYPE
' create File List
fileList=ListCreate()
POINTER fileVar
SETTYPE fileVar,fileType


to add a file entry I believe this is correct:
string fname="c:\\myfile\test.txt"
FILE mytest

fileVar=ListAdd(fileList,NEW(fileType,1))
#fileVar.fileName=fname
#fileVar.fileValue=mytest

IF OPENFILE(#fileVar.fileValue, #fileVar.fileName, "R") = 0


FILE and BFILE are really just pointers.

If you're going to use both types then instead of FILE in you TYPE definition you may need to make it a pointer and then derefence it with either #fileVar.#<FILE>fileValue or #fileVar.#<BFILE>fileValue orsomething like that,


LarryMc

Title: Re: How store file variable in Linked List
Post by: aurelCB on January 20, 2011, 12:44:42 PM
Quotestring fname="c:\\myfile\test.txt"
FILE mytest

fileVar=ListAdd(fileList,NEW(fileType,1))
#fileVar.fileName=fname
#fileVar.fileValue=mytest

IF OPENFILE(#fileVar.fileValue, #fileVar.fileName, "R") = 0

First ...thanks Larry on respond!
Yes i also think that is correct and i understand that filevariable is infact pointer.
#fileVar.fileValue is pointer of mytest which is file variable (read file pointer).

I will try create array of filevariables in global scope like:
FILE:fileVariable[100] for start...
then set each element of array with with counter

fileVar=ListAdd(fileList,NEW(fileType,1))
#fileVar.fileName=fname
count=count +1
#fileVar.fileValue=fileVariable[count]

This would probably work...
I will see...

Thanks again...
Aurel