File Hadnling Once Again...

Blitz3D Forums/Blitz3D Beginners Area/File Hadnling Once Again...

File line 15 = "Gamma = 0.5" <- in the file
However I need to get the value 0.5 and put it in variable "Gamma_Num" and display it in the text field, but I need to able to change it, cause currently I can't get the variable and currently cant change the value in the text box, I got no clue what to do right now :|

Make ur explication simple so I can understand :D

AppTitle "Coalition Legions Game Commander"

	Global   fileopen  = False
	Global   Gamma_Num = 0

	Const    MAXLINES  = 127

	; Create Main Window
	w% = 300;GadgetWidth(Desktop()) - 100
	h% = 300;GadgetHeight(Desktop()) - 100
	x% = (ClientWidth(Desktop()) - w) / 2
	y% = (ClientHeight(Desktop()) - h) / 2
	wndMain = CreateWindow("               Coalition Legions Game Commander", x, y, w, h,0,17)
	

	
	ChildPanel = CreatePanel(2,20,280,220,wndMain,0)
	MainSlid   = CreateSlider(275+1,10,15,228,wndMain,2)
	SaveBut    = CreateButton("Save",5,250,60,20,wndMain)
	ExitBut    = CreateButton("Exit",70,250,60,20,wndMain)
	
	lab_Gamma  = CreateLabel("Gamma :",15,14,60,15,ChildPanel)
	txt_Gamma  = CreateTextField( 150,8,100,20,ChildPanel)
	CreatePanel(5,30,255,4,ChildPanel,1)
	;CreatePanel(135,5,4,255,ChildPanel,1)
	
		CreateLabox("Edit",2,7,270,230,30,1,wndMain)
	
	Dim dat$(MAXLINES)
	
	ReadCFG   = ReadFile ("dfv.cfg")
	linecount=0
	If  ReadCFG = 0 Then
		Notify "Unable to access the file needed!"
		End
	Else
		fileopen=True	
	End If
	;-------------------------
	; READ
	While Not Eof(ReadCFG)
		linecount=linecount+1
		dat$(linecount)=ReadLine(ReadCFG)
		If linecount=MAXLINES Exit 
	Wend
	CloseFile ReadCFG
	Gamma_Num = dat$(15)
	;------------------------
	CreateTimer(60)
quit=False
Repeat
	
	WaitEvent()
	; Close Window
	If EventID()=$803
            If EventSource()=wndMain
				quit=True
            End If
	EndIf
	; Always Ontop
	If EventID()=$4001
		ActivateWindow wndMain
		SetGadgetText txt_Gamma,Gamma_Num
	EndIf
	;
	If EventID()=$401
		If EventSource()=SaveBut ; CLICK SAVE BUTTON
			If fileopen=True
				ReadCFG=WriteFile("gamefile.txt")
				For i=1 To linecount
				WriteLine ReadCFG,dat$(i)
				Next
				CloseFile ReadCFG	
			EndIf
		EndIf
		If EventSource()=ExitBut ; CLICK EXIT BUTTON
			quit=True
		EndIf
	EndIf

Until quit

; LABOX CREATION CODE
Function CreateLabox(b_text$,b_x,b_y,b_width,b_height,lab_width,lab_style,b_parent)

	CreatePanel( b_x, b_y, b_width+3, 4, b_parent, 1)                          ; Top
	
	CreatePanel( b_x, b_y+2, 4, b_height, b_parent, 1)                         ; Left
	
	CreatePanel( b_x, b_y + b_height, b_width+4, 4, b_parent, 1)                          ; Bottom
	
	CreatePanel( b_x + b_width, b_y, 4, b_height+3, b_parent, 1)               ; Right
	
	CreateLabel( b_text$, b_x+10, b_y-6, lab_width, 16, b_parent, lab_style)         ; Text
End Function