I slept on it and changed my approach, there wasn't a real need for it but at the time I thought it might be a tidier way to do it. Thanks for responding however

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: monkey_05_06 on Fri 06/05/2011 19:50:14
use dynamic arrays outside of the struct and simply use a struct interface (specifically, struct functions) for getting/setting the items you need
int iWS;
int iteration;
int Current_Segment_Tracker;
int Lines_Read;
int nSegments;
int Verb_Data_Unit;
String File_Lines[100];
String Segments[1000];
struct Lexicon_Verb { // *VERBS*
int tense; // 0=directive, 2=past, 3=present
int known_Subject; // 0=no, 1=yes
int abbey_capable; // 0=no, 1=yes
int user_capable; // 0=no, 1=yes
String Word_Text;
int Sound_File;
};
Lexicon_Verb Verb[1000];
String conversion_buffer_1; // since I can't just say Segments[0].Substring(0, 1).AsInt
String conversion_buffer_2; // probably don't need 4 of them, but peace of mind
String conversion_buffer_3;
String conversion_buffer_4;
function Load_Lexicon_Verbs() //===============---------------- Below is all tested and works great until @@@
{
bool bKeep_Loading_Verbs = false;
bool bKeep_Segmenting_Line_Verbs = false;
iteration = 0; // reset iteration to zero before segmenting
nSegments = 0; // reset nSegments to zero before segmenting a new string
iWS = 0; // reset white space tracker
Lines_Read = 0;
Current_Segment_Tracker = 0;
gLoading_Box.Visible = true; // turn on the loading box, it just shows me what steps are working
if(Verbs_Loaded == 0)
{
File *load_verbs = File.Open("Lexicon_Verbs.txt", eFileRead);
while(!load_verbs.EOF && Lines_Read < 100)
{
File_Lines[Lines_Read]= load_verbs.ReadRawLineBack();
Lines_Read++;
}
load_verbs.Close();
bKeep_Segmenting_Line_Verbs = true;
while(bKeep_Segmenting_Line_Verbs)
{
iWS = File_Lines[iteration].IndexOf(" ");
if(iWS == NOT_FOUND)
{
Segments[nSegments] = File_Lines[iteration];
iteration++;
if((iteration + 1) > Lines_Read)
{
bKeep_Loading_Verbs = true;
bKeep_Segmenting_Line_Verbs = false;
}
}
else
{
Segments[nSegments] = File_Lines[iteration].Truncate(iWS);
File_Lines[iteration] = File_Lines[iteration].Substring(iWS + 1, File_Lines[iteration].Length);
}
nSegments++;
}
// @@@=================================----------------- @@@ Above is all tested and works great @@@
iteration = 0;
while(iteration < nSegments)
{
Verb_Data_Unit = iteration % 3;
if(Verb_Data_Unit == 0) // now we're dealing with a Segments[] String of 'type A'
{
conversion_buffer_1 = Segments[Current_Segment_Tracker].Substring(0, 1);
Verb[iteration].tense = conversion_buffer_1.AsInt;
conversion_buffer_2 = Segments[Current_Segment_Tracker].Substring(1, 1);
Verb[iteration].known_Subject = conversion_buffer_2.AsInt;
conversion_buffer_3 = Segments[Current_Segment_Tracker].Substring(2, 1);
Verb[iteration].abbey_capable = conversion_buffer_3.AsInt;
conversion_buffer_4 = Segments[Current_Segment_Tracker].Substring(3, 1);
Verb[iteration].user_capable = conversion_buffer_4.AsInt;
Current_Segment_Tracker++;
}
else if(Verb_Data_Unit == 1) // 'type B'
{
Verb[iteration].Word_Text = Segments[Current_Segment_Tracker];
Current_Segment_Tracker++;
}
else if(Verb_Data_Unit == 2) // 'type C'
{
Verb[iteration].Sound_File = Segments[Current_Segment_Tracker].AsInt;
Current_Segment_Tracker++;
}
iteration++;
}
}
}
{
String a;
String b;
String b = "0011";
a = b.Chars[0];
}
Quote from: Khris on Thu 26/06/2014 08:03:48Seems like it should be (8 but I don't want to display it, I want to store it. I wouldn't make it that complicated, except Substring is returning an "invalid index" error, even after I corrected my above script by including a tracker int instead of iteration, which was the wrong int. Maybe I should post a more revealing script.
...you're making things much more complicated than they are; getting single characters from a String is trivial..
File *temp_string_to_sort = File.Open("Temp_String_Storage.txt", eFileWrite); // open or create a temporary file to store the string I want to sort
temp_string_to_sort.WriteString(Segments[iteration]); // write the 'type A' string to that temp file
Display("%c", temp_string_to_sort.ReadRawChar());
iteration = 0;
Verb_Data_Unit = 1;
while(bKeep_Loading_Verbs)
{
if(Verb_Data_Unit == 4)
{
Verb_Data_Unit = 1;
}
if(iteration > nSegments)
{
bKeep_Loading_Verbs = false;
}
if(Verb_Data_Unit == 1)
{
conversion_buffer_1 = Segments[iteration].Substring(0, 1);
Verb[iteration].tense = conversion_buffer_1.AsInt;
conversion_buffer_1 = Segments[iteration].Substring(1, 1); // This line is highlighted when I get my error
Verb[iteration].known_Subject = conversion_buffer_1.AsInt;
conversion_buffer_1 = Segments[iteration].Substring(2, 1);
Verb[iteration].abbey_capable = conversion_buffer_1.AsInt;
conversion_buffer_1 = Segments[iteration].Substring(3, 1);
Verb[iteration].user_capable = conversion_buffer_1.AsInt;
}
if(Verb_Data_Unit == 2)
{
Verb[iteration].Word_Text = Segments[iteration];
}
if(Verb_Data_Unit == 3)
{
Verb[iteration].Sound_File = Segments[iteration].AsInt;
}
iteration++;
Verb_Data_Unit++;
}
}
}
String user_text_input; // this is the raw string input from a text box prompt, "It could be this sentence!"
String first_word;
String second_word; // and so on...
function Input_Formatting() {
if (user_text_input.Chars[1] == ?) // and I'm stumped. I want '?' to be the symbol for a space. How do I refer to a space here?
// room script file
int Obj1View=2;
int Obj2View=3;
int Obj3View=4;
int Obj4View=5;
int Obj5View=6;
int SpiritOn=0;
int TitleOn=0;
int ArcPicOn=0;
function StarShift(Object* StarObj){
if(StarObj.GetProperty("StarNumber")==1){
if(Obj1View>=6){
Obj1View=(Obj1View+5)-9;
}
else{
Obj1View+=5;
}
StarObj.SetView(Obj1View, 2);
StarObj.Animate(2, 5, eRepeat, eNoBlock);
}
if(StarObj.GetProperty("StarNumber")==2){
if(Obj2View>=6){
Obj2View=(Obj2View+5)-9;
}
else{
Obj2View+=5;
}
StarObj.SetView(Obj2View, 2);
StarObj.Animate(2, 5, eRepeat, eNoBlock);
}
if(StarObj.GetProperty("StarNumber")==3){
if(Obj3View>=6){
Obj3View=(Obj3View+5)-9;
}
else{
Obj3View+=5;
}
StarObj.SetView(Obj3View, 2);
StarObj.Animate(2, 5, eRepeat, eNoBlock);
}
if(StarObj.GetProperty("StarNumber")==4){
if(Obj4View>=6){
Obj4View=(Obj4View+5)-9;
}
else{
Obj4View+=5;
}
StarObj.SetView(Obj4View, 2);
StarObj.Animate(2, 5, eRepeat, eNoBlock);
}
if(StarObj.GetProperty("StarNumber")==5){
if(Obj5View>=6){
Obj5View=(Obj5View+5)-9;
}
else{
Obj5View+=5;
}
StarObj.SetView(Obj5View, 2);
StarObj.Animate(2, 5, eRepeat, eNoBlock);
}
StarObj.X=-120;
StarObj.Move(440, 83, 1, eNoBlock, eAnywhere);
}
function room_Load()
{
gSplash.Visible=true;
objSky.SetView(1, 1);
objSky.Animate(1, 8, eRepeat, eNoBlock);
objMts.SetView(1, 8);
objMts.Animate(8, 3, eRepeat, eNoBlock);
obj1.SetView(2, 2);
obj1.Animate(2, 5, eRepeat, eNoBlock);
obj2.SetView(3, 2);
obj2.Animate(2, 5, eRepeat, eNoBlock);
obj3.SetView(4, 2);
obj3.Animate(2, 5, eRepeat, eNoBlock);
obj4.SetView(5, 2);
obj4.Animate(2, 5, eRepeat, eNoBlock);
obj5.SetView(6, 2);
obj5.Animate(2, 5, eRepeat, eNoBlock);
obj1.Move(440, 83, 1, eNoBlock, eAnywhere);
obj2.Move(440, 83, 1, eNoBlock, eAnywhere);
obj3.Move(440, 83, 1, eNoBlock, eAnywhere);
obj4.Move(440, 83, 1, eNoBlock, eAnywhere);
obj5.Move(440, 83, 1, eNoBlock, eAnywhere);
objMan.SetView(1, 2);
objYeti.SetView(1, 4);
objYeti.Animate(4, 3, eRepeat, eNoBlock);
objTot.SetView(1, 6);
objTot.Animate(6, 1, eRepeat, eNoBlock);
SetTimer(1, 30);
objSpirit.SetView(1, 0);
objSpirit.Animate(0, 3, eOnce, eNoBlock);
objTitle.SetView(1, 12);
objTitle.Animate(12, 3, eOnce, eNoBlock);
}
function room_RepExec()
{
if(TitleOn==0){
if(IsTimerExpired(2)==1){
TitleOn=1;
}
}
if(TitleOn==1){
if(objTitle.Animating==0){
objTitle.Animate(11, 1, eOnce, eNoBlock);
SetTimer(2, 160);
TitleOn=0;
}
}
if(SpiritOn==0){
if(IsTimerExpired(1)==1){
if(objTitle.Animating==0){
objTitle.Animate(10, 3, eOnce, eNoBlock);
TitleOn=1;
}
if(objSpirit.Animating==0){
objSpirit.Animate(9, 3, eRepeat, eNoBlock);
SpiritOn=1;
}
}
}
if(obj1.X==440){
StarShift(obj1);
}
if(obj2.X==440){
StarShift(obj2);
}
if(obj3.X==440){
StarShift(obj3);
}
if(obj4.X==440){
StarShift(obj4);
}
if(obj5.X==440){
StarShift(obj5);
}
if(objMan.Animating==0){
if(objMan.X==23){
objMan.Animate(3, 5, eOnce, eNoBlock);
objMan.Move(38, 135, -7, eNoBlock, eAnywhere);
}
if(objMan.X==38){
objMan.Animate(2, 5, eOnce, eNoBlock);
objMan.Move(23, 129, -7, eNoBlock, eAnywhere);
}
}
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.078 seconds with 13 queries.