Author Topic: How to get input from user in ndless sdk ?  (Read 11780 times)

0 Members and 1 Guest are viewing this topic.

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
How to get input from user in ndless sdk ?
« on: November 17, 2014, 02:47:47 pm »
Hi
I'm a new user and my calc is TI Nspire CX CAS
First: How can i write code in c++ not c ?
Second :I'm good in c++ but i can't make input from user how can i do this ?
Third : I write a code in c and I use "scanf()" to take input from user and when I test it on emulator , the emulator stuck what the problem ?
Forth : What is the important include that i should write before the program ? " the program contains input from user "
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #1 on: November 17, 2014, 03:19:29 pm »
Quote
Hi
I'm a new user and my calc is TI Nspire CX CAS
First: How can i write code in c++ not c ?
Use .cpp as file extension, not .c.

Quote
Second :I'm good in c++ but i can't make input from user how can i do this ?
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.

Quote
Third : I write a code in c and I use "scanf()" to take input from user and when I test it on emulator , the emulator stuck what the problem ?
It waits for serial input. By default std* are the first UART.

Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "
?

Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?
There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux. You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #2 on: November 17, 2014, 03:57:31 pm »
Thank you for reply

Quote
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.
What is the header file that i will include it will be "#include <nspire-io> ?

Quote
It waits for serial input. By default std* are the first UART.
This is my code (I still learning and test small codes)

