1. Bug or Error
- Posted by Lone_EverGreen_Ranger Sep 12, 2009
- 1121 views
Hey Guys,
What is wrong with my code, it runs fine, but when I go to execute it, it comes up with an error.
procedure SaveFile() fName = getSaveFileName(MainWin,file,FrostType) if length(fName) = 0 then return end if handle = open(fName,"wb") if handle = -1 then fn = message_box("Save File Error", "Save Error", MB_TASKMODAL) end if print(handle,HP) puts(handle,"\n") print(handle,Max_HP) puts(handle,"\n") print(handle,MP) puts(handle,"\n") print(handle,Max_MP) puts(handle,"\n") print(handle,Str) puts(handle,"\n") print(handle,Def) puts(handle,"\n") print(handle,Res) puts(handle,"\n") print(handle,Mag) puts(handle,"\n") print(handle,Spd) puts(handle,"\n") print(handle,Lvl) puts(handle,"\n") print(handle,Exp) puts(handle,"\n") print(handle,NeedExp) puts(handle,"\n") print(handle,Nxtlvl) puts(handle,"\n") print(handle,X) puts(handle,"\n") print(handle,Y) puts(handle,"\n") print(handle,Damage) puts(handle,"\n") print(handle,Max_Damage) puts(handle,"\n") print(handle,MagRes) puts(handle,"\n") print(handle,EleRes) puts(handle,"\n") print(handle,EleMag) puts(handle,"\n") print(handle,Min_Damage) puts(handle,"\n") print(handle,Items) puts(handle,"\n") print(handle,Money) puts(handle,"\n") print(handle,Ene_HP) puts(handle,"\n") print(handle,Ene_Max_HP) puts(handle,"\n") print(handle,Ene_MP) puts(handle,"\n") print(handle,Ene_Max_MP) puts(handle,"\n") print(handle,Ene_MP) puts(handle,"\n") print(handle,Ene_Max_MP) puts(handle,"\n") print(handle,Ene_Str) puts(handle,"\n") print(handle,Ene_Def) puts(handle,"\n") print(handle,Ene_Res) puts(handle,"\n") print(handle,Ene_Mag) puts(handle,"\n") print(handle,Ene_Spd) puts(handle,"\n") print(handle,Ene_EleMag) puts(handle,"\n") print(handle,Ene_MagRes) puts(handle,"\n") print(handle,Ene_EleRes) puts(handle,"\n") print(handle,Ene_X) puts(handle,"\n") print(handle,Ene_Y) puts(handle,"\n") print(handle,Ene_Money) puts(handle,"\n") print(handle,Ene_Exp) puts(handle,"\n") print(handle,Ene_Damage) puts(handle,"\n") print(handle,Ene_Max_Damage) puts(handle,"\n") print(handle,Ene_Min_Damage) puts(handle,"\n") print(handle,Ene_Items) puts(handle,"\n") print(handle,Item_Stock) puts(handle,"\n") print(handle,Hero_W) puts(handle,"\n") print(handle,Hero_H) puts(handle,"\n") print(handle,Enemy_W) puts(handle,"\n") print(handle,Enemy_H) puts(handle,"\n") print(handle,Boss_W) puts(handle,"\n") print(handle,Boss_H) puts(handle,"\n") print(handle,Vehicle_W) puts(handle,"\n") print(handle,Vehicle_H) puts(handle,"\n") print(handle,Item_W) puts(handle,"\n") print(handle,Item_H) puts(handle,"\n") print(handle,Element_W) puts(handle,"\n") print(handle,Element_H) puts(handle,"\n") print(handle,Attribute_W) puts(handle,"\n") print(handle,Attribute_H) puts(handle,"\n") print(handle,Npc_W) puts(handle,"\n") print(handle,Npc_H) puts(handle,"\n") print(handle,Weapon_W) puts(handle,"\n") print(handle,Weapon_H) puts(handle,"\n") --print(handle,Shop_W) --puts(handle,"\n") --print(handle,Shop_H) --puts(handle,"\n") print(handle,Attack_W) puts(handle,"\n") print(handle,Attack_H) puts(handle,"\n") print(handle,Spell_W) puts(handle,"\n") print(handle,Spell_H) puts(handle,"\n") print(handle,Skill_W) puts(handle,"\n") print(handle,Skill_H) puts(handle,"\n") print(handle,StatusEffect_W) puts(handle,"\n") print(handle,StatusEffect_H) puts(handle,"\n") print(handle,Backdrop_W) puts(handle,"\n") print(handle,Backdrop_H) puts(handle,"\n") print(handle,Summon_W) puts(handle,"\n") print(handle,Summon_H) puts(handle,"\n") print(handle,Dungeon_W) puts(handle,"\n") print(handle,Dungeon_H) puts(handle,"\n") print(handle,Class_W) puts(handle,"\n") print(handle,Class_H) puts(handle,"\n") print(handle,hero_x) puts(handle,"\n") print(handle,hero_y) puts(handle,"\n") print(handle,enemy_x) puts(handle,"\n") print(handle,enemy_y) puts(handle,"\n") print(handle,boss_x) puts(handle,"\n") print(handle,boss_y) puts(handle,"\n") print(handle,vehicle_x) puts(handle,"\n") print(handle,vehicle_y) puts(handle,"\n") print(handle,item_x) puts(handle,"\n") print(handle,item_y) puts(handle,"\n") print(handle,element_x) puts(handle,"\n") print(handle,element_y) puts(handle,"\n") print(handle,attribute_x) puts(handle,"\n") print(handle,attribute_y) puts(handle,"\n") print(handle,weapon_x) puts(handle,"\n") print(handle,weapon_y) puts(handle,"\n") print(handle,shop_x) puts(handle,"\n") print(handle,shop_y) puts(handle,"\n") print(handle,npc_x) puts(handle,"\n") print(handle,npc_y) puts(handle,"\n") print(handle,attack_x) puts(handle,"\n") print(handle,attack_y) puts(handle,"\n") print(handle,spell_x) puts(handle,"\n") print(handle,spell_y) puts(handle,"\n") print(handle,skill_x) puts(handle,"\n") print(handle,skill_y) puts(handle,"\n") print(handle,statuseffect_x) puts(handle,"\n") print(handle,statuseffect_y) puts(handle,"\n") print(handle,backdrop_x) puts(handle,"\n") print(handle,backdrop_y) puts(handle,"\n") print(handle,summon_x) puts(handle,"\n") print(handle,summon_y) puts(handle,"\n") print(handle,minigame_x) puts(handle,"\n") print(handle,minigame_y) puts(handle,"\n") print(handle,dungeon_x) puts(handle,"\n") print(handle,dungeon_y) puts(handle,"\n") print(handle,class_x) puts(handle,"\n") print(handle,class_y) puts(handle,"\n") print(handle,event_x) puts(handle,"\n") print(handle,event_y) puts(handle,"\n") print(handle,ani_x) puts(handle,"\n") print(handle,ani_y) puts(handle,"\n") print(handle,maps) puts(handle,"\n") print(handle,heroes) puts(handle,"\n") print(handle,bosses) puts(handle,"\n") print(handle,vehicles) puts(handle,"\n") print(handle,items) puts(handle,"\n") print(handle,elements) puts(handle,"\n") print(handle,attributes) puts(handle,"\n") print(handle,npcs) puts(handle,"\n") print(handle,weapons) puts(handle,"\n") print(handle,shops) puts(handle,"\n") print(handle,attacks) puts(handle,"\n") print(handle,spells) puts(handle,"\n") print(handle,skills) puts(handle,"\n") print(handle,statuseffects) puts(handle,"\n") print(handle,backdrops) puts(handle,"\n") print(handle,summoncreatures) puts(handle,"\n") print(handle,minigames) puts(handle,"\n") print(handle,dungeons) puts(handle,"\n") print(handle,classes) puts(handle,"\n") print(handle,events) puts(handle,"\n") print(handle,animations) puts(handle,"\n") print(handle,frostcode) puts(handle,"\n") print(handle,lmaps) puts(handle,"\n") print(handle,lheroes) puts(handle,"\n") print(handle,lenemies) puts(handle,"\n") print(handle,lbosses) puts(handle,"\n") print(handle,lvehicles) puts(handle,"\n") print(handle,litems) puts(handle,"\n") print(handle,lelements) puts(handle,"\n") print(handle,lattributes) puts(handle,"\n") print(handle,lweapons) puts(handle,"\n") print(handle,lshops) puts(handle,"\n") print(handle,lnpcs) puts(handle,"\n") print(handle,lattacks) puts(handle,"\n") print(handle,lspells) puts(handle,"\n") print(handle,lskills) puts(handle,"\n") print(handle,lstatuseffects) puts(handle,"\n") print(handle,lbackdrops) puts(handle,"\n") print(handle,lsummoncreatures) puts(handle,"\n") print(handle,lminigames) puts(handle,"\n") print(handle,ldungeons) puts(handle,"\n") print(handle,lclasses) puts(handle,"\n") print(handle,levents) puts(handle,"\n") print(handle,lanimations) puts(handle,"\n") print(handle,lfrostcode) puts(handle,"\n") print(handle,szhero_name) puts(handle,"\n") print(handle,szhero_rank) puts(handle,"\n") print(handle,szenemy_name) puts(handle,"\n") print(handle,szenemy_type) puts(handle,"\n") print(handle,szenemy_type2) puts(handle,"\n") print(handle,szboss_name) puts(handle,"\n") print(handle,szboss_type) puts(handle,"\n") print(handle,szboss_type2) puts(handle,"\n") print(handle,szvehicle_name) puts(handle,"\n") print(handle,szitem_name) puts(handle,"\n") print(handle,szitem_desc) puts(handle,"\n") print(handle,szelement_name) puts(handle,"\n") print(handle,szattribute_name) puts(handle,"\n") print(handle,szweapon_name) puts(handle,"\n") print(handle,sznpc_name) puts(handle,"\n") print(handle,szshop_name) puts(handle,"\n") print(handle,szattack_name) puts(handle,"\n") print(handle,szspell_name) puts(handle,"\n") print(handle,szskill_name) puts(handle,"\n") print(handle,szstatuseffect_name) puts(handle,"\n") print(handle,szbackdrop_name) puts(handle,"\n") print(handle,szminigame_name) puts(handle,"\n") print(handle,szdungeon_name) puts(handle,"\n") print(handle,szclass_name) puts(handle,"\n") print(handle,szevent_name) puts(handle,"\n") print(handle,szsummon_name) puts(handle,"\n") puts(handle,getText(Hero_Name_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Rank_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Name_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Type_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Type2_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Name_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Type_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Type2_Edit)) puts(handle,"\n") puts(handle,getText(Vehicle_Name_Edit)) puts(handle,"\n") puts(handle,getText(Item_Name_Edit)) puts(handle,"\n") puts(handle,getText(Item_Desc_Edit)) puts(handle,"\n") puts(handle,getText(Element_Name_Edit)) puts(handle,"\n") puts(handle,getText(Attribute_Name_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_Name_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Name_Edit)) puts(handle,"\n") puts(handle,getText(Shop_Name_Edit)) puts(handle,"\n") puts(handle,getText(Attack_Name_Edit)) puts(handle,"\n") puts(handle,getText(Spell_Name_Edit)) puts(handle,"\n") puts(handle,getText(Skill_Name_Edit)) puts(handle,"\n") puts(handle,getText(StatusEffect_Name_Edit)) puts(handle,"\n") puts(handle,getText(Backdrop_Name_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Name_Edit)) puts(handle,"\n") puts(handle,getText(Minigame_Name_Edit)) puts(handle,"\n") puts(handle,getText(Dungeon_Name_Edit)) puts(handle,"\n") puts(handle,getText(Class_Name_Edit)) puts(handle,"\n") puts(handle,getText(Class_Rank_Edit)) puts(handle,"\n") puts(handle,getText(Event_Name_Edit)) puts(handle,"\n") puts(handle,getText(Map_Name_Edit)) puts(handle,"\n") puts(handle,getText(Hero_HP_Edit)) puts(handle,"\n") puts(handle,getText(Hero_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Hero_MP_Edit)) puts(handle,"\n") puts(handle,getText(Hero_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Str_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Def_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Res_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Hero_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Hero_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Hero_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Hero_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_HP_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_MP_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Str_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Def_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Res_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Enemy_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Boss_HP_Edit)) puts(handle,"\n") puts(handle,getText(Boss_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Str_Edit)) puts(handle,"\n") puts(handle,getText(Boss_MP_Edit)) puts(handle,"\n") puts(handle,getText(Boss_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Str_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Def_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Res_Edit)) puts(handle,"\n") puts(handle,getText(Boss_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Boss_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Boss_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Boss_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Npc_HP_Edit)) puts(handle,"\n") puts(handle,getText(Npc_MP_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Str_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Def_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Res_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Npc_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Npc_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Npc_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Npc_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Title_Edit)) puts(handle,"\n") puts(handle,getText(Author_Edit)) puts(handle,"\n") puts(handle,getText(Company_Edit)) puts(handle,"\n") puts(handle,getText(Version_Edit)) puts(handle,"\n") puts(handle,getText(Summon_HP_Edit)) puts(handle,"\n") puts(handle,getText(Summon_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Summon_MP_Edit)) puts(handle,"\n") puts(handle,getText(Summon_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Str_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Def_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Res_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Summon_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Summon_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Summon_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Summon_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Vehicle_Capacity_Edit)) puts(handle,"\n") puts(handle,getText(Vehicle_Speed_Edit)) puts(handle,"\n") puts(handle,getText(Vehicle_Health_Edit)) puts(handle,"\n") puts(handle,getText(Vehicle_Damage_Edit)) puts(handle,"\n") puts(handle,getText(Element_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Element_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Attribute_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Attribute_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Attribute_EleDam_Edit)) puts(handle,"\n") puts(handle,getText(Class_HP_Edit)) puts(handle,"\n") puts(handle,getText(Class_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Class_MP_Edit)) puts(handle,"\n") puts(handle,getText(Class_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Class_Str_Edit)) puts(handle,"\n") puts(handle,getText(Class_Def_Edit)) puts(handle,"\n") puts(handle,getText(Class_Res_Edit)) puts(handle,"\n") puts(handle,getText(Class_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Class_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Class_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Class_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Class_EleMag_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_Str_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_Def_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_EleDam_Edit)) puts(handle,"\n") puts(handle,getText(Weapon_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Attack_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Spell_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Spell_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Spell_EleDam_Edit)) puts(handle,"\n") puts(handle,getText(Skill_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Skill_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Skill_EleDam_Edit)) puts(handle,"\n") puts(handle,getText(Code_Text)) puts(handle,"\n") puts(handle,getText(StatusEffect_Dam_Edit)) puts(handle,"\n") puts(handle,getText(StatusEffect_HP_Edit)) puts(handle,"\n") puts(handle,getText(StatusEffect_MP_Edit)) puts(handle,"\n") puts(handle,getText(StatusEffect_Code_Edit)) puts(handle,"\n") puts(handle,getText(Item_HP_Edit)) puts(handle,"\n") puts(handle,getText(Item_MaxHP_Edit)) puts(handle,"\n") puts(handle,getText(Item_MP_Edit)) puts(handle,"\n") puts(handle,getText(Item_MaxMP_Edit)) puts(handle,"\n") puts(handle,getText(Item_Str_Edit)) puts(handle,"\n") puts(handle,getText(Item_Def_Edit)) puts(handle,"\n") puts(handle,getText(Item_Res_Edit)) puts(handle,"\n") puts(handle,getText(Item_Mag_Edit)) puts(handle,"\n") puts(handle,getText(Item_Spd_Edit)) puts(handle,"\n") puts(handle,getText(Item_EleMagDam_Edit)) puts(handle,"\n") puts(handle,getText(Item_EleRes_Edit)) puts(handle,"\n") puts(handle,getText(Item_MagRes_Edit)) puts(handle,"\n") puts(handle,getText(Item_Price_Edit)) puts(handle,"\n") puts(handle,getText(Item_MPUse_Edit)) puts(handle,"\n") puts(handle,getText(Item_Uses_Edit)) puts(handle,"\n") puts(handle,getText(Item_Dam_Edit)) puts(handle,"\n") puts(handle,getText(Item_Hit_Edit)) puts(handle,"\n") puts(handle,getText(Item_StrDam_Edit)) puts(handle,"\n") puts(handle,getText(Item_DefDam_Edit)) puts(handle,"\n") puts(handle,getText(Item_SpdDam_Edit)) puts(handle,"\n") puts(handle,getText(Item_MagDam_Edit)) puts(handle,"\n") puts(handle,getText(Item_ResDam_Edit)) puts(handle,"\n") close(handle) end procedure
I can post more code if needed, basiclly when I goto write this to a file, it comes up with an error. This is the error.
frost.exw:3153 in procedure SaveFile() variable Ene_Exp has not been assigned a value ... called from frost.exw:3775 in procedure Save_Project() self = 24 event = 4 parm = {} ... called from C:\euphoria_40b1\include\win32lib.ew:3895 in function invokeHandler() id = <no value> event = <no value> params = <no value> lRoutines = <no value> lStates = <no value> lPos = <no value> lNotify = <no value> lRecvr = <no value> i = 1 j = 1 i = 1 ... called from C:\euphoria_40b1\include\win32lib.ew:22901 in function fDoCommand() id = 24 hWnd = 1574162 iMsg = 273 wParam = 24 lParam = 0 pReturn = -2761 lRC = {-9987} lChildId = <no value> lParent = <no value> ... called from C:\euphoria_40b1\include\win32lib.ew:24449 in function MessageProcessor() pSource = <no value> hWnd = <no value> iMsg = <no value> wParam = <no value> lParam = <no value> id = <no value> lHandledEvent = <no value> lTemp = <no value> result = <no value> lUserReturn = <no value> w32iff_ifTrue__inl = <no value> w32iff_test__inl = <no value> ... called from C:\euphoria_40b1\include\win32lib.ew:24500 in function WndProc() hWnd = <no value> iMsg = <no value> wParam = <no value> lParam = <no value> ^^^ call-back from Windows ... called from C:\euphoria_40b1\include\w32dll.ew:280 in procedure w32Proc() funcid = <no value> parms = <no value> libfunc = <no value> lFuncDef = <no value> memset = <no value> i = 1 ... called from C:\euphoria_40b1\include\win32lib.ew:25000 in procedure eventLoop() pData = {} temp = <no value> msg = 38939396 getRC = 1 hDlg = 1574162 inc = <no value> el = 1 lTock = 0 ... called from C:\euphoria_40b1\include\win32lib.ew:25228 in procedure WinMain() id = 3 style = 3 lInitFocus = -1 lRtnId = <no value> lEventName = <no value> lInitView = <no value> setMainWindow_lOld__inl = <no value> ... called from frost.exw:4193
I put it in eucode, so that it would be easier to read. I have assinged var Ene_Exp a value, after I looked into ex.err, but it still comes up with the other errors.
2. Re: Bug or Error
- Posted by jeremy (admin) Sep 12, 2009
- 1086 views
Hey Guys,
What is wrong with my code, it runs fine, but when I go to execute it, it comes up with an error.
I'm a bit confused with this statement. What do you mean it runs fine? What do you mean by executing it?
Jeremy
3. Re: Bug or Error
- Posted by Fendaril Sep 12, 2009
- 1084 views
Im sorry this won't answer your question but is that a MUD you are working on? Are you making it write information to a file to save it?
4. Re: Bug or Error
- Posted by Lone_EverGreen_Ranger Sep 12, 2009
- 1085 views
Hey Guys,
What is wrong with my code, it runs fine, but when I go to execute it, it comes up with an error.
I'm a bit confused with this statement. What do you mean it runs fine? What do you mean by executing it?
Jeremy
I have a menu and menuitem. I have a menuitem called File_Save_Project, when I click on that, it saves the file. However when it goes to write the data to the file, I get the error.
constant MainWin = createEx(Window,"",0,Default,Default,800,600,0,0) constant File = createEx(Menu,"&File",MainWin,0,0,0,0,0,0), File_Save_Project = createEx(MenuItem,"Save Project",File,0,0,0,0,0,0) WinMain(MainWin,Maximized)
The above code is just a simple explanation of how the GUI is. I just need to know how to fix the error. If someone could show me how to use the new and improved Eu 4.0 read and write commands with my code above, I'd appericate it.
5. Re: Bug or Error
- Posted by ChrisB (moderator) Sep 12, 2009
- 1099 views
Hi
Instead of
handle = open(fName,"wb")
try
handle = open(fName,"w")
Since you are not actually writing binary data.
Secondly, I would have thought that there's a large number of global variable there. Probably too late, but another way of doing this would be to to define a global sequence (I know, I know), and use constants to define each element of the sequence.
So for instance
global constant HP = 1,
Max_HP = 2,
MP = 3,
and so on
then you have your global sequence
global sequence Char_attribs = repeat("", number_of_attribs_above)
Then when it comes to writing out your file
for i = 1 to length(Char_atribs) do puts(handle, Char_attrib[i]) end for
BUT, an even better way would be to use eds or sqlite to write out the sequences, then they they could be easily modified as you saw fit, without having to re write the whole file each time.
This may not help, but make sure you have initialised all the variables, and see what happens if you only try to save smaller chunks.
Chris
6. Re: Bug or Error
- Posted by Lone_EverGreen_Ranger Sep 12, 2009
- 1060 views
Hi
Instead of
handle = open(fName,"wb")
try
handle = open(fName,"w")
Since you are not actually writing binary data.
Secondly, I would have thought that there's a large number of global variable there. Probably too late, but another way of doing this would be to to define a global sequence (I know, I know), and use constants to define each element of the sequence.
So for instance
global constant HP = 1,
Max_HP = 2,
MP = 3,
and so on
then you have your global sequence
global sequence Char_attribs = repeat("", number_of_attribs_above)
Then when it comes to writing out your file
for i = 1 to length(Char_atribs) do puts(handle, Char_attrib[i]) end for
BUT, an even better way would be to use eds or sqlite to write out the sequences, then they they could be easily modified as you saw fit, without having to re write the whole file each time.
This may not help, but make sure you have initialised all the variables, and see what happens if you only try to save smaller chunks.
Chris
Well it has to be a binary file, as I plan on writing data images to it later on. I think it may be because I don't have all of the var assinged values, I'll see if that helps. Also, its not really a MUD, its more of a RPG editor and a engine. So it is kinda like a MUD, but not really.
7. Re: Bug or Error
- Posted by ChrisB (moderator) Sep 12, 2009
- 1076 views
Hi
Then you'd still be better of using a database system that could handle BLOBs - I know sqlite can, but haven't got around to adding it to the wrappers yet, as I simply haven't needed it.
Chris
Forked into: eDBI and SQLite
8. Re: Bug or Error
- Posted by DerekParnell (admin) Sep 12, 2009
- 1086 views
What is wrong with my code ...
Yes, the first thing is that you cannot use a variable until it has been assigned something, and sending it out to a file is using it.
Secondly, the style you have chosen is not the best one from a maintenance point of view. Like others, I'd suggest that you use a database to store this stuff in, and the supplied EDS is very suitable for it - including storing images.
I'd code it more like ...
procedure SaveFile() fName = getSaveFileName(MainWin,file,FrostType) if length(fName) = 0 then return end if fName = defaultext(fName, "edb") delete_file(fName) handle = db_create(fName) if handle != DB_OK then fn = message_box("Save File Error", "Save Error", MB_TASKMODAL) end if db_create_table("attributes") db_select_table("attributes") db_insert("Basic", { HP, Max_HP, MP, Max_MP, Str, Def, ... etc, etc, etc, ... getText(Item_MagDam_Edit), getText(Item_ResDam_Edit), $ -- end of list marker }) db:close() end procedure
9. Re: Bug or Error
- Posted by Lone_EverGreen_Ranger Sep 12, 2009
- 1029 views
- Last edited Sep 13, 2009
What is wrong with my code ...
Yes, the first thing is that you cannot use a variable until it has been assigned something, and sending it out to a file is using it.
Secondly, the style you have chosen is not the best one from a maintenance point of view. Like others, I'd suggest that you use a database to store this stuff in, and the supplied EDS is very suitable for it - including storing images.
I'd code it more like ...
procedure SaveFile() fName = getSaveFileName(MainWin,file,FrostType) if length(fName) = 0 then return end if fName = defaultext(fName, "edb") delete_file(fName) handle = db_create(fName) if handle != DB_OK then fn = message_box("Save File Error", "Save Error", MB_TASKMODAL) end if db_create_table("attributes") db_select_table("attributes") db_insert("Basic", { HP, Max_HP, MP, Max_MP, Str, Def, ... etc, etc, etc, ... getText(Item_MagDam_Edit), getText(Item_ResDam_Edit), $ -- end of list marker }) db:close() end procedure
Ah, thanks for the tips