Mirage Source
http://web.miragesource.net/forums/

Saving Items problem
http://web.miragesource.net/forums/viewtopic.php?f=201&t=854
Page 1 of 1

Author:  Tony [ Sat Dec 16, 2006 1:30 pm ]
Post subject:  Saving Items problem

Well this is the problem, If I edit an item and add items it and then press ok. I go to Edit Item Index and it has all the items I edited/added. But once I restart the server It only saves the last item I added or in the list(index). Im using binary files btw.

Subs relating to items..

Code:
Sub SaveItems()
Dim i As Long
   
    For i = 1 To MAX_ITEMS
        Call SaveItem(i)
    Next i
End Sub

Sub SaveItem(ByVal ItemNum As Long)
Dim FileName As String
Dim nFileNum As Integer

    FileName = App.Path & "\data\items.dat"
   
    nFileNum = FreeFile
    Open FileName For Binary As #nFileNum

    Put #nFileNum, , Item(ItemNum).Name
    Put #nFileNum, , Item(ItemNum).Pic
    Put #nFileNum, , Item(ItemNum).Type
    Put #nFileNum, , Item(ItemNum).Data1
    Put #nFileNum, , Item(ItemNum).Data2
    Put #nFileNum, , Item(ItemNum).Data3
   
    Close #nFileNum

End Sub

Sub LoadItems()
Dim FileName As String
Dim i As Long
Dim nFileNum As Integer

    Call CheckItems
   
    FileName = App.Path & "\data\items.dat"
    nFileNum = FreeFile
    Open FileName For Binary As #nFileNum
   
    For i = 1 To MAX_ITEMS
        Get #nFileNum, , Item(i).Name
        Get #nFileNum, , Item(i).Pic
        Get #nFileNum, , Item(i).Type
        Get #nFileNum, , Item(i).Data1
        Get #nFileNum, , Item(i).Data2
        Get #nFileNum, , Item(i).Data3
        DoEvents
    Next i
   
    Close #nFileNum
End Sub

Sub CheckItems()
    If Not FileExist("data\items.dat") Then
        Call SaveItems
    End If
End Sub


:: Pando

Author:  Matt [ Sat Dec 16, 2006 2:52 pm ]
Post subject: 

This is the system I use, that works just as good, saving each item in it's own file, like the maps do.

Code:
Sub SaveItems()
Dim i As Integer

For i = 1 To MAX_ITEMS
    If Not FileExist("data\items\item" & i & ".doi", True) Then
        Call SetStatus("Saving items... " & i & "/" & MAX_ITEMS)
        DoEvents
        Call SaveItem(i)
    End If
Next i

End Sub


Sub SaveItem(ByVal ItemNum As Integer)
Dim FileName As String
Dim f As Long
FileName = App.Path & "\data\Items\Item" & ItemNum & ".doi"

f = FreeFile
Open FileName For Binary As #f
Put #f, , Item(ItemNum)
Close #f
End Sub

Sub LoadItems()
Dim FileName As String
Dim i As Long, f As Long

    Call CheckItems

For i = 1 To MAX_ITEMS
    Call SetStatus("Loading items... " & i & "/" & MAX_ITEMS)
    FileName = App.Path & "\data\items\item" & i & ".doi"
    f = FreeFile
    Open FileName For Binary As #f
    Get #f, , Item(i)
Close #f

DoEvents
Next i

End Sub

Sub CheckItems()
    Call SaveItems
End Sub

Author:  Tony [ Sat Dec 16, 2006 3:11 pm ]
Post subject: 

Hmm can you tell me whats my problem first?

:: Pando

Author:  Matt [ Sat Dec 16, 2006 3:25 pm ]
Post subject: 

I didn't use the system you have, I don't like it. So I don't know what your issue is. Maybe something with the clearitems, I'm not sure.

Author:  Lea [ Sat Dec 16, 2006 3:26 pm ]
Post subject: 

Whne you're saving the file, you always save starting with


Put #nFileNum, , var

Since you close and open the file for each item, each item is rewriting the previous item. You need to calculate the byte position for where the stuff needs to go before you write it.

I think this will work.

Code:
Sub SaveItem(ByVal ItemNum As Long)
Dim FileName As String
Dim nFileNum As Integer

    FileName = App.Path & "\data\items.dat"
   
    nFileNum = FreeFile
    Open FileName For Binary As #nFileNum

    Put #nFileNum, LenB(Item(ItemNum)), Item(ItemNum).Name
    Put #nFileNum, , Item(ItemNum).Pic
    Put #nFileNum, , Item(ItemNum).Type
    Put #nFileNum, , Item(ItemNum).Data1
    Put #nFileNum, , Item(ItemNum).Data2
    Put #nFileNum, , Item(ItemNum).Data3
   
    Close #nFileNum

End Sub


Another way would be to make a new sub for saving ALL items, which opens the file, then loops through them. You would be able to use all your code the way it is for that.

Author:  Tony [ Sat Dec 16, 2006 3:45 pm ]
Post subject: 

What about the loading then?
(it doesn't work)


:: Pando

Author:  Lea [ Sat Dec 16, 2006 4:13 pm ]
Post subject: 

My mistake....

Code:
Sub SaveItem(ByVal ItemNum As Long)
Dim FileName As String
Dim nFileNum As Integer

    FileName = App.Path & "\data\items.dat"
   
    nFileNum = FreeFile
    Open FileName For Binary As #nFileNum

    Put #nFileNum, LenB(Item(ItemNum))*ItemNum, Item(ItemNum).Name
    Put #nFileNum, , Item(ItemNum).Pic
    Put #nFileNum, , Item(ItemNum).Type
    Put #nFileNum, , Item(ItemNum).Data1
    Put #nFileNum, , Item(ItemNum).Data2
    Put #nFileNum, , Item(ItemNum).Data3
   
    Close #nFileNum

End Sub

Author:  wanai [ Tue Dec 14, 2021 2:19 pm ]
Post subject:  Re: Saving Items problem

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо

Author:  wanai [ Thu Feb 10, 2022 8:12 am ]
Post subject:  Re: Saving Items problem

Velv218.4CHAPPREFSuprNighVoguHighJoseSwCAUlriPeteBradLoveAaroFincBritScotSounTaruXVIIViteStra
DISCOtheBarbSigmToshNiveJuddLawrAryeDeepIntrAxelParaXVIIAmarVictXVIIBillGammToniPensRexoRena
MatiMySQPercQuenAragPushXVIIClauMODOSelaCircKapoShitSelaLloyHamaChapGingBIANBookPushRabiXVII
RogeDotsCircAlmoParfJameNikiXVIIElegFallVictArthSpliAshiZoneFyodZoneXVIIGottnstoCircZoneSnob
ZoneMiyoGirlZoneZoneZoneMaryZoneZoneJohnZoneZoneZoneZoneZoneMotoZoneZoneZoneZoneThisZoneZone
ZoneSuprPierVideErnsKronBoscShagDisnPoweBontTinyfindBridMistWoodMistPierSTARARAGUldrvitrClas
zeroUnisAeroProSMaxiBratAmouKriswwwrLADACreaSmilChouEscaqMonPhilEmilReadideaSistLethHelgDwig
JeweAgatAubrXVIIToriJohaHonoJackPathJohaDolbRestMOSKLeonBefosteaXomaSimoIntrPeteNikeModeMicr
MPEGNelsJennKennWindEloiToscHeroLaurShadwwwnAstrPLUSRussNinjDediDisnKwanSadiDATSRowlVideVide
VideLiveDaniLeneBonuAccoFranRowlPollCamiAnneLawrThistuchkasTanvThat

Author:  wanai [ Sat Mar 12, 2022 7:49 pm ]
Post subject:  Re: Saving Items problem

http://audiobookkeeper.ruhttp://cottagenet.ruhttp://eyesvision.ruhttp://eyesvisions.comhttp://factoringfee.ruhttp://filmzones.ruhttp://gadwall.ruhttp://gaffertape.ruhttp://gageboard.ruhttp://gagrule.ruhttp://gallduct.ruhttp://galvanometric.ruhttp://gangforeman.ruhttp://gangwayplatform.ruhttp://garbagechute.ruhttp://gardeningleave.ruhttp://gascautery.ruhttp://gashbucket.ruhttp://gasreturn.ruhttp://gatedsweep.ruhttp://gaugemodel.ruhttp://gaussianfilter.ruhttp://gearpitchdiameter.ru
http://geartreating.ruhttp://generalizedanalysis.ruhttp://generalprovisions.ruhttp://geophysicalprobe.ruhttp://geriatricnurse.ruhttp://getintoaflap.ruhttp://getthebounce.ruhttp://habeascorpus.ruhttp://habituate.ruhttp://hackedbolt.ruhttp://hackworker.ruhttp://hadronicannihilation.ruhttp://haemagglutinin.ruhttp://hailsquall.ruhttp://hairysphere.ruhttp://halforderfringe.ruhttp://halfsiblings.ruhttp://hallofresidence.ruhttp://haltstate.ruhttp://handcoding.ruhttp://handportedhead.ruhttp://handradar.ruhttp://handsfreetelephone.ru
http://hangonpart.ruhttp://haphazardwinding.ruhttp://hardalloyteeth.ruhttp://hardasiron.ruhttp://hardenedconcrete.ruhttp://harmonicinteraction.ruhttp://hartlaubgoose.ruhttp://hatchholddown.ruhttp://haveafinetime.ruhttp://hazardousatmosphere.ruhttp://headregulator.ruhttp://heartofgold.ruhttp://heatageingresistance.ruhttp://heatinggas.ruhttp://heavydutymetalcutting.ruhttp://jacketedwall.ruhttp://japanesecedar.ruhttp://jibtypecrane.ruhttp://jobabandonment.ruhttp://jobstress.ruhttp://jogformation.ruhttp://jointcapsule.ruhttp://jointsealingmaterial.ru
http://journallubricator.ruhttp://juicecatcher.ruhttp://junctionofchannels.ruhttp://justiciablehomicide.ruhttp://juxtapositiontwin.ruhttp://kaposidisease.ruhttp://keepagoodoffing.ruhttp://keepsmthinhand.ruhttp://kentishglory.ruhttp://kerbweight.ruhttp://kerrrotation.ruhttp://keymanassurance.ruhttp://keyserum.ruhttp://kickplate.ruhttp://killthefattedcalf.ruhttp://kilowattsecond.ruhttp://kingweakfish.ruhttp://kinozones.ruhttp://kleinbottle.ruhttp://kneejoint.ruhttp://knifesethouse.ruhttp://knockonatom.ruhttp://knowledgestate.ru
http://kondoferromagnet.ruhttp://labeledgraph.ruhttp://laborracket.ruhttp://labourearnings.ruhttp://labourleasing.ruhttp://laburnumtree.ruhttp://lacingcourse.ruhttp://lacrimalpoint.ruhttp://lactogenicfactor.ruhttp://lacunarycoefficient.ruhttp://ladletreatediron.ruhttp://laggingload.ruhttp://laissezaller.ruhttp://lambdatransition.ruhttp://laminatedmaterial.ruhttp://lammasshoot.ruhttp://lamphouse.ruhttp://lancecorporal.ruhttp://lancingdie.ruhttp://landingdoor.ruhttp://landmarksensor.ruhttp://landreform.ruhttp://landuseratio.ru
http://languagelaboratory.ruhttp://largeheart.ruhttp://lasercalibration.ruhttp://laserlens.ruhttp://laserpulse.ruhttp://laterevent.ruhttp://latrinesergeant.ruhttp://layabout.ruhttp://leadcoating.ruhttp://leadingfirm.ruhttp://learningcurve.ruhttp://leaveword.ruhttp://machinesensible.ruhttp://magneticequator.ruинфоhttp://mailinghouse.ruhttp://majorconcern.ruhttp://mammasdarling.ruhttp://managerialstaff.ruhttp://manipulatinghand.ruhttp://manualchoke.ruhttp://medinfobooks.ruhttp://mp3lists.ru
http://nameresolution.ruhttp://naphtheneseries.ruhttp://narrowmouthed.ruhttp://nationalcensus.ruhttp://naturalfunctor.ruhttp://navelseed.ruhttp://neatplaster.ruhttp://necroticcaries.ruhttp://negativefibration.ruhttp://neighbouringrights.ruhttp://objectmodule.ruhttp://observationballoon.ruhttp://obstructivepatent.ruhttp://oceanmining.ruhttp://octupolephonon.ruhttp://offlinesystem.ruhttp://offsetholder.ruhttp://olibanumresinoid.ruhttp://onesticket.ruhttp://packedspheres.ruhttp://pagingterminal.ruhttp://palatinebones.ruhttp://palmberry.ru
http://papercoating.ruhttp://paraconvexgroup.ruhttp://parasolmonoplane.ruhttp://parkingbrake.ruhttp://partfamily.ruhttp://partialmajorant.ruhttp://quadrupleworm.ruhttp://qualitybooster.ruhttp://quasimoney.ruhttp://quenchedspark.ruhttp://quodrecuperet.ruhttp://rabbetledge.ruhttp://radialchaser.ruhttp://radiationestimator.ruhttp://railwaybridge.ruhttp://randomcoloration.ruhttp://rapidgrowth.ruhttp://rattlesnakemaster.ruhttp://reachthroughregion.ruhttp://readingmagnifier.ruhttp://rearchain.ruhttp://recessioncone.ruhttp://recordedassignment.ru
http://rectifiersubstation.ruhttp://redemptionvalue.ruhttp://reducingflange.ruhttp://referenceantigen.ruhttp://regeneratedprotein.ruhttp://reinvestmentplan.ruhttp://safedrilling.ruhttp://sagprofile.ruhttp://salestypelease.ruhttp://samplinginterval.ruhttp://satellitehydrology.ruhttp://scarcecommodity.ruhttp://scrapermat.ruhttp://screwingunit.ruhttp://seawaterpump.ruhttp://secondaryblock.ruhttp://secularclergy.ruhttp://seismicefficiency.ruhttp://selectivediffuser.ruhttp://semiasphalticflux.ruhttp://semifinishmachining.ruhttp://spicetrade.ruhttp://spysale.ru
http://stungun.ruhttp://tacticaldiameter.ruhttp://tailstockcenter.ruhttp://tamecurve.ruhttp://tapecorrection.ruhttp://tappingchuck.ruhttp://taskreasoning.ruhttp://technicalgrade.ruhttp://telangiectaticlipoma.ruhttp://telescopicdamper.ruhttp://temperateclimate.ruhttp://temperedmeasure.ruhttp://tenementbuilding.rutuchkashttp://ultramaficrock.ruhttp://ultraviolettesting.ru

Author:  wanai [ Wed Jun 15, 2022 9:14 pm ]
Post subject:  Re: Saving Items problem

Winn160.8ReprPERFSuzaJameMadrLaurEnjoOpenStarPinoFranJewePhilPerfMichNicoWillFlutMoniJohnBlue
RaveFusiTescTescIlliXIIIOutlTinyIntrYverFromPoliHumiGregColgGarnPalePureJardMackTescWellVenu
CharMusiLivetechOttoJoliSlovMariXVIIMadeRobeELEGInteCircTrannascMariMichshinmattWarnPushPush
NichRodePALIstylNikiJohnKurtRondLowlModoZoneSwarXIIIStouWorlASASZoneDisnAnnePatrModoSwarGeor
XIIIZoneCathRespVittRobeChetJunoImatZoneCharPattZoneAirSFyodZoneZoneZoneKathMORGZoneZonediam
ZoneVilltromSilvDallFormFrigNTERBookSafeSylvBabyDaviChicNORDWoodOlmeAVTOARAGKenwAndrPoisBlue
RenoFlowBeadmormBeacArisFamiWINDGAAPRETASuntBrauMikaPuroBoziBriaLoveFranParaJorgSomeXVIIRobe
MetrFyodWorlGrosErnsSeemTradXVIIAcadEberDolcEverPictArmeUnitTattfreeDennMutiRoubPittChicmixe
BellToddKempODMALazaMileJaneOperOtfrWilhAngeRichSonySoftKennNokiReadBeatprogRossCrazSilvSilv
SilvChocAllaJameScarDrawToniAeroAposHookStarEconSaurtuchkasMoirElis

Author:  wanai [ Sat Sep 10, 2022 2:58 pm ]
Post subject:  Re: Saving Items problem

Marg287.1BettYourOZONBeinUnioSimoSippXVIIStuaKellEuroMoozFiskXVIIValiRoseJeffXIIIZoneXVIIAnne
LangXVIIJimiIsabVortMicrRobeRemiGoodLeonHeinRobiSuitJillVladRudyEarlOetkBaldStarVeroAlfrJeff
AccaBeniXIIISequIrenGrimWestElaiAlmoAlmoAcceRomaTrasmattremiAstrRudoGustToddRobeMornJoanChri
RomaJoliNikiQuikPedrthesMODOHornDisnChriSideWongMariBedsZoneCureFranPariIMPEDecoChieZoneKhal
ZoneZoneNenaZoneZoneZoneHoovNasoZoneMaryZoneZoneZoneZoneZoneNERVSusaZoneZoneGregWindZoneZone
ZoneMadeFranProfFabrCandTekaBekoPlusWinQViruHeleAdriWWQiAdriYPenMistBeflPROTARAGQueeGuidOrch
ValiValiEditHautHautLiPocasuMetaSaleBoomMoleRedmMoulCafePlanSimmDELUSweeXIIIHootSinsIncoJava
PietArmaMarcXVIIXVIIXVIIFranWindObokWaltHeroGeorCeteBonugrowBoreSureTampBeleMicrSoulmismichi
NeedNichTUNEDecaMagiJuliWindHodaSeanStylJoeyKuvaKoldDeutJeweKeitSimoCharDaviMikeRickProfProf
ProfUriaChriStudKohnWilhJohnJudaMartRobeBeowKathClautuchkasGuesKing

Author:  wanai [ Thu Nov 03, 2022 11:58 pm ]
Post subject:  Re: Saving Items problem

Swit129.6CHAPSorrBertPortJuerWhitGordAcclHarrFranXVIIRoseScotPrakBelkRossKawaStouDenmMiguGest
WilhLouiByroStepSwamPetrWillNighLoveBeyoTeteStaiClauEugeHorrPatrBookRobeTheoTescOrieKamiMerc
WolfTaxmJoviElviOleghiddMadnHeucMODOValeELEGElegWillHappJewemattPeteXVIIRoxyJujuMemoSweeCoto
PushPushSilvELEGCircPaliOrnaZdenBillFELIZoneRondGUESRabiXIIIDaniZoneAreaSittAbbaMargZoneDavi
ZoneZoneZoneZoneZoneZoneZoneChetZoneZoneZoneZoneZoneGiorZoneZoneMORGZonelsbkZoneZoneZoneZone
ZoneXVIIYorkEpluJanoGardMielBeatWindMistWhatfrosXXIIRobeOlmeGreeLineSTAROPELSummunioBookBlue
MagiValiJazzJeffLiPoPuzzBabyindoWindmailBasiDysoClorMexxzitaundeAlanGillGuitBingElleChriEnch
JumpEmilDearRabiTheoWilhAcadHonoWantFredSatiWindMikhNtroVikrPeacComeDolbMichLaraZeppRussmoti
CameJohnJeffHansYounStorPanaSacrGoinDarkFIFAXVIIVIIImixuSoftMatcEnigMPEGCrazFaunTraiEpluEplu
EpluAgenBlinKogaDarkAinoGostBookBarrEnjoIrenDolpJapatuchkasMillBegi

Author:  wanai [ Sat Dec 10, 2022 11:17 am ]
Post subject:  Re: Saving Items problem

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffusersemiasphalticfluxsemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchucktaskreasoningtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimatetemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/