May 16, 2024, 01:44:21 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


How store file variable in Linked List

Started by aurelCB, January 20, 2011, 09:31:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

January 20, 2011, 09:31:20 AM Last Edit: January 20, 2011, 11:28:22 AM by aurelCB
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

LarryMc

January 20, 2011, 12:17:40 PM #1 Last Edit: January 20, 2011, 12:26:57 PM by Larry McCaughn
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

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

aurelCB

January 20, 2011, 12:44:42 PM #2 Last Edit: January 20, 2011, 12:48:31 PM by aurelCB
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