Inserting Strings

  • 11 years ago
    Ok i have some code for you all to take a look at... everything works except one part

    Code:

    Private Sub cmdAdd_Click()
    Dim i As Integer

    For i = 0 To 1
    With sBill

           ' FX Configuration
       
           .alias = txtAlias.Text
           .alias1 = txtAliasOne.Text
           .alias2 = txtAliasTwo.Text
           .alias3 = txtAliasThree.Text
           .pathfx = txtPath.Text
           .pathfx1 = txtPathFx.Text
           .effect = lblEffect.Caption
           .effect1 = lblEffect1.Caption
           .loadfx = lblLoadfx.Caption
           .loadfx1 = lblLoadfx1.Caption
           .maps = lblMaps.Caption
           .maps1 = lblMaps1.Caption
           .x = txtX.Text
           .x1 = txtXone.Text
           .y = txtY.Text
           .y2 = txtYtwo.Text
           .z = txtZ.Text
           .z3 = txtZthree.Text
           .waitT = txtWait.Text
           .waitV = txtWaitFx.Text
           
           

    End With

    i = i + 1
    'Label2.Caption = sBill.sHead
    Text12.Text = Text12.Text & sBill.sEfx
    DoEvents
    Next i

    End Sub

    Private Sub Command1_Click()
    With sBill

           ' setCullFog - ambientPlay - maps\mp\_load::main();
           .Ambient = cboAmbient.Text
           .sCF = lblScf.Caption
           .mMP = Label15.Caption
           .mp = Label3.Caption
           .a = Text5.Text
           .b = Text7.Text
           .c = Text8.Text
           .d = Text9.Text
           .e = Text10.Text
           .f = Text11.Text
           
           ' Setup Files
           .sMain = txtMain.Text
           .game = game
           .soldierT = cboSoldier.Text
           .soldierV = cboSoldierV.Text
           .weather = cboWeather.Text
           .division = cboDivision.Text
           .germanT = cboGerman.Text
           .germanV = cboG_Sold_Var.Text
           .germanD = cboG_Division.Text
           .germanW = cboG_Weather.Text
           .allies = CboAllies.Text
           .defenders = Text4.Text
           .attackers = Text2.Text
           .defender1 = Text3.Text
           .defenders = Text4.Text
           .axis = Text6.Text
           .attackers1 = Text1.Text
           .allies1 = Text2.Text
           .axis1 = Text4.Text
           .layoutimage = "layoutimage"
           .layout1 = txtLayoutImage.Text
    End With
    Text12.Text = Text12.Text & sBill.sHead
    End Sub

    Private Sub Form_Load()

    ' Clear the Combo Boxes
    cboAmbient.Text = ""
    cboSoldier.Text = ""
    cboSoldierV.Text = ""
    cboWeather.Text = ""
    cboDivision.Text = ""
    cboG_Weather.Text = ""
    cboG_Sold_Var.Text = ""
    cboG_Division.Text = ""
    cboGerman.Text = ""
    CboAllies.Text = ""
    txtLayoutImage.Text = ""


    ' Ambient Types
    With cboAmbient
           .AddItem "ambient_mp_berlin"
           .AddItem "ambient_mp_brecourt"
           .AddItem "ambient_mp_burnville"
           .AddItem "ambient_mp_chateau"
           .AddItem "ambient_mp_dam"
           .AddItem "ambient_mp_factory"
           .AddItem "ambient_mp_harbor"
           .AddItem "ambient_mp_night"
           .AddItem "ambient_mp_ocean"
           .AddItem "ambient_mp_pegasusnight"
           .AddItem "ambient_mp_powcamp"
           .AddItem "ambient_mp_sewer"
           .AddItem "ambient_mp_ship"
           .AddItem "ambient_mp_snowy"
           .AddItem "ambient_mp_staligrad"
           .AddItem "ambient_mp_training"
    End With


    '-------------------------------------------------------

    ' sBill to setup the combo Text files to the strings


    ' soldier ComboBox Setup
    With cboSoldier
           .AddItem "american_soldier"
           .AddItem "british_soldiertype"
           .AddItem "russian_soldiertype"
    End With

    ' soldier ComboBox Variation
    With cboSoldierV
           .AddItem "american_soldiervariation"
           .AddItem "british_soldiervariation"
           .AddItem "russian_solidervariation"
    End With
    ' Division Combobox
    With cboDivision
           .AddItem "commando"
           .AddItem "veteran"
           .AddItem "airborne"
           .AddItem "conscript"
    End With

    With cboWeather
           .AddItem "normal"
           .AddItem "winter"
    End With

    With cboGerman
           .AddItem "german_soldiertype"
    End With

    With cboG_Sold_Var
           .AddItem "german_soldiervariation"
    End With

    With cboG_Division
           .AddItem "waffen"
           .AddItem "fallschirmjagercamo"
           .AddItem "wehrmacht"
           .AddItem "kriegsmarine"
    End With

    With CboAllies
           .AddItem "american"
           .AddItem "british"
           .AddItem "russian"
    End With

    With cboG_Weather
           .AddItem "normal"
           .AddItem "winter"
    End With
    End Sub


    Private Sub Form_Unload(Cancel As Integer)
    mnuExit_Click
    End Sub

    Private Sub mnuArena_Click()
    frmArena.Show
    End Sub

    Private Sub mnuCod_Options_Click()
    frmOptions.Show
    End Sub

    Private Sub mnuCod2_Click()
    frmCod2Efx.Show
    End Sub

    Private Sub mnuExit_Click()
    Unload Me
    End Sub

    Private Sub mnuSave_Click()
    With cd1
       On Error GoTo errHandler
       .CancelError = True
       .DialogTitle = "Exodus COD, COD2 Gaming Tools"
       .Flags = cdlOFNReadOnly + cdlOFNOverwritePrompt
       .Filter = "GSC Files (*.gsc)|*.gsc"
       .FileName = ""
       .ShowSave
    End With
    Open cd1.FileName For Output As #1
    Print #1, Text12.Text
    Close #1

    errHandler:
    Exit Sub
    End Sub



    Here is the Declaration in a Class

    Code:

    Option Explicit

    ' Main Map GSC

    Public game As String
    Public sMain As String
    Public soldierT As String
    Public soldierV As String
    Public weather As String
    Public division As String
    Public allies As String
    Public axis As String
    Public attackers As String
    Public defenders As String
    Public attackers1 As String
    Public defender1 As String
    Public axis1 As String
    Public allies1 As String
    Public Ambient As String
    Public germanT As String
    Public germanV As String
    Public germanW As String
    Public germanD As String
    Public layoutimage As String
    Public layout1 As String

    ' Map_Fx.gsc

    Public pathfx As String
    Public pathfx1 As String
    Public pathfx2 As String
    Public pathgx3 As String
    Public alias As String
    Public alias1 As String
    Public alias2 As String
    Public alias3 As String
    Public effect As String
    Public effect1 As String
    Public loadfx As String
    Public loadfx1 As String
    Public maps As String
    Public maps1 As String
    Public waitT As String
    Public waitV As String
    Public x As Single
    Public x1 As Single
    Public y As Single
    Public y2 As Single
    Public z As Single
    Public z3 As Single

    ' setCullFog - ambientPlay - maps\mp\_load::main();

    Public sCF As String
    Public mp As String
    Public mMP As String
    Public a As String
    Public b As String
    Public c As String
    Public d As String
    Public e As String
    Public f As String



    Public Property Get sHead()
    sHead = Me.sMain & vbNewLine & Chr(123) & vbNewLine & " " & vbNewLine & " " & _
    sCF & Chr(40) & a & " " & b & " " & c & " " & d & " " & e & " " & f & Chr(41) & Chr(59) & vbNewLine & " " & _
    mp & " " & Chr(40) & Chr(34) & Ambient & Chr(34) & Chr(41) & Chr(59) & vbNewLine & vbNewLine & vbNewLine & " " & _
    mMP & vbNewLine & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & attackers & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & allies & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & defenders & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & axis & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & attackers1 & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & allies1 & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & defender1 & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & axis1 & Chr(34) & Chr(59) & vbNewLine & vbNewLine & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & soldierT & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & division & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & soldierV & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & weather & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & germanT & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & germanD & Chr(34) & Chr(59) & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & germanV & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & germanW & Chr(34) & Chr(59) & vbNewLine & vbNewLine & vbNewLine & " " & _
    "game" & Chr(91) & Chr(34) & Me.game & layoutimage & Chr(34) & Chr(93) & " " & Chr(61) & " " & Chr(34) & layout1 & Chr(34) & Chr(59) & vbNewLine & vbNewLine & vbNewLine & " " & Chr(125)
    End Property

    Public Property Get sEfx()
    sEfx = vbNewLine & " " & vbNewLine & " " & _
    effect & alias & loadfx & pathfx & vbNewLine & " " & _
    maps & Chr(40) & alias1 & " " & Chr(40) & x & " " & y & " " & z & Chr(41) & waitT & Chr(41) & Chr(59) & vbNewLine & " " & _
    effect1 & alias2 & loadfx1 & pathfx1 & vbNewLine & " " & _
    maps1 & Chr(40) & alias3 & " " & Chr(40) & x1 & " " & y2 & " " & z3 & Chr(41) & waitV & Chr(41) & Chr(59) & vbNewLine & vbNewLine & vbNewLine
    End Proper




    Here is output file that is originally you will get.

    main()
    {

    level._effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp\_fx::loopfx("fire", (16 24 0),0.6);
    level._effect["smoke"]= loadfx("fx/smoke/ash_smoke.efx");
    maps\mp\_fx::loopfx("smoke", (16 24 32),0.7);

    setCullFog(0, 6000, .32, .33, .40, 0);
    ambientPlay ("");


    maps\mp\_load::main();

    game["allies"] = "";
    game["axis"] = "german";
    game["attackers"] = "allies";
    game["defenders"] = "axis";


    game[""] = "";
    game[""] = "";
    game[""] = "";
    game[""] = "";


    game["layoutimage"] = "";


    }

    Now the question i am asking... is that between the brackets before and the end... i want to insert the sEfx inside those brackets on using the loop condition... but when i hit add effects it will drop below the bottom bracket...

    Now when i get the correct code to insert in between the brackets, i want to keep adding sEfx script in there.. .and still have the rest of the code there...

    thanks experts

    Merry Christmas and happy Holidays.

    Wildturkey
  • 11 years ago
    Ok since i am not getting a proper response.. I will try to explain it a different way.

    main() <- without loosing this function
    { < - without loosing these bracket

    I want to keep the main() and the brackets at stationary point.

    Insert Multiple Arrays here

    Insert Multiple Arrays here.

    Look at the EFFECTS code, i want to insert the same script in these brackets over and over without loosing the brackets


    } < - without loosing these brackets

    they seem to fall under the brackets here...


    Multiple Arrays here




    ----------------------------------------

    I can't seem to add it in between the brackets using Arrays without loosing the brackets and main()

    better example.. or am i even confusing it worse than ever lol

    wildturkey.
  • 11 years ago

    Yes. This is incredibly confusing.


    But, if I understand this correctly, you wish to (effectively) insert some dynamically generated code in your main() function...?


    If so, consider looking for the final closing brace character.


    If it is safe to assume that said closing brace is the last character in the current contents of the TextBox, then change


    Code:

    'Label2.Caption = sBill.sHead
    Text12.Text = Text12.Text & sBill.sEfx
    DoEvents


    to


    Code:

    'Label2.Caption = sBill.sHead
    Text12.Text = Left$(Text12.Text, Len(Text12.Text) - 1) & sBill.sEfx
    DoEvents


    If it is not safe to assume that the closing brace is the last character (e.g. it may be followed by a number of vbCrLf newline pairs) then the replacement code should be


    Code:

    'Label2.Caption = sBill.sHead
    strTrimmedContent = RTrim$(Text12.Text)
    Text12.Text = Left$(strTrimmedContent, Len(strTrimmedContent) - 1) & sBill.sEfx

    DoEvents


    Then add the closing brace back in.


    I believe this will do what you want.

  • 11 years ago

    main()
    {


    level.effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);
    level.
    effect["smoke"]= loadfx("fx/smoke/ashsmoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);
                                                                                                       // these is controlled by an Array, i keep clicking Add Efx and i get rows of the samething
    level.
    effect["fire"]= loadfx("fx/fire/tinybon.efx");                            // This is what i am looken for with main() and brackets. but i am not getting this look
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);                                     // below.
    level.effect["smoke"]= loadfx("fx/smoke/ashsmoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);



    }



    level.effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);
    level.
    effect["smoke"]= loadfx("fx/smoke/ash_smoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);


    level.effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);
    level.
    effect["smoke"]= loadfx("fx/smoke/ash_smoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);


    Now the above script i cant keep the main() and the brackets together


    they seem to drop below the brackets. like this


    main()
    {
    }


    level.effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);
    level.
    effect["smoke"]= loadfx("fx/smoke/ash_smoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);


    level.effect["fire"]= loadfx("fx/fire/tinybon.efx");
    maps\mp_fx::loopfx("fire", (16 24 0),0.6);
    level.
    effect["smoke"]= loadfx("fx/smoke/ash_smoke.efx");
    maps\mp_fx::loopfx("smoke", (16 24 32),0.7);


    I could send the source code to one person so you can accually see the interface and what i am trying to do...


    The Effects has to fall between the brackets but they are dropping below the brackets.. .


    hope this is a little better example...


    Thanks.


    Wildturkey

  • 11 years ago
    Ok, so I did understand what you meant. That's good.

    Did you try making the modifications I suggested? They ought to make some difference.

    I don't see any code in the sample you have posted that inserts the:

    Code:

    main()
    {
    }


    snippet. Any chance you could post the code that inserts that?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”