TextEdit
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
You are right, I did forget the ";". I haven't compiled it, I just copied and heavily modified preexisting code. What is a "STACKOVERFLOW"? I have used that method of mine, and it seems to work actually really well for me.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: TextEdit
Oops. I meant to say 1.31.mattallen37 wrote:I don't think there is such a thing as enhanced firmware 1.21.nxtboyiii wrote:I have enhanced FW 1.21...
Thanks, and have a nice day,
nxtboy III
programnxt.com
nxtboy III
programnxt.com
Re: TextEdit
Mattallen, can you modify your program to output to the variable "Sen" (not an array)
2Labz.com, My Website
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
dudmaster wrote:Mattallen, can you modify your program to output to the variable "Sen" (not an array)
Code: Select all
if(OpenFileRead("File.txt", size, handle) == NO_ERR)
{
until (Sdone == true) // read the text file till the end
{
if(ReadLnString(handle,message) != NO_ERR) Sdone = true;
//You need to grab the message and write it to another string(or whatever you need to do) all right here.
//Base it on an increasing variable, like the following lines.
Sen[i]=message;
i++
}
}
How about this?
Code: Select all
if(OpenFileRead("File.txt", size, handle) == NO_ERR)
{
until (Sdone == true) // read the text file till the end
{
if(ReadLnString(handle,message) != NO_ERR) Sdone = true;
//You need to grab the message and write it to another string(or whatever you need to do) all right here.
//Base it on an increasing variable, like the following lines.
TotalMessage[i]=message;
i++
}
Sen=TotalMessage[Line];//Line being a variable or constant in the range of 0-(number of lines-1)
}
Code: Select all
Sen=TotalMessage[Line];
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: TextEdit
The program is great. Thanks, maybe i can add all lines together, and i can use the variable i to find out how many lines, correct?
2Labz.com, My Website
Re: TextEdit
Well, i can't get the code to compile.
I got muntoo's code to compile but when i use it i get a -5 error.
Here is the code:
It takes the array and adds all the lines into one variable.
I got muntoo's code to compile but when i use it i get a -5 error.
Here is the code:
It takes the array and adds all the lines into one variable.
Code: Select all
void ReadLines(string &out[], string filename)
{
byte handle;
int fsize = 300;
ArrayInit(out, "", 0);
if(OpenFileRead(filename, fsize, handle) == LDR_SUCCESS)
{
for(string szBuf; (ReadLnString(handle, szBuf) == LDR_SUCCESS); ArrayBuild(out, out, szBuf));
CloseFile(handle);
}
}
task main() {
bool Sdone;
int size = 300, i, n;
byte handle;
string message, Full;
string Sen[100000000];
ReadLines(Sen, "Test3.txt");
int ArrLen = ArrayLen(Sen);
while (n < ArrLen)
{
string Dude = Sen[n];
Full = Full + Dude;
}
int TextWrap = 0;
while (0 == ButtonCount(BTNCENTER, true))
{
if (ButtonCount(BTNLEFT, true) && TextWrap > 0)
{
TextWrap = TextWrap - 100;
}
if (ButtonCount(BTNRIGHT, true) && TextWrap < StrLen(Full) - 99)
{
TextWrap = TextWrap + 100;
}
TextOut(0, LCD_LINE1, SubStr(Full, TextWrap, 18), true);
TextOut(0, LCD_LINE2, SubStr(Full, TextWrap + 16, 18));
TextOut(0, LCD_LINE3, SubStr(Full, TextWrap + 32, 18));
TextOut(0, LCD_LINE4, SubStr(Full, TextWrap + 48, 18));
TextOut(0, LCD_LINE5, SubStr(Full, TextWrap + 64, 18));
TextOut(0, LCD_LINE6, SubStr(Full, TextWrap + 80, 18));
TextOut(0, LCD_LINE7, SubStr(Full, TextWrap + 96, 18));
TextOut(0, LCD_LINE8, SubStr(Full, TextWrap + 112, 18));
if (ButtonCount(BTNEXIT, true))
{
Stop(true);
}
Wait(50);
}
}
}
2Labz.com, My Website
Re: TextEdit
Paint.NET "Caligraphy Toolbox" Plugin SDK
Chrome Extension Development/Themes.
@Matt
Technically, I believe it would be called a buffer overflow, but StackOverflow cooler.
Buffer overflows are one of the oldest hacking techniques used to execute arbitary code. I don't understand the details, but here's a simple explaination:
I'll add more to this later...
Dud, look here:
https://sourceforge.net/apps/phpbb/mind ... 2865#p2865
Chrome Extension Development/Themes.
@Matt
Technically, I believe it would be called a buffer overflow, but StackOverflow cooler.
Buffer overflows are one of the oldest hacking techniques used to execute arbitary code. I don't understand the details, but here's a simple explaination:
Code: Select all
byte badCode[] = {0x10, 0x20, 0x30, 0x42, 0x2A, 0x10, 0x10, 0x10}; // Instructions in machine language
byte temp[3];
temp[0] = 0x10;
temp[1] = 0x20;
temp[2] = 0x30;
temp = badCode;
//temp[3] == 0x42!!!
Dud, look here:
https://sourceforge.net/apps/phpbb/mind ... 2865#p2865
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
Ok, but that looks legit to me. Why shouldn't temp[3] = 0x42?muntoo wrote:@Matt
Technically, I believe it would be called a buffer overflow, but StackOverflow cooler.
Buffer overflows are one of the oldest hacking techniques used to execute arbitary code. I don't understand the details, but here's a simple explaination:I'll add more to this later...Code: Select all
byte badCode[] = {0x10, 0x20, 0x30, 0x42, 0x2A, 0x10, 0x10, 0x10}; // Instructions in machine language byte temp[3]; temp[0] = 0x10; temp[1] = 0x20; temp[2] = 0x30; temp = badCode; //temp[3] == 0x42!!!
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: TextEdit
It will. BUT temp was only initialized for 3 elements (temp[0-2]). temp[3-7] have been written to. Oh oh.mattallen37 wrote:Ok, but that looks legit to me. Why shouldn't temp[3] = 0x42?
On your NXT, this would probably give you a File Error, if you gave it random data. But if you gave it legitimate machine instructions, something would happen... Depends on the instructions.
I'm probably bringing about a new hacker into this world by explaining all this.
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
Ok, well, it does NOT get program errors when running, so it must be somewhat decent.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: No registered users and 2 guests