Incrementing a String Value?

Post » Sun Jan 30, 2011 9:40 pm

I have a String Value "Item01", to be used with Pluggy's INIWrite___. This is for the Key part of the .ini file.

What I'd like to is write a script to go through every iteration between 1 and 1000-- I can make the Script do this fine, but actually updating the String is beyond me-- whatever I attempt just seems to stall the Script.

Is there a way to do something like :

SetString Key "Item"
AddToString Ticker

?
I've tried using IntToString, but that just seems to stall my Script, as the rest does not run, and StringCat does the same :S
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Sun Jan 30, 2011 12:49 pm

StringCat would be the one you want. Could you post the script you tried it with?
User avatar
Alisha Clarke
 
Posts: 3461
Joined: Tue Jan 16, 2007 2:53 am

Post » Sun Jan 30, 2011 1:45 pm

Unfortunately I do not have it-- I've been trying different things.

What I was trying was something akin to :

Long KeyLong ValToAddShort Ticker <-- A counter from 0 - 1000SetString Key "Item"IntToString ValToAdd TickerStringCat Key ValToAdd


This is the code I am currently trying:
	If ( DoCheck == 1 )		Set DoCheck to 0		Set ItemsInChest to ( ThisChest.GetNumItems )		Label 10		If ( Ticker < ItemsInChest )			Set File to CreateString -1 "CDM - Here Take This.ini"			Set Section to CreateString -1 "Chest 01"			Set Key to CreateString -1 "Item"			Set Dint to 0				IntToString ValToAdd Ticker			StringCat Key ValToAdd			Set Target to ThisChest.GetInventoryObject 0			IniWriteRef File Section Key Target			SetString Key "ItemCount01"			Set ItemCount to ( ThisChest.GetItemCount Target )			IniWriteInt File Section Key ItemCount			GoTo 10		EndIf		Message" Items Deposited..."	EndIf

User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Sun Jan 30, 2011 9:49 pm

Ticker is never set or changed here. The only lines with Ticker in it are
		If ( Ticker < ItemsInChest )...			IntToString ValToAdd Ticker

That could be the cause of the crash - if Ticker never changes this loop will run forever.


Then using StringCat would look something like
               ;set the File, Section, and Key outside of the loop - inside the loop would create new strings for every loop, which works but takes more memory than necessary)               set Ticker to 0                Label 10                If ( Ticker < ItemsInChest )                        set Target to ThisChest.GetInventoryObject Ticker                       set Ticker to (Ticker + 1) ;Sanity for the player, because most people don't think of the first item as item 0                       IntToString ValToAdd Ticker                       SetString Key "Item"                       StringCat Key ValToAdd

User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Sun Jan 30, 2011 9:24 am

Thanks, Haama-- I'll take a look to-morrow, and get back to you on how it goes :)

OK, I decided to test it tonight-- it works perfectly!! Thank you :D

But can I ask for al ittle bit more help?

This is my retrival code-- it doesn't seem to be working-- it says it has checked the Items, but no items are actually added to the chest...

	If ( GetGameLoaded )		ThisChest.RemoveAllItems		Set File to CreateString -1 "CDM - Here Take This\CDM - Here Take This.ini"		Set Section to CreateString -1 "Chest 01"		Set Key to CreateString -1 "Item"		Set Dint to 0		Set Ticker to 0 				Label 20		If ( Ticker < ItemsInChest )						Set Ticker to ( Ticker + 1 )			IntToString ValToAdd Ticker			SetString Key "Item"			StringCat Key ValToAdd			Set Target to IniReadRef File Section Key DInt			IntToString ValToAdd Ticker			SetString Key "ItemCount"			StringCat Key ValToAdd			Set ItemCount to IniReadInt File Section Key DInt2			ThisChest.AddItem Target ItemCount				GoTo 20		EndIf		Message" Items Loaded..."	EndIf

User avatar
Izzy Coleman
 
Posts: 3336
Joined: Tue Jun 20, 2006 3:34 am

Post » Sun Jan 30, 2011 7:16 am

The last parameter in your Set Target to IniReadRef File Section Key DInt line refers to the rootID, or which folder Pluggy looks for the ini. Since you have two different variables for IniReadRef and IniReadInt, I don't think that's what you meant to do. set Target to IniReadRef File Section Key should work for your purposes.

I would also try removing the space from the section name "Chest 01". I'm not sure if the Delphi Ini reader handles spaces properly.
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm


Return to IV - Oblivion