I want to update an array of string at specific location with a value from variable. But if the value of the variable changes again it should not affect the array updated.
I am attaching the following code for a better understanding of my need.
#platform "Gen4-uLCD-70DT"
#inherit "VisualConst.inc"
#inherit "DemoConst.inc"
func main()
var p, q;
var buff1[20];
var format;
format := "%*s\n%*s\n%*s\n%*s\n%*s";
//Create an Array of 5 and fill it with a string of Characters
var m[5];
m[0] := "Shiva";
m[1] := "Parvati";
m[2] := "Ganesha";
m[3] := "Kartikeya";
m[4] := "That which is not";
//Print that Array in the required format
p := str_Ptr(m);
str_Printf(&p, format);
putch('\n');
putch('\n');
gfx_Cls();
//Fill the Array buff1 with strings
to(buff1);
print("V");
p := str_Ptr(buff1);
str_Cat(p, "I");
str_Cat(p + 1, "S");
str_Cat(p + 2, "H");
str_Cat(p + 3, "N");
str_Cat(p + 4, "U");
str_Cat(p + 5, 0);
//Print that buff1
print([STR]buff1);
putch('\n');
putch('\n');
//Replace the m[2] with the buff1 filled above
q := str_Ptr(m);
str_PutWord(q + 4 , buff1);
//Print the m array. Note that the m[2] has been updated with buff1
str_Printf(&q, format);
print("\n");
print("\n");
//Update the value of buff1
to(buff1);
print("B");
p := str_Ptr(buff1);
str_Cat(p, "R");
str_Cat(p + 1, "A");
str_Cat(p + 2, "M");
str_Cat(p + 3, "H");
str_Cat(p + 4, "A");
str_Cat(p + 5, 0);
//Wait for 1 sec
pause(1000);
//Print the m buffer. Note that the value at m[2] has been updated
p := str_Ptr(m);
str_Printf(&p, format);
repeat
forever
endfunc
Note:
Array at m[2] was updated with buff1 and printed.
However, if buff1 is updated, the value at m[2] seems to update as well. I do not want this to happen.
Once the Array has been updated, it should be independent.
I do not know, if this is the appropriate method or not, however, I wish to carry out this task.
Can anyone help me with this? Thanks.
I am attaching the following code for a better understanding of my need.
#platform "Gen4-uLCD-70DT"
#inherit "VisualConst.inc"
#inherit "DemoConst.inc"
func main()
var p, q;
var buff1[20];
var format;
format := "%*s\n%*s\n%*s\n%*s\n%*s";
//Create an Array of 5 and fill it with a string of Characters
var m[5];
m[0] := "Shiva";
m[1] := "Parvati";
m[2] := "Ganesha";
m[3] := "Kartikeya";
m[4] := "That which is not";
//Print that Array in the required format
p := str_Ptr(m);
str_Printf(&p, format);
putch('\n');
putch('\n');
gfx_Cls();
//Fill the Array buff1 with strings
to(buff1);
print("V");
p := str_Ptr(buff1);
str_Cat(p, "I");
str_Cat(p + 1, "S");
str_Cat(p + 2, "H");
str_Cat(p + 3, "N");
str_Cat(p + 4, "U");
str_Cat(p + 5, 0);
//Print that buff1
print([STR]buff1);
putch('\n');
putch('\n');
//Replace the m[2] with the buff1 filled above
q := str_Ptr(m);
str_PutWord(q + 4 , buff1);
//Print the m array. Note that the m[2] has been updated with buff1
str_Printf(&q, format);
print("\n");
print("\n");
//Update the value of buff1
to(buff1);
print("B");
p := str_Ptr(buff1);
str_Cat(p, "R");
str_Cat(p + 1, "A");
str_Cat(p + 2, "M");
str_Cat(p + 3, "H");
str_Cat(p + 4, "A");
str_Cat(p + 5, 0);
//Wait for 1 sec
pause(1000);
//Print the m buffer. Note that the value at m[2] has been updated
p := str_Ptr(m);
str_Printf(&p, format);
repeat
forever
endfunc
Note:
Array at m[2] was updated with buff1 and printed.
However, if buff1 is updated, the value at m[2] seems to update as well. I do not want this to happen.
Once the Array has been updated, it should be independent.
I do not know, if this is the appropriate method or not, however, I wish to carry out this task.
Can anyone help me with this? Thanks.
Comment