TextEdit
Re: TextEdit
Oh. I know it is possible to make it read more than the first line because I have seen it before.
Thanks, and have a nice day,
nxtboy III
programnxt.com
nxtboy III
programnxt.com
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
I don't think there is such a thing as enhanced firmware 1.21.nxtboyiii wrote:I have enhanced FW 1.21...
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's not a bug, it's a feature:sidneys1 wrote:I'm pretty sure chaos theory states that that is wholly impossible Perhaps you should add support for multiline files?dudmaster wrote:
- All bugs fixed
Have a nice day,
~Sidneys1
Also, I don't think it was the chaos theory that states that...
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
I just downloaded the program to look at it, and I see a couple things that you should consider.
I haven't tried the program, but I think you should have the character "0" (zero) in the "Alphabet" array (struct?).
Please indent your code.
Here is an indented version with the 0:
I haven't tried the program, but I think you should have the character "0" (zero) in the "Alphabet" array (struct?).
Please indent your code.
Here is an indented version with the 0:
Code: Select all
/*
Version 7 Features...
@ FontWrap display
@ AutoVersion capable
@ UNLIMITED letter text! (in Read mode)
@ Tutorial
@ Lastest greatest best GUIs
@ User-friendly design
@ Better graphics
@ Multi-function read/write/delete
@ File lister
@ Automatic file extention detector
@ Automatic loop
*/
#download "TextEdit.ric"
#download "wText.ric"
#download "AreYouSure.ric"
#download "TextDelete.ric"
#download "TextOpen.ric"
#download "TextWrite.ric"
#download "TextOptions.ric"
#download "TextRename.ric"
task main()
{
SetLongAbort(2);
string BrickName = BrickDataName();
string Alphabet[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
"v", "w", "x", "y", "z", ".", " ", "!", ",", "(", , ")", "?", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
int LinkNumber, Select;
int TextX2 = 100, TextX1 = 26;
GraphicOut(0, 0, "wText.ric", true);
while (0 == ButtonCount(BTNRIGHT, true) && 0 == Select)
{
Select = ButtonCount(BTNLEFT, true);
if (ButtonCount(BTNEXIT, true))
{
Stop(true);
}
}
if (Select == 1)
{
TextOut(0, LCD_LINE1, "Use arrow keys", true);
TextOut(0, LCD_LINE2, "to select option.");
until (ButtonCount(BTNCENTER, true));
}
MainMenu:
LinkNumber = 0;
TextX2 = 100;
TextX1 = 26;
while (false == ButtonCount(BTNCENTER,true))
{
if (LinkNumber == 0)
{
GraphicOut(12, 3, "TextRename.ric", true);
GraphicOut(42, 3, "TextOpen.ric");
GraphicOut(72, 3, "TextWrite.ric");
TextOut(3, LCD_LINE5, " Read");
}
if (LinkNumber == 1)
{
GraphicOut(72, 3, "TextDelete.ric", true);
GraphicOut(12, 3, "TextOpen.ric");
GraphicOut(42, 3, "TextWrite.ric");
TextOut(0, LCD_LINE5, " Write");
}
if (LinkNumber == 2)
{
GraphicOut(42, 3, "TextDelete.ric", true);
GraphicOut(72, 3, "TextRename.ric");
GraphicOut(12, 3, "TextWrite.ric");
TextOut(3, LCD_LINE5, " Delete");
}
if (LinkNumber == 3)
{
GraphicOut(42, 3, "TextRename.ric", true);
GraphicOut(72, 3, "TextOpen.ric");
GraphicOut(12, 3, "TextDelete.ric");
TextOut(3, LCD_LINE5, " Rename");
}
GraphicOut(0, LCD_LINE3, "TextEdit.ric");
RectOut(38, 23, 24, -300);
TextOut(0, LCD_LINE1, BrickName);
LineOut(0, 54, 99, 54);
if (1 == ButtonCount(BTNLEFT,true))
{
if (1 == LinkNumber || 2 == LinkNumber || 3 == LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
else
{
LinkNumber = 3;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (0 == LinkNumber || 1 == LinkNumber || 2 == LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
else
{
LinkNumber = 0;
}
}
if (ButtonCount(BTNEXIT, true))
{
Stop(true);
}
Wait(50);
}
if (1 == LinkNumber)
{
if (Select == 1)
{
TextOut(0, LCD_LINE1, "You have chosen", true);
TextOut(0, LCD_LINE2, "Write. Type in a");
TextOut(0, LCD_LINE3, "filename to use");
TextOut(0, LCD_LINE4, "and then type in");
TextOut(0, LCD_LINE5, "file content.");
TextOut(0, LCD_LINE6, "Use exit to");
TextOut(0, LCD_LINE6, "backspace or exit.");
until (ButtonCount(BTNCENTER, true));
}
WF:
string Sen = "", Sen2 = "";
bool S = false;
byte handle = 0x00;
int N = 0, LinkNumber = 0, cnt = 0;
while (S == false){
while (0 == ButtonCount(BTNCENTER,true)){
if (ButtonCount(BTNLEFT,true) && N > 0)
{
N--;
}
if (ButtonCount(BTNRIGHT,true) && N < 69)
{
N++;
}
Sen2 = Alphabet[N];
TextOut(0, LCD_LINE1, "File Name:", true);
TextOut(0, LCD_LINE2, SubStr(Sen + Sen2, 0, 18));
TextOut(0, LCD_LINE3, SubStr(Sen + Sen2, 16, 18));
TextOut(0, LCD_LINE4, SubStr(Sen + Sen2, 32, 18));
TextOut(0, LCD_LINE5, SubStr(Sen + Sen2, 48, 18));
TextOut(0, LCD_LINE6, SubStr(Sen + Sen2, 64, 18));
TextOut(0, LCD_LINE7, SubStr(Sen + Sen2, 80, 18));
TextOut(0, LCD_LINE8, SubStr(Sen + Sen2, 96, 18));
if (ButtonCount(BTNEXIT, true))
{
int Bksp = StrLen(Sen);
if (Bksp > 0)
{
Bksp--;
Sen = SubStr(Sen, 0, Bksp);
}
else
{
goto MainMenu;
}
}
Wait(20);
}
Sen = Sen + Sen2;
while (false == ButtonCount(BTNCENTER,true))
{
if (LinkNumber == 0)
{
TextOut(0, LCD_LINE3, "> Next", true);
TextOut(0, LCD_LINE4, " Done");
}
else
{
TextOut(0, LCD_LINE3, " Next", true);
TextOut(0, LCD_LINE4, "> Done");
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (1 == LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (0 == LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
}
Wait(15);
}
if (LinkNumber == 1)
{
S = true;
}
}
int Len = StrLen(Sen);
S = false;
N = 0;
LinkNumber = 0;
S = false;
N = StrLen(Sen);
until (SubStr(Sen, N, 1) == "." || N == 0)
{
N--;
}
int Se;
if (N == 0)
{
TextOut(0, LCD_LINE1, "Add Extention?", true);
TextOut(0, LCD_LINE8, "Yes No");
while (0 == ButtonCount(BTNRIGHT, true) && Se == 0) {
Se = ButtonCount(BTNLEFT, true);
if (ButtonCount(BTNEXIT, true))
{
goto WF;
}
}
if (Se == 1)
{
Sen = Sen + ".txt";
}
}
string SenS = "", SenS2 = "";
S = false;
N = 0;
LinkNumber = 0;
S = false;
handle = 0x00;
LinkNumber = 0;
cnt = 0;
int tX = 100;
while (tX > 0)
{
tX--;
TextOut(tX, LCD_LINE2, "Type content", true);
Wait(18);
}
Wait(SEC_1);
while (tX < 100)
{
tX++;
TextOut(tX, LCD_LINE2, "Type content", true);
Wait(18);
}
while (S == false){
while (0 == ButtonCount(BTNCENTER,true)){
if (ButtonCount(BTNLEFT,true) && N > 0)
{
N--;
}
if (ButtonCount(BTNRIGHT,true) && N < 69)
{
N++;
}
SenS2 = Alphabet[N];
TextOut(0, LCD_LINE1, SubStr(SenS + SenS2, 0, 18), true);
TextOut(0, LCD_LINE2, SubStr(SenS + SenS2, 16, 18));
TextOut(0, LCD_LINE3, SubStr(SenS + SenS2, 32, 18));
TextOut(0, LCD_LINE4, SubStr(SenS + SenS2, 48, 18));
TextOut(0, LCD_LINE5, SubStr(SenS + SenS2, 64, 18));
TextOut(0, LCD_LINE6, SubStr(SenS + SenS2, 80, 18));
TextOut(0, LCD_LINE7, SubStr(SenS + SenS2, 96, 18));
TextOut(0, LCD_LINE8, SubStr(SenS + SenS2, 112, 18));
if (ButtonCount(BTNEXIT, true))
{
int Bksp = StrLen(SenS);
if (Bksp > 0)
{
Bksp--;
SenS = SubStr(SenS, 0, Bksp);
}
else
{
goto WF;
}
}
Wait(20);
}
SenS = SenS + SenS2;
while (false == ButtonCount(BTNCENTER,true))
{
if (LinkNumber == 0)
{
TextOut(0, LCD_LINE3, "> Next", true);
TextOut(0, LCD_LINE4, " Done");
}
else
{
TextOut(0, LCD_LINE3, " Next", true);
TextOut(0, LCD_LINE4, "> Done");
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (1 == LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (0 == LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
}
Wait(15);
}
if (LinkNumber == 1)
{
S = true;
}
}
CreateFile(Sen, 300, handle);
WriteString(handle, SenS, cnt);
CloseFile(handle);
int tX2 = 100;
while (tX2 > 0)
{
tX2--;
TextOut(tX2, LCD_LINE2, "Complete!", true);
Wait(18);
}
Wait(SEC_1);
while (tX2 < 100)
{
tX2++;
TextOut(tX2, LCD_LINE2, "Complete!", true);
Wait(18);
}
}
if (0 == LinkNumber)
{
if (Select == 1)
{
TextOut(0, LCD_LINE1, "You have chosen", true);
TextOut(0, LCD_LINE2, "read. Choose a");
TextOut(0, LCD_LINE3, "file to read.");
until (ButtonCount(BTNCENTER, true));
}
RF:
string Sen = "", Sen2 = "";
bool S = false;
byte handle = 0x00;
int N = 0, LinkNumber = 0, cnt = 0;
ListFilesType args;
args.Pattern = "*.*";
SysListFiles(args);
int i = 0;
if (args.Result == NO_ERR && ArrayLen(args.FileList) > 0)
{
while (0 == ButtonCount(BTNCENTER, true))
{
if (ButtonCount(BTNLEFT, true) && 0 < i)
{
i--;
}
if (ButtonCount(BTNRIGHT, true) && ArrayLen(args.FileList) - 1 > i)
{
i++;
}
TextOut(0, LCD_LINE3, SubStr(args.FileList[i], 0, 18), true);
TextOut(0, LCD_LINE4, SubStr(args.FileList[i], 16, 18));
TextOut(0, LCD_LINE5, SubStr(args.FileList[i], 32, 18));
TextOut(0, LCD_LINE6, SubStr(args.FileList[i], 48, 18));
TextOut(0, LCD_LINE1, "Choose File:");
if (ButtonCount(BTNEXIT, true))
{
goto MainMenu;
}
Wait(50);
}
}
else
{
goto MainMenu;
}
string Name = args.FileList[i];
Sen = Name;
string V = "";
int B = 300;
if(OpenFileRead(Sen,B,handle) == LDR_SUCCESS)
{
ReadLnString(handle,V);
CloseFile(handle);
int Len = StrLen(Sen);
S = false;
N = 0;
LinkNumber = 0;
S = false;
N = StrLen(Sen);
until (SubStr(Sen, N, 1) == "." || N == 0)
{
N--;
}
string Str;
Str = SubStr(Sen, N, Len);
TextOut(0, LCD_LINE1, "Chars Count:", true);
NumOut(0, LCD_LINE2, StrLen(V));
TextOut(0, LCD_LINE4, "File Name:");
TextOut(0, LCD_LINE5, SubStr(Sen, 0, N));
TextOut(0, LCD_LINE6, "Ext: " + Str);
Wait(SEC_2);
int TextWrap = 0;
while (0 == ButtonCount(BTNCENTER, true))
{
if (ButtonCount(BTNLEFT, true) && TextWrap > 0)
{
TextWrap = TextWrap - 100;
}
if (ButtonCount(BTNRIGHT, true) && TextWrap < StrLen(V) - 99)
{
TextWrap = TextWrap + 100;
}
TextOut(0, LCD_LINE1, SubStr(V, TextWrap, 18), true);
TextOut(0, LCD_LINE2, SubStr(V, TextWrap + 16, 18));
TextOut(0, LCD_LINE3, SubStr(V, TextWrap + 32, 18));
TextOut(0, LCD_LINE4, SubStr(V, TextWrap + 48, 18));
TextOut(0, LCD_LINE5, SubStr(V, TextWrap + 64, 18));
TextOut(0, LCD_LINE6, SubStr(V, TextWrap + 80, 18));
TextOut(0, LCD_LINE7, SubStr(V, TextWrap + 96, 18));
TextOut(0, LCD_LINE8, SubStr(V, TextWrap + 112, 18));
if (ButtonCount(BTNEXIT, true))
{
goto RF;
}
Wait(50);
}
}
}
if (2 == LinkNumber)
{
if (Select == 1)
{
TextOut(0, LCD_LINE1, "You have chosen", true);
TextOut(0, LCD_LINE2, "Delete. Choose a");
TextOut(0, LCD_LINE3, "file to delete.");
until (ButtonCount(BTNCENTER, true));
}
DF:
string Sen = "", Sen2 = "";
bool S = false;
byte handle = 0x00;
int N = 0, LinkNumber = 0, cnt = 0;
ListFilesType args;
args.Pattern = "*.*";
SysListFiles(args);
int i = 0;
if (args.Result == NO_ERR && ArrayLen(args.FileList) > 0)
{
while (0 == ButtonCount(BTNCENTER, true))
{
if (ButtonCount(BTNLEFT, true) && 0 < i)
{
i--;
}
if (ButtonCount(BTNRIGHT, true) && ArrayLen(args.FileList) - 1 > i)
{
i++;
}
TextOut(0, LCD_LINE3, SubStr(args.FileList[i], 0, 18), true);
TextOut(0, LCD_LINE4, SubStr(args.FileList[i], 16, 18));
TextOut(0, LCD_LINE5, SubStr(args.FileList[i], 32, 18));
TextOut(0, LCD_LINE6, SubStr(args.FileList[i], 48, 18));
TextOut(0, LCD_LINE1, "Choose File:");
if (ButtonCount(BTNEXIT, true))
{
goto MainMenu;
}
Wait(50);
}
}
else
{
goto MainMenu;
}
string Name = args.FileList[i];
Sen = Name;
int Select2 = 0;
GraphicOut(0, 0, "AreYouSure.ric", true);
while (0 == ButtonCount(BTNRIGHT, true) && 0 == Select2)
{
Select2 = ButtonCount(BTNLEFT, true);
if (ButtonCount(BTNEXIT, true))
{
goto DF;
}
}
int tX = 100;
if (1 == Select2) {
DeleteFile(Sen);
while (tX > 0)
{
tX--;
TextOut(tX, LCD_LINE2, "Complete!", true);
Wait(18);
}
Wait(SEC_1);
while (tX < 100)
{
tX++;
TextOut(tX, LCD_LINE2, "Complete!", true);
Wait(18);
}
}
if (0 == Select2) {
while (tX > 0)
{
tX--;
TextOut(tX, LCD_LINE2, "Canceled!", true);
Wait(18);
}
Wait(SEC_1);
while (tX < 100)
{
tX++;
TextOut(tX, LCD_LINE2, "Canceled!", true);
Wait(18);
}
}
}
if (LinkNumber == 3)
{
if (Select == 1)
{
TextOut(0, LCD_LINE1, "You have chosen", true);
TextOut(0, LCD_LINE2, "Rename. Choose a");
TextOut(0, LCD_LINE3, "file to rename.");
TextOut(0, LCD_LINE3, "Then, type in");
TextOut(0, LCD_LINE3, "a new filename.");
until (ButtonCount(BTNCENTER, true));
}
CF:
int N = 0, cnt = 0;
LinkNumber = 0;
ListFilesType args;
args.Pattern = "*.*";
SysListFiles(args);
int i = 0;
if (args.Result == NO_ERR && ArrayLen(args.FileList) > 0)
{
while (0 == ButtonCount(BTNCENTER, true))
{
if (ButtonCount(BTNLEFT, true) && 0 < i)
{
i--;
}
if (ButtonCount(BTNRIGHT, true) && ArrayLen(args.FileList) - 1 > i)
{
i++;
}
TextOut(0, LCD_LINE3, SubStr(args.FileList[i], 0, 18), true);
TextOut(0, LCD_LINE4, SubStr(args.FileList[i], 16, 18));
TextOut(0, LCD_LINE5, SubStr(args.FileList[i], 32, 18));
TextOut(0, LCD_LINE6, SubStr(args.FileList[i], 48, 18));
TextOut(0, LCD_LINE1, "Choose File:");
if (ButtonCount(BTNEXIT, true))
{
goto MainMenu;
}
Wait(50);
}
}
else
{
goto MainMenu;
}
string Name = args.FileList[i];
string Sen = "", Sen2 = "";
bool S = false;
byte handle = 0x00;
N = 0, LinkNumber = 0, cnt = 0;
while (S == false){
while (0 == ButtonCount(BTNCENTER,true)){
if (ButtonCount(BTNLEFT,true) && N > 0)
{
N--;
}
if (ButtonCount(BTNRIGHT,true) && N < 69)
{
N++;
}
Sen2 = Alphabet[N];
TextOut(0, LCD_LINE1, "New Name:", true);
TextOut(0, LCD_LINE2, SubStr(Sen + Sen2, 0, 18));
TextOut(0, LCD_LINE3, SubStr(Sen + Sen2, 16, 18));
TextOut(0, LCD_LINE4, SubStr(Sen + Sen2, 32, 18));
TextOut(0, LCD_LINE5, SubStr(Sen + Sen2, 48, 18));
TextOut(0, LCD_LINE6, SubStr(Sen + Sen2, 64, 18));
TextOut(0, LCD_LINE7, SubStr(Sen + Sen2, 80, 18));
TextOut(0, LCD_LINE8, SubStr(Sen + Sen2, 96, 18));
if (ButtonCount(BTNEXIT, true))
{
goto CF;
}
Wait(20);
}
Sen = Sen + Sen2;
while (false == ButtonCount(BTNCENTER,true))
{
if (LinkNumber == 0)
{
TextOut(0, LCD_LINE3, "> Next", true);
TextOut(0, LCD_LINE4, " Done");
}
else
{
TextOut(0, LCD_LINE3, " Next", true);
TextOut(0, LCD_LINE4, "> Done");
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (1 == LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (0 == LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
}
Wait(15);
}
if (LinkNumber == 1)
{
S = true;
}
}
rename(Name, Sen);
}
goto MainMenu;
}
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
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
I read multiple lines with the ReadLnString command, I just do it multiple times (as many times as there are lines). To write multiple lines, I use the WriteLnString command (again, as many times as I want lines). I am not exactly sure how that would be added to your program, but that is what I do to read and write multiple lines.dudmaster wrote:So, how do i do this? (Add multiple line support)
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
I need to find out how many lines are in this text. How do i do that?
2Labz.com, My Website
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: TextEdit
For what little I have done, I did something like the following.I hope you can get something out of that.
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++
}
}
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
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: TextEdit
Here's something you may find interesting. Often, when I'm doing something like this, I'll create a single image to represent the whole screen, and pass it parameters for values that will change.
Here's what I mean. I created a "main menu" graphic (attached). Pass it three parameters which represent the three menu items you want to show.
Hopefully, this code shows enough for you to understand what I mean...
Values...
Does that make sense?
Steve
Here's what I mean. I created a "main menu" graphic (attached). Pass it three parameters which represent the three menu items you want to show.
Hopefully, this code shows enough for you to understand what I mean...
Code: Select all
int Params[] = {0,0,0};
... later in program
Params[0] = value1;
Params[1] = value2;
Params[2] = value3;
GraphicOutEx(0,0, "TextMain.ric", Params, 0);
- 1 Open (read)
2 Write
3 Delete
4 Rename
5 Options
0 = no item
Does that make sense?
Steve
- Attachments
-
- TextMain.zip
- (444 Bytes) Downloaded 340 times
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: TextEdit
This is my version. The problem with Matt's code is that TotalMessage[] can suffer a STACKOVERFLOW [Beethoven's Symphony No. 5 ].mattallen37 wrote:For what little I have done, I did something like the following.I hope you can get something out of that.
Also, you forgot to add a `;` after the `i++`.
*I really wish we could turn `` into code snippets...
Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE
Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Who is online
Users browsing this forum: No registered users and 4 guests