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 / 27004
27003  |  27005
Subject: 
Re: NXC/NBC release news
Newsgroups: 
lugnet.robotics
Date: 
Fri, 30 Mar 2007 14:11:44 GMT
Original-From: 
davis_nxt <dmle@IHATESPAMdoc.ic.ac.uk>
Viewed: 
11055 times
  
Hi,

Sorry for asking a naive question but I have been trying to create and
manipulate an array
of strings in NXC without much success. Here is the little test program that
I use:

#include "NXCDefs.h"

task main() {
  string sarr[];
  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);
}

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?

Any help is much appreciated.

Thanks,
Duc

John Hansen-4 wrote:
> 
> I have posted sourcecode and the win32 build of beta 25 for NBC/NXC.  The
> Linux
> and Mac OSX binaries will be available later today.
> 
> February 8, 2007 - NBC 1.0.1.b25 beta is available.
> 
> - Fixes a string whitespace bug introduced in b22
> - Fixes a division bug where 1st operand is negative and 2nd operand is
> unsigned
> - Fixes bugs in the NBC and NXC file I/O macros
> - Adds support in NXC for string indexing
>     string msg = "test";
>     msg[0] = 'C';
>     byte x = msg[2];
> - Adds support in NXC for inline functions
>     inline int Double(const int x) { return x*2; }
> - Adds support in NXC for const and reference function argument types
>     bool IsFooBar(int x, int &handle) { handle = 10; x = x+1; return x >
> 2; }
> - Adds support in NXC for const variable declarations
>     const int myVar = 12; // myVar cannot be changed.
> - Adds support in NXC for arrays of strings
>     string myStrings[];
>     ArrayInit(myStrings, "", 4); // set array of strings to a size of 4
> (0..3)
>     myStrings[0] = "please work";
>     myStrings[1] = "testing";
> - Improves NXC parameter type checking in function calls
> - Adds NBC API macros to simplify NXT<->NXT bluetooth communication
>     ReceiveRemoteBool(queue, clear, bval, result)
>     ReceiveRemoteNumber(queue, clear, val, result)
>     ReceiveRemoteString(queue, clear, str, result)
>     ReceiveRemoteMessageEx(queue, clear, str, val, bval, result)
>     SendRemoteBool(conn, queue, bval, result)
>     SendRemoteNumber(conn, queue, val, result)
>     SendRemoteString(conn, queue, str, result)
>     SendResponseBool(queue, bval, result)
>     SendResponseNumber(queue, val, result)
>     SendResponseString(queue, msg, result)
> - Adds NBC API macros for sending direct commands to another NXT
>     RemoteMessageRead(conn, queue, result)
>     RemoteMessageWrite(conn, queue, msg, result) // alias for
> SendRemoteString
>     RemoteStartProgram(conn, filename, result)
>     RemoteStopProgram(conn, result)
>     RemotePlaySoundFile(conn, filename, bloop, result)
>     RemotePlayTone(conn, frequency, duration, result)
>     RemoteStopSound(conn, result)
>     RemoteKeepAlive(conn, result)
>     RemoteResetScaledValue(conn, port, result)
>     RemoteResetMotorPosition(conn, port, brelative, result)
>     RemoteSetInputMode(conn, port, type, mode, result)
>     RemoteSetOutputState(conn, port, speed, mode, regmode, turnpct,
> runstate,
> tacholimit, result)
> - Adds NXC API macros to simplify NXT<->NXT bluetooth communication
>     result = ReceiveRemoteBool(queue, clear, bval)
>     result = ReceiveRemoteNumber(queue, clear, val)
>     result = ReceiveRemoteString(queue, clear, str)
>     result = ReceiveRemoteMessageEx(queue, clear, str, val, bval)
>     result = SendRemoteBool(conn, queue, bval)
>     result = SendRemoteNumber(conn, queue, val)
>     result = SendRemoteString(conn, queue, str)
>     result = SendResponseBool(queue, bval)
>     result = SendResponseNumber(queue, val)
>     result = SendResponseString(queue, msg)
> - Adds NXC API macros for sending direct commands to another NXT
>     result = RemoteMessageRead(conn, queue)
>     result = RemoteMessageWrite(conn, queue, msg) // alias for
> SendRemoteString
>     result = RemoteStartProgram(conn, filename)
>     result = RemoteStopProgram(conn)
>     result = RemotePlaySoundFile(conn, filename, bloop)
>     result = RemotePlayTone(conn, frequency, duration)
>     result = RemoteStopSound(conn)
>     result = RemoteKeepAlive(conn)
>     result = RemoteResetScaledValue(conn, port)
>     result = RemoteResetMotorPosition(conn, port, brelative)
>     result = RemoteSetInputMode(conn, port, type, mode)
>     result = RemoteSetOutputState(conn, port, speed, mode, regmode,
> turnpct,
> runstate, tacholimit)
> 
> John Hansen
> http://bricxcc.sourceforge.net/
> 
> 

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



Message has 1 Reply:
  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 (...) (19 years ago, 30-Mar-07, to lugnet.robotics)

Message is in Reply To:
  NXC/NBC release news
 
I have posted sourcecode and the win32 build of beta 25 for NBC/NXC. The Linux and Mac OSX binaries will be available later today. February 8, 2007 - NBC 1.0.1.b25 beta is available. - Fixes a string whitespace bug introduced in b22 - Fixes a (...) (20 years ago, 9-Feb-07, to lugnet.robotics, lugnet.robotics.nxt)

4 Messages in This Thread:

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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

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