Public Sub MakeTemplate() 'Write Template to Gas File Function
'Embed Quotations
Const Quote As String = """"
Open "Template.gas" For Output As #1
Print #1, "[t:template,n:Auto_Template]"
Print #1, "("
Print #1, "doc = " & Quote & WepName & Quote & ";"
Print #1, "specializes = " & Weapon & ";"
Print #1, "[aspect]"
Print #1, "{"
Print #1, "model = " & Model & ";"
Print #1, "}"
Print #1, "[attack]"
Print #1, "{"
Print #1, "f damage_max = " & MaxDam & ";"
Print #1, "f damage_min = " & MinDam & ";"
Print #1, "}"
Print #1, "[common]"
Print #1, "{"
Print #1, "screen_name = " & Quote & WepName & Quote & ";"
Print #1, "}"
If Effect = True Then
Print #1, "[effect_manager]"
Print #1, "{"
Print #1, "effect_name = " & GFX & ";"
If Repeat = True Then
Print #1, "repeat = true;"
End If
Print #1, "}"
End If
Print #1, "[gui]"
Print #1, "{"
Print #1, "active_icon = b_gui_ig_i_ic_swd_001;"
Print #1, "equip_requirements = strength:1;"
Print #1, "inventory_height = " & wHeight & ";"
Print #1, "inventory_width = " & wWidth & ";"
Print #1, "inventory_icon = " & wIcon & ";"
Print #1, "tooltip_color = unique;"
Print #1, "}"
Print #1, "}"
Close #1
End Sub
This is the function im using to write to my file - but it has one problem, no text appears - Anyone have a solution?
no cause i have no idea what id going on. :P lol but really
Quote from: Dyndrilliac on November 14, 2003, 08:19 AM
This is the function im using to write to my file - but it has one problem, no text appears - Anyone have a solution?
Are you saying the file is created but nothing is written to it? You may have to specify the exact location where you want the file to be saved (by default, if no path is specified, it'll be saved to the folder from which your project was launched from, so you may want to do a search on your harddrive for the file to see if it was saved somewhere else).
I don't see anything obviously wrong as to why that doesn't work. Are you sure you actually called the function?
It appears to work fine for me. I pasted your procedure directly into a new VB program, called it from a command button, and removed Option Explicit. It created the file template.gas, containing the following text:
Quote
[t:template,n:Auto_Template]
(
doc = "";
specializes = ;
[aspect]
{
model = ;
}
[attack]
{
f damage_max = ;
f damage_min = ;
}
[common]
{
screen_name = "";
}
[gui]
{
active_icon = b_gui_ig_i_ic_swd_001;
equip_requirements = strength:1;
inventory_height = ;
inventory_width = ;
inventory_icon = ;
tooltip_color = unique;
}
}
You'll have to be more specific about your problem.
Quote from: Sliver_king on November 14, 2003, 09:11 AM
no cause i have no idea what id going on. :P lol but really
If you aren't going to post something useful, don't post anything at all.
Ok, mky specific problem is that the file is created, but when I call the function no text is written to the file. I have it being called in a command button, as shown below:Private Sub cmdCompile_Click()
If txtHeight.Text = vbNullString Then
Exit Sub
End If
If txtWidth.Text = vbNullString Then
Exit Sub
End If
If txtMaxDam.Text = vbNullString Then
Exit Sub
End If
If txtMinDam.Text = vbNullString Then
Exit Sub
End If
'Constants
WepName = txtName.Text
wHeight = CInt(Val(txtHeight.Text))
wWidth = CInt(Val(txtWidth.Text))
MaxDam = CInt(Val(txtMaxDam.Text))
MinDam = CInt(Val(txtMinDam.Text))
wIcon = txtIcon.Text
GFX = txtEffect.Text
Model = txtModel.Text
Weapon = "base_sword"
'Calls the MakeTemplate procedure
MakeTemplate
End Sub
From what Grok summized - unlesssomething is wrong with my caller it should work, but it doesn't.
Are you sure the file is being created? When you don't specify the full path for the file it creates in in the current working directory, which can sometimes be different from your application path (often when you run your program via a shortcut, or another application starts it).
Other than that, I don't see anything wrong.
Nevermind, I fixed the problem, I was running the prohram in the Visual Basic Environment (instead of compiling an exe) and the paths were wrong :P Thanks for all your help though