5.62 beta 2 Preference`s write broken

Post bugs related to the IDE here
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

5.62 beta 2 Preference`s write broken

Post by Zebuddi123 »

windows pro 10 x64 (PB 5.62 - Beta 2) Preference`s lib Broken.

Not writing to prefs file. Works with x64 - 5.61 Can anyone else confirm ? Please.

Zebuddi.

1. WritePreferenceString()
2. WritePreferenceInteger()
3. WritePreferenceInteger()

Test code. "PureLust`s Dynamic Dialog --- Indentation-Injector "

Code: Select all

; Indentation-Injector - Litte Prog to add some Indentation-Keywords to your PureBasic-Preference File

; have a look at the DataSection below, to see which commands will be injected into your indentation-settings

; HINT:  You need to exit the PureBasic IDE BEFORE you start this tools.
;        otherwise the IDE will overwrite the changes on exit.

EnableExplicit

Procedure.s GetSpecialFolder(folderno)
	CompilerIf #PB_Compiler_OS = #PB_OS_Windows
		Protected listptr=0
		Protected result$=Space(270)
		SHGetSpecialFolderLocation_(0,folderno,@listptr) 
		SHGetPathFromIDList_(listptr,@result$) 
		ProcedureReturn Trim(result$)
	CompilerEndIf
EndProcedure

Structure	KeyWords
	KeyWord$
	Before.l
	After.l
EndStructure

Define	PBConfigPath$, PBConfigFile$, n

PBConfigPath$= GetSpecialFolder(26)+"\PureBasic\"

PBConfigFile$ = OpenFileRequester("Please select your PureBasic-Preference File", PBConfigPath$, "PureBasic Preference File| PureBasic.prefs|All Files|*.*", 0)

If PBConfigFile$ > "" And FileSize(PBConfigFile$) > 0
	If OpenPreferences(PBConfigFile$)
		Debug PBConfigFile$
		PreferenceGroup("Indentation")
		
		NewList KeyList.KeyWords()
		Define Number = ReadPreferenceInteger("NbKeywords",0)
		
		If Number < 1			; Maybe wrong Preference-File Version
			MessageRequester("ERROR", "No Keywords found."+#LF+"Maybe wrong Preference-File Version.")
			End
		EndIf
		
		; =====  Read List with existing KeyWords from PureBasic Preference-File
		
		For n = 0 To Number-1
			AddElement(KeyList())
			With KeyList()
				
				\KeyWord$	= ReadPreferenceString("Keyword_"+Str(n),"")
				\Before		= ReadPreferenceInteger("Before_"+Str(n),-999)
				\After		= ReadPreferenceInteger("After_"+Str(n),-999)
				
				If \KeyWord$ = "" Or \Before < -990 Or \After < -990
					MessageRequester("ERROR", "Suspicious Data found while trying to read Keyword:"+Str(n)+#LF+#LF+"Maybe wrong Preference-File Version.")
					End
				EndIf
				
			EndWith
		Next
		
		Define NewKeyWord$, NewBefore, NewAfter
		
		; =====  Read Data for new KeyWords, check if they already exist, and if not - add them to the KeyWord-List
		
		Restore Indentation_DynamicDialog_withSuffix
		
		Read.s	NewKeyWord$
		Read.l	NewBefore
		Read.l	NewAfter
			
		While NewBefore + NewAfter > -1900
			
			Repeat	; Dummy-Loop, just to use Break to exit it
				
				With KeyList()
					
					ForEach KeyList()
						If UCase(\KeyWord$) = UCase(NewKeyWord$)
							Break 2		; KeyWord already exists - do not change any settings
						EndIf
					Next
					
					AddElement(KeyList())			; Add new Keyword and Indentation to KeyWord-List
					
					\KeyWord$	= NewKeyWord$
					\Before		= NewBefore
					\After		= NewAfter
					
				EndWith							
					
			Until #True
			
			Read.s	NewKeyWord$
			Read.l	NewBefore
			Read.l	NewAfter
			
		Wend
	
		; =====  Write updated KeyWord-List to PureBasic Preference-File
		
		WritePreferenceInteger("NbKeywords",ListSize(KeyList()))
		
		ForEach KeyList()
			Debug "Keyword_"+Str(ListIndex(KeyList())) + " " + KeyList()\KeyWord$ + " " + KeyList()\Before + " " + KeyList()\After  ;Zebuddi
			WritePreferenceString("Keyword_"+Str(ListIndex(KeyList()))	, KeyList()\KeyWord$)
			WritePreferenceInteger("Before_"+Str(ListIndex(KeyList()))	, KeyList()\Before)
			WritePreferenceInteger("After_"+Str(ListIndex(KeyList()))	, KeyList()\After)
		Next
		
		MessageRequester("PureBasic Preference-File Updated",Str(ListSize(KeyList())-Number)+" Indentation-Keys have been added to your Preference-File." +
		                                                     #CRLF$+#CRLF$+"You have to close the IDE BEFORE you start this program to make these changes permanent.")
		ClosePreferences()
	EndIf
EndIf

DataSection
	
	Indentation_DynamicDialog_withSuffix:
	
	Data.s	"Dialogs__"			:	Data.l	0,	1		; ===== XML-Layout Elements
	Data.s	"Window__"			:	Data.l	0,	1
	Data.s	"vBox__"			:	Data.l	0,	1
	Data.s	"hBox__"			:	Data.l	0,	1
	Data.s	"GridBox__"			:	Data.l	0,	1
	Data.s	"MultiBox__"		:	Data.l	0,	1
	Data.s	"SingleBox__"		:	Data.l	0,	1
	
	Data.s	"Container__"		:	Data.l	0,	1		; ===== PuraBasic Container-Elements
	Data.s	"Frame__"			:	Data.l	0,	1
	Data.s	"Panel__"			:	Data.l	0,	1
	Data.s	"Tab__"				:	Data.l	0,	1
	Data.s	"ScrollArea__"		:	Data.l	0,	1
	Data.s	"Splitter__"		:	Data.l	0,	1
	
	Data.s	"EndDialogs__"		:	Data.l	-1,	0		; ===== Close-Nodes
	Data.s	"EndWindow__"		:	Data.l	-1,	0
	Data.s	"EndVBox__"			:	Data.l	-1,	0
	Data.s	"EndHBox__"			:	Data.l	-1,	0
	Data.s	"EndGridBox__"		:	Data.l	-1,	0
	Data.s	"EndMultiBox__"		:	Data.l	-1,	0
	Data.s	"EndSingleBox__"	:	Data.l	-1,	0
	Data.s	"EndContainer__"	:	Data.l	-1,	0
	Data.s	"EndFrame__"		:	Data.l	-1,	0
	Data.s	"EndPanel__"		:	Data.l	-1,	0
	Data.s	"EndTab__"			:	Data.l	-1,	0
	Data.s	"EndScrollArea__"	:	Data.l	-1,	0
	Data.s	"EndSplitter__"		:	Data.l	-1,	0
	Data.s	"EndNode__"			:	Data.l	-1,	0
	Data.s	"CloseNode__"		:	Data.l	-1,	0
	
	Data.s	"_NoMoreKeys_"		:	Data.l -999,-999
	
EndDataSection
malleo, caput, bang. Ego, comprehendunt in tempore
deeproot
Enthusiast
Enthusiast
Posts: 269
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: 5.62 beta 2 Preference`s write broken

Post by deeproot »

Not sure what is going on here - didn't use the test code above as not wishing to mess with my PB prefs file.

However, I use WritePreferenceString() and WritePreferenceInteger() a lot and I cannot see any problems here. The preference values for my program are all being saved correctly.

Using - Windows 7 x64 and PB 5.62 Beta 2
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: 5.62 beta 2 Preference`s write broken

Post by PureLust »

Zebuddi123 wrote:Not writing to prefs file. Works with x64 - 5.61 Can anyone else confirm ?
...
Test code. "PureLust`s Dynamic Dialog --- Indentation-Injector "
Did you take account of the hint?

Code: Select all

; HINT:  You need to exit the PureBasic IDE BEFORE you start this tools.
;        otherwise the IDE will overwrite the changes on exit.
The IDE has to be closed, otherwise the pref will not be written correctly.

Greets, PL.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Post Reply