#include <os.h>
int main() {
   printf ("!!!Hello World!!!");
   int x ;
   scanf("%d" , &x);
   printf ("The  value is : %d" , x)
   return 0;
}
What is the problem for this code (The prog not start to write an input)

Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "
I mean what is the main (#include <>) that without it the app doesn't run ?

Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?
There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux. You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.

can you give me link contains example for GUI code ?
Thanks in advance

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #3 on: November 17, 2014, 04:03:36 pm »
Thank you for reply

Quote
Use nspire-io, directly or indirectly. The new SDK at https://github.com/ndless-nspire/Ndless has nspire-io support built-in, just look at samples/newlib.
You can use scanf, std::cin, ifstream, whatever you like.
What is the header file that i will include it will be "#include <nspire-io> ?
#include <nspireio/nspireio.h>

Quote
Quote
It waits for serial input. By default std* are the first UART.
This is my code (I still learning and test small codes)

#include <os.h>
int main() {
   printf ("!!!Hello World!!!");
   int x ;
   scanf("%d" , &x);
   printf ("The  value is : %d" , x)
   return 0;
}
What is the problem for this code (The prog not start to write an input)
Try a newline or puts instead of printf.
Quote
Quote
Forth : What is the important include that i should write before the program ? " the program contains input from user "

I mean what is the main (#include <>) that without it the app doesn't run ?
There is no such #include, although you need to #include <os.h> on the old sdk to do something useful.


Quote
Quote
Fifth and least : is there any tutorial "pdf or videos " for programming ti nspire cx cas ? can I make a GUI app ?

There is only http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux. You can use some graphics libs like nSDL, n2dlib or nGL or rip an existing program apart and use its GUI stuff, like pyWrite.

can you give me link contains example for GUI code ?
That depends on how you want to do GUI development, which library you use.



Quote

Thanks in advance

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #4 on: November 17, 2014, 04:20:49 pm »
for the GUI
I still in the start and I don't know anything of them
So I wish you recommend me anyone of them to start learn it
I need a simple gui .

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #5 on: November 17, 2014, 04:35:53 pm »
Quote
for the GUI
I still in the start and I don't know anything of them
So I wish you recommend me anyone of them to start learn it
I need a simple gui .
Well, if text is enough you can use nspire-io to display text at specified positions and move using the cursor keys. Or if you want 2d graphics, use nSDL, nGC, n2DLib or nGL.

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #6 on: November 17, 2014, 04:42:51 pm »
Edited (I make some edit in the code but still has a problem)
The code is :
#include <os.h>
#include <iostream>
#include <stdlib.h>
#include <libndls.h>
using namespace std;
int main() {
   cout<<"!!!Hello World!!!";
   int x ;
   cin>> x;
   cout<<"The  value is :" << x ;
   return 0;
}
The compile result :
>C:\ndless-sdk-v3.6-r53.464a532/mingw-get/msys/1.0/bin/sh -l -c 'PATH="$PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless/bin:/C/ndless-sdk-v3.6-r53.464a532/yagarto/bin\' C_INCLUDE_PATH="$C_INCLUDE_PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless_pc/include\' LIBRARY_PATH="$LIBRARY_PATH":\'/C/ndless-sdk-v3.6-r53.464a532/ndless_pc/lib\' \'/C/ndless-sdk-v3.6-r53.464a532/ndless/bin/nspire-gcc\' -Os -c hello.cpp'
>Exit code: 0

The Build result :
Please choose a name for the program below.
Makefile created. You can now build with the 'make' command or Ndless Editor's Tools>Build command.
mkdir -p .
nspire-ld-bflt hello.o -o ./First.tns  --cpp
c:/ndless-sdk-v3.6-r53.464a532/yagarto-20121222/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol lf2flt; defaulting to 00000000
Built.

When i test it on emu (I'm already install ndless on  emu and check before i run the prog.)
apper a message that prog. not supported
other thing the cpp file is 1 kB
The TNS file is 4.1 MB ? it seems large 
« Last Edit: November 17, 2014, 05:40:12 pm by Mohammed Elborolossy »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #7 on: November 18, 2014, 04:02:04 am »
That's expected, to use libstdc++ you have to use the new SDK.

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #8 on: November 19, 2014, 02:34:16 am »
That's expected, to use libstdc++ you have to use the new SDK.
I still has the same problem
I tried the two version from  the official ndless site
If you Anyone has the (Ndless sdk) and work fine with c++ and emulator please upload the folder
Thanks in advance

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #9 on: November 19, 2014, 05:41:34 am »
Quote
I tried the two version from  the official ndless site
They're both the old sdk. The new SDK is on Github.

Quote
If you Anyone has the (Ndless sdk) and work fine with c++ and emulator please upload the folder
Windows? Cygwin?

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #10 on: November 19, 2014, 01:33:23 pm »

Windows? Cygwin?

I'm using windows 8.1
What do you mean about Cygwin ?

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: How to get input from user in ndless sdk ?
« Reply #11 on: November 19, 2014, 01:34:52 pm »
Cygwin is a program which gives a unix-like mini environment to a Windows user. It installs some binaries, a folder with the structure of a Linux distribution, a shell ( a command line program, like command invite) and you have a similar environement as a Linux should be.

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #12 on: November 19, 2014, 01:46:21 pm »
Cygwin is a program which gives a unix-like mini environment to a Windows user. It installs some binaries, a folder with the structure of a Linux distribution, a shell ( a command line program, like command invite) and you have a similar environement as a Linux should be.
I have Ubuntu and windows 8.1 and I try the booth
In Ubuntu : I follow this tutorial : http://hackspire.unsads.com/wiki/index.php/C_and_assembly_development_introduction_on_Linux
After this code "./build_toolchain.sh" and after download i get two errors and try to solve them but not success
In windows 8.1 : I download the sdk and a download yagarto additional files and write a c++ program the compile complete but in build there is an error : cannot find entry symbol lf2flt; defaulting to 00000000


[/size]

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1192
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #13 on: November 19, 2014, 02:00:29 pm »
It's better if you use Linux.
Quote
After this code "./build_toolchain.sh"  and after download i get two errors and try to solve them but not success
Which two errors?

Offline Mohammed Elborolossy

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: How to get input from user in ndless sdk ?
« Reply #14 on: November 19, 2014, 02:08:36 pm »
I think that this is one :

configure: error: no termcap library found
I search for "termcap" in synaptic but not found it