Go to Post To quote Dylan, "When you aint got nothing, you got nothing to lose". - KenWittlief [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 21-03-2015, 15:27
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Preferences table Null Pointer Exception

The sample on that page seems to be missing a line:

prefs = Preferences.getInstance();
  #2   Spotlight this post!  
Unread 21-03-2015, 21:33
Arhowk's Avatar
Arhowk Arhowk is offline
FiM CSA
AKA: Jake Niman
FRC #1684 (The Chimeras) (5460 Mentor)
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Lapeer
Posts: 542
Arhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to beholdArhowk is a splendid one to behold
Re: Preferences table Null Pointer Exception

Quote:
Originally Posted by RufflesRidge View Post
The sample on that page seems to be missing a line:

prefs = Preferences.getInstance();
You're right! Thats quite funny. Here's the actual code for reference

Code:
package org.usfirst.frc.team40.robot;

import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Preferences;

public class Robot extends SampleRobot{

    Preferences prefs;
    double armUpPosition;
    double armDownPosition;
    public void robotInit(){
        prefs = Preferences.getInstance();
        armUpPosition = prefs.getDouble("ArmUpPosition", 1.0);
        armDownPosition = prefs.getDouble("ArmDownPosition", 4.0);
    }
}
On a side note, to follow NetworkTable conventions the method name should be "getNumber" but that is trivial.
  #3   Spotlight this post!  
Unread 22-03-2015, 00:05
L1TH1UM L1TH1UM is offline
Registered User
FRC #4334
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2015
Location: Calgary, AB
Posts: 4
L1TH1UM is an unknown quantity at this point
Re: Preferences table Null Pointer Exception

Thank you, I appreciate it. This fixed our problem.
  #4   Spotlight this post!  
Unread 22-03-2015, 10:57
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 577
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: Preferences table Null Pointer Exception

If you didn't do so already, please use the form on the page to report the error.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi