nemolorn Posted July 9, 2012 Share Posted July 9, 2012 I'm stuck. This is what I have working: [scar]program stuff; type DB = record Name, Status, Server, Field1, Field2 :String; end; var DBName :DB; Smith, Jenny :DB; procedure namespace(login:string); begin case login of 'Smith': DBName := Smith; 'Jenny': DBName := Jenny; end; end; procedure setupstuff; begin Smith.Name := 'Smith' Smith.Status := 'Ready' Smith.Server := '176.26' Smith.Field1 := 'unknown' Smith.Field2 := 'unknown' Jenny.Name := 'Jenny' Jenny.Status := 'Ready' Jenny.Server := '176.26' Jenny.Field1 := 'unknown' Jenny.Field2 := 'unknown' end; begin setupstuff; Namespace('Smith') wait(1000) writeln(DBName.Name+'.Name := '+DBName.Name) end.[/scar] Expected Result: Smith.Name := Smith I need to somehow incorporate a second part to the array, as the final result needs to be: [scar] procedure setupstuff; begin Smith.S1.Name := 'Smith' Smith.S1.Status := 'Ready' Smith.S1.Server := '176.26' Smith.S1.Field1 := 'unknown' Smith.S1.Field2 := 'unknown' Jenny.S1.Name := 'Jenny' Jenny.S1.Status := 'Ready' Jenny.S1.Server := '176.26' Jenny.S1.Field1 := 'unknown' Jenny.S1.Field2 := 'unknown' Smith.s2.Name := 'Smithy' Smith.s2.Status := 'Ready' Smith.s2.Server := '176.25' Smith.s2.Field1 := 'unknown' Smith.s2.Field2 := 'unknown' Jenny.s2.Name := 'Jenny10' Jenny.s2.Status := 'Ready' Jenny.s2.Server := '176.25' Jenny.s2.Field1 := 'unknown' Jenny.s2.Field2 := 'unknown' Smith.s3.Name := 'Smith' Smith.s3.Status := 'Ready' Smith.s3.Server := '176.75' Smith.s3.Field1 := 'unknown' Smith.s3.Field2 := 'unknown' Jenny.s3.Name := 'Jenny' Jenny.s3.Status := 'Ready' Jenny.s3.Server := '176.75' Jenny.s3.Field1 := 'unknown' Jenny.s3.Field2 := 'unknown' Smith.s4.Name := 'Smith_Ken' Smith.s4.Status := 'Ready' Smith.s4.Server := '82.126' Smith.s4.Field1 := 'Sheep' Smith.s4.Field2 := 'unknown' Jenny.s4.Name := 'Jenny' Jenny.s4.Status := 'Ready' Jenny.s4.Server := '82.126' Jenny.s4.Field1 := 'Corn' Jenny.s4.Field2 := 'unknown' end; begin setupstuff; Namespace('Smith') wait(1000) writeln(DBName.Name+'.'+(NewVariablearrayidentifier)+'.Server:= '+(NewVariablearrayidentifier)+DBName.Server) writeln(DBName.Name+'.'+(NewVariablearrayidentifier)+'.Name := '+(NewVariablearrayidentifier)+DBName.Name) Namespace('Jenny') wait(1000) writeln(DBName.Name+'.'+(NewVariablearrayidentifier)+'.Server:= '+(NewVariablearrayidentifier)+DBName.Name) writeln(DBName.Name+'.'+(NewVariablearrayidentifier)+'.Field1 := '+(NewVariablearrayidentifier)+DBName.Name) end.[/scar] Expected Result: Smith.S2.Server:= S2.176.25 Smith.S2.Name := S2.Smithy Jenny.S4.Server:= S4.82.126 Jenny.S4.Field1 := S4.Corn I need that middle array to go (s1, s2, s3, s4), because it represents 3 different servers and a 4th game that is very similar, and it needs to respond to a procedure similar to the Namespace procedure, where I can change that middle variable once Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 9, 2012 Share Posted July 9, 2012 Try this: [scar]type TDBItem = record Name, Status, Server, Field1, Field2: string; end; TDB = record S: array[1..4] of TDBItem; end; var Smith, Jenny: TDB; begin Smith.S[1].Name := 'Smith' Smith.S[1].Status := 'Ready' Smith.S[1].Server := '176.26' Smith.S[1].Field1 := 'unknown' Smith.S[1].Field2 := 'unknown' Jenny.S[1].Name := 'Jenny' Jenny.S[1].Status := 'Ready' Jenny.S[1].Server := '176.26' Jenny.S[1].Field1 := 'unknown' Jenny.S[1].Field2 := 'unknown' Smith.S[2].Name := 'Smithy' Smith.S[2].Status := 'Ready' Smith.S[2].Server := '176.25' Smith.S[2].Field1 := 'unknown' Smith.S[2].Field2 := 'unknown' Jenny.S[2].Name := 'Jenny10' Jenny.S[2].Status := 'Ready' Jenny.S[2].Server := '176.25' Jenny.S[2].Field1 := 'unknown' Jenny.S[2].Field2 := 'unknown' Smith.S[3].Name := 'Smith' Smith.S[3].Status := 'Ready' Smith.S[3].Server := '176.75' Smith.S[3].Field1 := 'unknown' Smith.S[3].Field2 := 'unknown' Jenny.S[3].Name := 'Jenny' Jenny.S[3].Status := 'Ready' Jenny.S[3].Server := '176.75' Jenny.S[3].Field1 := 'unknown' Jenny.S[3].Field2 := 'unknown' Smith.S[4].Name := 'Smith_Ken' Smith.S[4].Status := 'Ready' Smith.S[4].Server := '82.126' Smith.S[4].Field1 := 'Sheep' Smith.S[4].Field2 := 'unknown' Jenny.S[4].Name := 'Jenny' Jenny.S[4].Status := 'Ready' Jenny.S[4].Server := '82.126' Jenny.S[4].Field1 := 'Corn' Jenny.S[4].Field2 := 'unknown' end.[/scar] Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 9, 2012 Share Posted July 9, 2012 Whoa, you didn't put any ; (semi-colon)s after the variable initializations. Note that SCAR supports INI files, Database files, and regular files. http://wiki.scar-divi.com/index.php?title=Category:Database_Functions http://wiki.scar-divi.com/index.php?title=Category:File_Functions Quote Link to comment Share on other sites More sharing options...
FHannes Posted July 9, 2012 Share Posted July 9, 2012 Whoa, you didn't put any ; (semi-colon)s after the variable initializations. I didn't even notice, I just copied his code and ran a regex replace. Quote Link to comment Share on other sites More sharing options...
nemolorn Posted July 9, 2012 Author Share Posted July 9, 2012 it runs well enough though >_> added the semi's, and works just fine Thanks. I've been thinking about changing my setupstuff to a logfile/readfile string when I start setting up more bots, just haven't looked into that yet, still cleaning up a few other bugs before I try and streamline my code more. Quote Link to comment Share on other sites More sharing options...