To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 27013
27012  |  27014
Subject: 
Re: NXC/NBC release news
Newsgroups: 
lugnet.robotics
Date: 
Mon, 2 Apr 2007 12:36:34 GMT
Original-From: 
davis_nxt <dmle@doc.ic.ac^nospam^.uk>
Viewed: 
4822 times
  
Hi John,

Thank you for your reply. I will try your suggestion and let you know how it
goes.

Regards,
Davis


John Hansen-4 wrote:

In lugnet.robotics, davis_nxt <dmle@doc.ic.ac.uk> wrote:
I would have expected the string "hello world" to be printed. However, "*
*"
is printed instead.
It seems that the value assignment operators for sarr's elements did not
work.
Am I using the right syntax?

The standard NXT firmware has a bug in the replace opcode which makes it
impossible to use with multi-dimensional arrays (or ragged arrays of
arrays).  I
have fixed this bug and submitted the code to folks at NI and LEGO for
possible
inclusion in the next official firmware update.  Hopefully they will
include it.
In the meantime you can use my unofficial build of the standard NXT
firmware.
It includes this fix.  If you install the unofficial firmware image then
you
should be able to use the code as you have it written without any
problems.

The alternative is to build the contents of the string array using
ArrayBuild*
or to write it in an asm block with the arrbuild opcode (which is all the
ArrayBuild* API functions do).

Like this:

#include "NXCDefs.h"

task main() {
  string sarr[];
  ArrayBuild3(sarr, "hello", "world", "*");
/*
  ArrayInit(sarr, "*",3);
  string s1 = "hello";
  string s2 = "world";
  sarr[0]=s1;
  sarr[1]=s2;
*/
  string ss1 = sarr[0];
  string ss2 = sarr[1];
  string tmp = StrCat(ss1, ss2);
  TextOut(0, LCD_LINE1, tmp);
  Wait(3000);
}


John Hansen



--
View this message in context: http://www.nabble.com/NXC-NBC-release-news-tf3197029.html#a9789759
Sent from the LEGO Robotics mailing list archive at Nabble.com.



Message is in Reply To:
  Re: NXC/NBC release news
 
(...) The standard NXT firmware has a bug in the replace opcode which makes it impossible to use with multi-dimensional arrays (or ragged arrays of arrays). I have fixed this bug and submitted the code to folks at NI and LEGO for possible inclusion (...) (18 years ago, 30-Mar-07, to lugnet.robotics)

4 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR