Variable size array output from dynamic dispatch class method on FPGA

I have a Parent class on the FPGA that will serve as a template/framework for future code that will be developed. I had planned on creating a child class and overriding a couple methods. The child class constant would be dropped on the block diagram so the compiler wouldn't have any trouble figuring out which method (parent's or child's) should be used (i.e. the parent's method will never actually be used and won't be compiled with the main code). The output of one of the methods is an array. This array will have a different size depending on the application. I defined the array size as variable. In the child method, there is no question about the size of the array so the compiler should be able to figure it out. However, when I try to compile, I get an error about the array size. I can't figure out any way around it. Any thought would be greatly appreciated! 
Thanks, Patrick
Solved!
Go to Solution.
Attachments:
FPGA Test.zip ‏1194 KB

Wait what?
Can we use dynamic dispatch VIs on FPGA?  Really?  I was completely unaware of this.  Obviously the dependencies need to be constant and known at compile time but...... This would have saved me a lot of headaches in the last few months.
Since which LV version is this supported?
Say hello to my little friend.
RFC 2323 FHE-Compliant

Similar Messages

  • Problem with combination of LabVIEW classes (dynamic dispatch), statechart module and FPGA module

    SITUATION:
    - I am developing a plug-in-based software with plug-ins based on LabVIEW classes which are instanced at run-time. The actual plug-in classes are derived from generic plug-in classes that define the interfaces to the instancing VI and may provide basic functionality. This means that many of the classes' methods are dynamic dispatch and methods of child classes may even call the parent method.
    - Top-level plug-ins (those directly accessed by the main VI) each have a run method that drives a plug-in-specific statechart.
    - The statechart of the data acquisition plug-in class (DAQ class) calls a method of the DAQ class that reads in data from a NI FPGA card and passes it on to another component via a queue.
    PROBLEM:
    - At higher sampling rates, an FPGA-to-host FIFO overflow occurs after some time. When I "burden" the system just by moving a Firefox browser window over the screen, the overflow is immediately triggered. I did not have this kind of problem in an older software, where I was also reading from an FPGA FIFO, but did not make use of LabVIEW classes or statecharts.
    TRIED SOLUTIONS (WITHOUT SUCCESS):
    - I put the statechart into a timed loop (instead of a simple while loop) which I assigned specifically to an own core (I have a quad-core processor), while I left all the other loops of my application (there are many of them) in simple while loops. The FIFO overflow still does occur, however. 
    QUESTION:
    - Does anybody have a hint how I could tackle this problem? What could be the cause: the dynamic dispatch methods, the DAQ statechart or just the fact that I have a large number of loops? However, I can hardly change the fact that I have dynamic dispatch methods because that's the very core of my architecture... 
    Any hints are greatly appreciated!
    Message Edited by dlanger on 06-25-2009 04:18 AM
    Message Edited by dlanger on 06-25-2009 04:19 AM
    Solved!
    Go to Solution.

    I now changed the execution priority of all the VIs involved in reading from the FPGA FIFO to "time critical priority (highest)". This seems to improve the situation very much: so far I did not get a FIFO overflow anymore, even when I move around windows on the screen. I hope it stays like this...

  • How can I create a variable size array?

    How can I create a variable size array?

    ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
    After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
    Anyway, the answer to your question is, of course:
    Vector v = new Vector();(But you should probably use ArrayList instead of Vector.)

  • Array output from formula node

    How to get an array output from the formula node.I am trying to use a for loop inside the formula node and want an array output.

    You cannot place a For or While Loop inside the formula node.
    Here is what the Help Description says about the syntax inside the Formula Node:
    Formula Node
    Evaluates mathematical formulas and expressions similar to C on the block diagram. The following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh. There are some differences between the parser in the Mathematics VIs and the Formula Node.
     Place on the block diagram
     Find on the Functions palette
    Refer to Creating Formula Nodes and Formula Node Syntax for more information about the Formula Node and the Formula Node syntax.
    Note  The Formula Node accepts only the period (.) as a decimal separator. The node does not recognize localized decimal separators.
    <SCRIPT type=text/javascript>if (typeof(writeVarRefs)=="function"){writeVarRefs("763");}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvrthelp763) != "undefined"){document.writeln(lvrthelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvfpga763) != "undefined"){document.writeln(lvfpga763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvemb763) != "undefined"){document.writeln(lvemb763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvpdahelp763) != "undefined"){document.writeln(lvpdahelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvtpchelp763) != "undefined"){document.writeln(lvtpchelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvblackfin763) != "undefined"){document.writeln(lvblackfin763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvdsp763) != "undefined"){document.writeln(lvdsp763)}</SCRIPT>
    Example
    Refer to the Create Function with Formula Node VI in the labview\examples\general\structs.llb for an example of using the Formula Node.

  • Array output from formula node with input variable as array size

    Hi,
    I have created a formula node with an array output called al, but I get an error "you have connected a scalar type to an array with that type".
    I declare the output as follows..
    float64 al[len_as];
    where len_as is an scalar input to the formula node.
    It only works when I put a number as.
    float64 al[5];
    ,but I don't know beforehand how many elements I need, so I cannot use this.
    Please help! This is so stupid.
    Thanks

    Don't define your array in your formula node.
    Initialize the array as the size you want and pass it in as an input into the formula node.
    Are you sure you even need to use a formula node?  Can you implement your formula using all native LabVIEW functions?
    Message Edited by Ravens Fan on 10-07-2009 11:51 PM
    Attachments:
    Example_VI_BD.png ‏3 KB

  • Variable size array in a FlowPane

    If i have an array of variable size (for example a array of cards).
    How can i build something to show the elements(in a FlowPane for example) and each of them having its own controller (fxml + controller for each card), so the container (flow pane) of the elements (cards) can have it's elements swaped, removed or added new ones?
    Controller:
    public class HandController extends FlowPane implements Initializable{
        @Override public void initialize(URL arg0, ResourceBundle arg1){
        public void setHand(ArrayList<Cards> Hand){
            //this would work if the hand were static
            for(int i = 0; i < Hand.size(); ++i){
                FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("CardView.fxml"));
                CardController controller = new CardController();
                fxmlLoader.setController(controller);
                fxmlLoader.setRoot(controller);
                Parent card = (Parent)fxmlLoader.load();
                fxmlLoader.setRoot(card);
                this.getChildren().add(card);
                controller.setCard(Hand.get(i));
    }Fxml:
    <fx:root type="FlowPane" xmlns:fx="http://javafx.com/fxml"
             stylesheets="view/Style.css">
        <children>
            <!--should i put something here?-->
        </children>
    </fx:root>

    Well, I was bored...
    This "game" has a hand of up to five cards. You can deal from a deck to the hand, and then play (or discard) a card by double-clicking on it.
    The model comprises a Card class, a Deck class, and a GameModel class. The last one tracks the hand and deck and the relationship between them. Card and Deck were written from my memory of reading an example of using Enums by Josh Bloch.
    Card.java
    package cardgame;
    public class Card {
         public enum Rank {
              Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
         public enum Suit {
              Clubs, Diamonds, Hearts, Spades
         private final Rank rank;
         private final Suit suit;
         public Card(Rank rank, Suit suit) {
              this.rank = rank;
              this.suit = suit;
         public Rank getRank() {
              return rank;
         public Suit getSuit() {
              return suit;
         @Override
         public String toString() {
              return String.format("%s of %s", rank, suit);
         @Override
         public int hashCode() {
              final int prime = 31;
              int result = 1;
              result = prime * result + ((rank == null) ? 0 : rank.hashCode());
              result = prime * result + ((suit == null) ? 0 : suit.hashCode());
              return result;
         @Override
         public boolean equals(Object obj) {
              if (this == obj)
                   return true;
              if (obj == null)
                   return false;
              if (getClass() != obj.getClass())
                   return false;
              Card other = (Card) obj;
              if (rank != other.rank)
                   return false;
              if (suit != other.suit)
                   return false;
              return true;
    }Deck.java
    package cardgame;
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Random;
    import cardgame.Card.Rank;
    import cardgame.Card.Suit;
    public class Deck {
         private final List<Card> cards;
         private Deck() {
              cards = new LinkedList<Card>();
              for (Suit suit : Suit.values())
                   for (Rank rank : Rank.values())
                        cards.add(new Card(rank, suit));
         public static Deck newDeck() {
              return new Deck();
         public static Deck shuffledDeck() {
              return newDeck().shuffle();
         public Deck shuffle() {
              final List<Card> copy = new ArrayList<Card>(cards.size());
              Random rng = new Random();
              while (cards.size() > 0) {
                   int index = rng.nextInt(cards.size());
                   copy.add(cards.remove(index));
              cards.clear();
              cards.addAll(copy);
              return this;
         public Card deal() {
              return cards.remove(0);
         public int size() {
              return cards.size();
    }GameModel.java
    package cardgame;
    import javafx.beans.binding.BooleanBinding;
    import javafx.beans.property.BooleanProperty;
    import javafx.beans.property.ReadOnlyBooleanProperty;
    import javafx.beans.property.SimpleBooleanProperty;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    public class GameModel {
         private ObservableList<Card> hand;
         private Deck deck;
         private BooleanProperty canDeal;
         public GameModel() {
              this.hand = FXCollections.observableArrayList();
              this.deck = Deck.newDeck().shuffle();
              this.canDeal = new SimpleBooleanProperty(this, "canDeal");
              canDeal.bind(new BooleanBinding() {
                        super.bind(hand);
                   @Override
                   protected boolean computeValue() {
                        return deck.size() > 0 && hand.size() < 5;
         public ObservableList<Card> getHand() {
              return hand;
         public ReadOnlyBooleanProperty canDealProperty() {
              return canDeal;
         public boolean canDeal() {
              return canDeal.get();
         public void deal() throws IllegalStateException {
              if (deck.size() <= 0) {
                   throw new IllegalStateException("No cards left to deal");
              if (hand.size() >= 5) {
                   throw new IllegalStateException("Hand is full");
              hand.add(deck.deal());
         public void playCard(Card card) throws IllegalStateException {
              if (hand.contains(card)) {
                   hand.remove(card);
              } else {
                   throw new IllegalStateException("Hand does not contain " + card);
    }The CardController is the controller for a CardView. It takes a reference to a Card and its initialize method initializes the view to display it (the view is just a simple label).
    CardController.java
    package cardgame;
    import javafx.fxml.FXML;
    import javafx.scene.control.Label;
    public class CardController {
         private final Card card;
         @FXML
         private Label label;
         public CardController(Card card) {
              this.card = card;
         public void initialize() {
              label.setText(String.format("%s%nof%n%s", card.getRank(),
                        card.getSuit()));
    }The HandController is the controller for the display of the hand. This is where most of the action happens. The trick here is that it requires a reference to a GameModel, which needs to be injected from somewhere, so we need a setModel(...) method, or something similar. I didn't want to assume the order of events: i.e. whether the model is injected before or after the initialize() method is invoked. To keep this flexibility, I used an ObjectProperty to wrap the model, and listen for changes to it. When the model is updated, I register a listener with the hand (exposed by the model). This listener in turn rebuilds the views of the cards when the hand changes. There's also a "deal" button, whose disabled state is managed by binding to a property in the model (using a neat trick from the Bindings class to allow the model value to be dynamic).
    HandController.java
    package cardgame;
    import java.io.IOException;
    import javafx.beans.binding.Bindings;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.ListChangeListener;
    import javafx.event.EventHandler;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Node;
    import javafx.scene.control.Button;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.Pane;
    public class HandController {
         private ObjectProperty<GameModel> model;
         @FXML
         private Pane container;
         @FXML
         private Button dealButton;
         public HandController() {
              this.model = new SimpleObjectProperty<GameModel>(this, "model", null);
              final ListChangeListener<Card> handListener = new ListChangeListener<Card>() {
                   @Override
                   public void onChanged(Change<? extends Card> change) {
                        container.getChildren().clear();
                        try {
                             for (Card card : model.get().getHand()) {
                                  container.getChildren().add(loadCardView(card));
                        } catch (IOException e) {
                             e.printStackTrace();
              model.addListener(new ChangeListener<GameModel>() {
                   @Override
                   public void changed(
                             ObservableValue<? extends GameModel> observable,
                             GameModel oldValue, GameModel newValue) {
                        if (oldValue != null) {
                             oldValue.getHand().removeListener(handListener);
                        if (newValue != null) {
                             newValue.getHand().addListener(handListener);
         public void setModel(GameModel model) {
              this.model.set(model);
         public void initialize() {
              dealButton.disableProperty().bind(
                        Bindings.selectBoolean(model, "canDeal").not());
         private Node loadCardView(final Card card) throws IOException {
              FXMLLoader loader = new FXMLLoader(getClass().getResource(
                        "CardView.fxml"));
              CardController controller = new CardController(card);
              loader.setController(controller);
              Node cardView = (Node) loader.load();
              cardView.setOnMouseClicked(new EventHandler<MouseEvent>() {
                   @Override
                   public void handle(MouseEvent event) {
                        if (event.getClickCount() == 2) {
                             model.get().playCard(card);
              return cardView;
         public void dealCard() {
              model.get().deal();
    }Here are the FXML files:
    CardView.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.StackPane?>
    <?import javafx.scene.control.Label?>
    <?import java.lang.String?>
    <StackPane xmlns:fx="http://javafx.com/fxml" prefHeight="150" prefWidth="80" minWidth="80" maxWidth="80" minHeight="150" maxHeight="150">
         <Label fx:id="label" >
         </Label>
         <styleClass>
              <String fx:value="card"/>
         </styleClass>
    </StackPane>Hand.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.FlowPane?>
    <?import javafx.scene.layout.BorderPane?>
    <?import javafx.scene.control.Button?>
    <?import javafx.scene.control.ScrollPane?>
    <?import java.lang.String?>
    <BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="cardgame.HandController" >
         <center>
              <FlowPane hgap="5" vgap="10" fx:id="container">
              </FlowPane>
         </center>
         <bottom>
              <Button text="Deal" onAction="#dealCard" fx:id="dealButton"/>
         </bottom>
    </BorderPane>The overall application is managed by a Game.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.BorderPane?>
    <BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="cardgame.GameController">
         <center>
              <fx:include source="Hand.fxml" fx:id="hand" />
         </center>
    </BorderPane>with a GameController:
    package cardgame;
    import javafx.fxml.FXML;
    public class GameController {
         @FXML private HandController handController ;
         private GameModel model ;
         public GameController() {
              model = new GameModel();
         public void initialize() {
              handController.setModel(model);
    }Game.java is the main class:
    package cardgame;
    import java.io.IOException;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    public class Game extends Application {
         @Override
         public void start(Stage primaryStage) throws IOException {
              Scene scene = new Scene(FXMLLoader.<Parent>load(getClass().getResource("Game.fxml")), 600, 400, Color.DARKGREEN);
              scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
              primaryStage.setScene(scene);
              primaryStage.show();
         public static void main(String[] args) {
              launch(args);
    }and then a style sheet
    style.css:
    @CHARSET "US-ASCII";
    .card {
         -fx-background-color: white ;
         -fx-border-color: black ;
         -fx-border-radius: 5 ;
         -fx-border-style: solid ;
         -fx-padding: 5 ;
    .card .label {
         -fx-text-alignment: center ;
    }

  • Using output from dynamic DL to add to sharepoint group

    Hi,
    I have output a dynamic DL to a variable $people but am unable to add users to a sharepoint group with the method below:
    $poeple | foreach {Add-SPOUser -Group "US Team Members" -Site https://contoso.sharepoint.com -LoginName $_.PrimarySMTPAddress}
    Output for the above command is Add-SPOUser : Cannot bind argument to parameter 'LoginName'
    Which tells me there is an issue with my variable supplying the PrimarySMTPAddress property. When I check against get-member, it is definitely there. See below:
    PS> $people | gm | findstr -i primary
    PrimarySmtpAddress                     Property     System.String {get;set;}
    I am not sure how to proceed about accomplishing this or if it is even possible. Any help is greatly apprecated! Thanks all!

    I don't have the same cmdlet to test but give this a shot:
    $people | foreach {Add-SPOUser -Group 'US Team Members' -Site 'https://contoso.sharepoint.com' -LoginName "$($_.PrimarySmtpAddress)" }
    or
    foreach ($person in $people)
    Add-SPOUser -Group 'US Team Members' -Site 'https://contoso.sharepoint.com' -LoginName "$($person.PrimarySmtpAddress)"

  • How to modify array elements from a separate class?

    I am trying to modify array elements in a class which populates these fields by reading in a text file. I have got mutator methods to modify the array elements and they work fine in the same class.
    public class Outlet {
         private Outlet[] outlet;
         private String outletName;
         private int phoneNumber;
         private int category;
         private int operatingDays;
    static final int DEFAULT = 99;
         public void setPhoneNumber(int newPhoneNumber) {
              phoneNumber = newPhoneNumber;
         public void setCategory(int newCategory) {
              category = newCategory;
         public void setOperatingDays(int newOperatingDays) {
              operatingDays = newOperatingDays;
    public static void readFile(Outlet[] outlet) throws FileNotFoundException {
              Scanner inFile = new Scanner(new FileReader("outlets.txt"));
              int rowNo = 0;
              int i = 0;
              String outletValue;
              while (inFile.hasNext() && rowNo < MAXOUTLETS) {
                   outlet[rowNo] = new Outlet();
                   outletValue = inFile.nextLine();
                   outlet[rowNo].setOutletName(outletValue.toUpperCase());
                   outlet[rowNo].setPhoneNumber(DEFAULT);
                   outlet[rowNo].setCategory(DEFAULT);
                   outlet[rowNo].setOperatingDays(DEFAULT);
              inFile.close();
         public static void displayUnassignedOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing all unassigned Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   if (outlet.getCategory() == DEFAULT) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
    Now in the other class that I want to modify the array elements I use the following code but I get an error that "The expression type must be an array but a Class ' Outlet' is resolved".
    So how can I modify the array elements? What do I have to instantiate to get the following code to work?
    public class Franchise {
         private Franchise[] franchise;
         public Outlet[] outlet;
         public static void createFranchise(Franchise[] franchise) throws FileNotFoundException {
              Scanner console = new Scanner(System.in);
              int choice = -1;
    ++++++++++++++++++++++++++++++++++++
              Outlet outlet = new Outlet();
              Outlet.readFile(outlet.getOutlet());
    ++++++++++++++++++++++++++++++++++++
              boolean invalidChoice = true;
              while (invalidChoice) {
              System.out.println("\nCreating a New Franchise...");
              System.out.println(STARS);
              System.out.println("Please select an outlet from the list below");
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
              choice = console.nextInt();
              if (choice < 0 || choice > 10) {
                   System.out.println("Error! Please choose a single number between 1 and 10");               
              else {
                   invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Phone Number for this Outlet");
                   choice = console.nextInt();
                   String phone = new String();
              phone = new Integer(choice).toString();
                   if (phone.length() < 8 || phone.length() > 10) {
                        System.out.println("Error! Please enter 8 to 10 digits only");
                   else {
    +++++++++++++++++++++++++++++++++++++++
                        outlet[(choice - 1)].setPhoneNumber(choice);
    +++++++++++++++++++++++++++++++++++++++
                        invalidChoice = false;

    Hi Pete!
    Thanks for your comments. I have included my full classes below with their respective driver modules. Hope this helps out a bit more using the code tags. Sorry, it was my first posting. Thanks for the heads up!
    import java.util.*;
    import java.io.*;
    public class Outlet {
         public Outlet[] outlet;
         private String outletName;
         private int phoneNumber;
         private int category;
         private int operatingDays;
    //     private Applicant chosenApplicant;
         static boolean SHOWDETAILS = false;
         static final String STARS = "****************************************";
         static final int MAXOUTLETS = 10;
         static final int DEFAULT = 99;
         public Outlet[] getOutlet() {
              return outlet;
         public String getOutletName() {
              return outletName;
         public int getPhoneNumber() {
              return phoneNumber;
         public int getCategory() {
              return category;
         public int getOperatingDays() {
              return operatingDays;
         public void setOutletName(String newOutletName) {
              outletName = newOutletName;
         public void setPhoneNumber(int newPhoneNumber) {
              phoneNumber = newPhoneNumber;
         public void setCategory(int newCategory) {
              category = newCategory;
         public void setOperatingDays(int newOperatingDays) {
              operatingDays = newOperatingDays;
         public Outlet() {
              outlet = new Outlet[10];
         public static void readFile(Outlet[] outlet) throws FileNotFoundException {
              Scanner inFile = new Scanner(new FileReader("outlets.txt"));
              int rowNo = 0;
              int i = 0;
              String outletValue;
              while (inFile.hasNext() && rowNo < MAXOUTLETS) {
                   outlet[rowNo] = new Outlet();
                   outletValue = inFile.nextLine();
                   outlet[rowNo].setOutletName(outletValue.toUpperCase());
                   //System.out.println(rowNo % 2);
              //     if (rowNo % 2 == 0) {
                   outlet[rowNo].setPhoneNumber(DEFAULT);
                   outlet[rowNo].setCategory(DEFAULT);
                   outlet[rowNo].setOperatingDays(DEFAULT);
    //               System.out.println("Outlet Name+++++++  " + rowNo + "\n" + outlet[rowNo].getOutlet());               
                   rowNo++;
         //          System.out.println(rowNo);
              if (SHOWDETAILS) {
                   if (rowNo > 6) {
                        for (i = 0; i < rowNo; i++ ) {
                             System.out.println("\nOutlet Name+++++++  " + (i + 1) + "\t" +
                                       outlet.getOutletName());
              inFile.close();
         public static void displayAllOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing All Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
         public static void displayUnassignedOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing all unassigned Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   if (outlet[i].getCategory() == DEFAULT) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
         public static void main(String[] args) throws FileNotFoundException {
              Outlet start = new Outlet();
              Outlet.readFile(start.getOutlet());
              Outlet.displayUnassignedOutlets(start.getOutlet());
    ================================
    So in the below Franchise class, when I specify:
    outlet[(choice - 1)].setPhoneNumber(choice);
    I get the error that an array is required but the class Outlet is resolved. Any feedback is greatly appreciated!
    import java.io.FileNotFoundException;
    import java.io.PrintWriter;
    import java.util.*;
    public class Franchise {
         private Franchise[] franchise;
         public Outlet[] outlet;
         static final int MAXOUTLETS = 10;
         static final int DEFAULT = 99;
         static boolean SHOWDETAILS = false;
         static final String STARS = "****************************************";
         static final double REGHOTDOG = 2.50;
         static final double LARGEHOTDOG = 4;
         static final int SALESPERIOD = 28;
         static final int OPERATINGHOURS = 8;
         public Franchise[] getFranchise() {
              return franchise;
         public Franchise() {
         public static void createFranchise(Franchise[] franchise) throws FileNotFoundException {
              Scanner console = new Scanner(System.in);
              int choice = -1;
              //franchise[i] = new Franchise();
              Outlet outlet = new Outlet();
              //outlet[i] = new Franchise();
              Outlet[] myOutlet = new Outlet[10];
              Outlet.readFile(outlet.getOutlet());
              boolean invalidChoice = true;
              while (invalidChoice) {
              System.out.println("\nCreating a New Franchise...");
              System.out.println(STARS);
              System.out.println("Please select an outlet from the list below");
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
              choice = console.nextInt();
              if (choice < 0 || choice > 10) {
                   System.out.println("Error! Please choose a single number between 1 and 10");               
              else {
                   invalidChoice = false;
              //System.out.println(j);
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Phone Number for this Outlet");
                   choice = console.nextInt();
                   String phone = new String();
                  phone = new Integer(choice).toString();
                   if (phone.length() < 8 || phone.length() > 10) {
                        System.out.println("Error! Please enter 8 to 10 digits only");
                   else {
                        outlet[(choice - 1)].setPhoneNumber(choice);
                        invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the category number for this Outlet");
                   choice = console.nextInt();
                   if (choice < 1 || choice > 4) {
                        System.out.println("Error! Please choose a single number between 1 and 4");
                   else {
                        outlet.setCategory(choice);
                        invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Operating Days for this Outlet");
                   choice = console.nextInt();
                   if (choice < 5 || choice > 7) {
                        System.out.println("Error! Please choose a single number between 5 and 7");
                   else {
                        outlet.setOperatingDays(choice);
                        invalidChoice = false;
    //          Applicant chosenApplicant = new Applicant();
         //     Applicant.readFile(chosenApplicant.getApplicant());
              //Applicant.checkCriteria(chosenApplicant.getApplicant());
         //     System.out.println("This Franchise has been assigned to : " +
              //          chosenApplicant.displayOneEligibleApplicant());
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
         public static void main(String[] args) throws FileNotFoundException {
              Franchise start = new Franchise();
              Franchise.testing(start.getFranchise());
              //Franchise.createFranchise(start.getFranchise());
              //Franchise.displaySalesForcast();
              //Franchise.displayAllFranchises(start.getOutlet());

  • Calculate size of output from HttpServletResponse

    how to calculate size (in bytes) of the output from HttpServletResponse.
    can anyone tell me....
    thanks in advance

    > how to calculate size (in bytes) of the output from
    HttpServletResponse.
    can anyone tell me....
    1) Read the bytes from the servlet output stream and count them.
    2) Determine the content to be sent in the response and count the bytes.
    ~

  • How to override methods from dynamic instaniated class to call externally?

    Hi,
    Does anyone knows how to get processWindowEvent() from JFrame to call externally without having to override it in a subclass.
    public class UserFrame extends JFrame {
    public class Application {
    public void main(String[] args) {
    UserFrame frame = (UserFrame ) UserFrame .class.newInstance();
    processWindowEvent(WindowEvent evt) {
    the point is to get the instantiated UserFrame to call Application's processWindowEvent() whenever the window event is generated without having to override it in UserFrame.
    Any expert on this?

    The point is there will be several subclasses of JFrame and I would not want to mannually override each subclasses, but by getting any JFrams's method to be delegated to call another method. VB.net, Delphi and etc. have a feature called class method delegation.
    Java has a feature called method Proxy by using InvocationHandler class but is there any example how it could perform what I require?

  • Exporting Tables from BSP to Class Methods

    Afternoon Everybody,
    in true SAP OSS Message style I post this question on it's own thread to enable maximum value from the reward points.
    Question:
    I have a BSP, in an event in my BSP I call a method in my class.
    I have mastered Exporting parameters to the methods from the BSP and Importing parameters back to the BSP from the methods, but now, I need so Export a table to the method and I don't know how to.
    Also, in combination with this, when I create the method I am able to setup the importing parameters, but how can create/define the importing table ?
    If this is not clear I will add more info.
    Thanks for your help,
    Tomas.

    Tomas,
    The key to problem is always to learn a few "nice" things defined in the system. So let me see. The first problem you have is that methods are declared of the form:
    method <parm> <direction> TYPE [REF TO] <t>
    parm = the name of the paramter
    direction = IMPORTING|EXPORTING|CHANGING|RETURNING
    t = type of parm
    However, in this type it is not possible to write that you want "type of table". You can only use predefined types (either internal or indictionary).
    Having said this, most people with extensive ABAP experience before the OO-wave, tend to use character types all the time. However, we nearly always use only type string. And exactly for this type there is a type string_table.
    So the code would be:
    <u>Declaration:</u>
      method lines changing type string_table
    <u>Calling:</u>
      DATA: t TYPE string_table.
      APPEND 'Hello' TO t.
      APPEND 'World' TO t.
      class=>method( CHANGING lines = t ).
    <u>Method Implementation:</u>
      DATA: line LIKE LINE OF lines.
      LOOP AT lines INTO line.
        TRANSLATE line TO UPPER CASE.
        MODIFY lines FROM line. " write back
      ENDLOOP.
    <u>Better Method Implementation (works directly on row):</u>
      FIELD-SYMBOLS: <line> LIKE LINE OF lines.
      LOOP AT lines ASSIGNING <line>.
        TRANSLATE <line> TO UPPER CASE.
      ENDLOOP.
    These two types <b>string</b> and <b>string_table</b> goes a long way. The other two types that I often use are <b>ihttpvnp</b> and <b>Tihttpvnp</b> (table): they are good for name/value pairs of strings.
    Now is the time that you should invest 30 minutes reading each time that you run into a problem. You have the framework, just check up on one aspect each time. (I usually use online help, for example to understand MODIFY for writing this text.)

  • Need suggestion for variable size array of primitive type.

    Hi all,
    I am working on a problem in which I need to keep an array of primitive (type int) sorted. Also I insert new elements while keeping it sorted, and at times I merge two similar arrays with unique elements.
    I would welcome suggestions on the implementation aspects as to which type/class to use. My primary consideration is performance. Here are my observations:
    1. type int
    Efficient operation, but arrays are fixed size so it makes clumsy code and overhead when the array is expanded or merged with another.
    Methods in class Arrays can be used, incl. binary search and sort.
    2. Vector, ArrayList, List, LinkedList
    Accept objects only. I can use Integer instead of int, but it will involve overhead, and I'll need to write my own sort and search routines (already done).
    For now, I choose option 2 using Vectors. Is there a better choice, or are there other options, given the conditions and consideration enumerated at the beginning?
    Appreciate any input or comments.

    mathmate wrote:
    I have not had the occasion to use them in parallel to recognize the difference. It pays to talk to people!A small benchmark is easily constructed:
    import bak.pcj.list.IntArrayList;
    import java.util.Random;
    import java.util.ArrayList;
    public class CollectionTest {
        static void testObjectsList(ArrayList<Integer> list, int n, long seed) {
            long start = System.currentTimeMillis();
            Random rand = new Random(seed);
            for(int i = 0; i < n; i++)
                list.add(new Integer(rand.nextInt()));
            for(int i = 0; i < n/2; i++)
                list.remove(rand.nextInt(list.size()));
            long end = System.currentTimeMillis();
            System.out.println("objectsList -> "+(end-start)+" ms.");
        static void testPrimitiveList(IntArrayList list, int n, long seed) {
            long start = System.currentTimeMillis();
            Random rand = new Random(seed);
            for(int i = 0; i < n; i++)
                list.add(rand.nextInt());
            for(int i = 0; i < n/2; i++)
                list.remove(rand.nextInt(list.size()));
            long end = System.currentTimeMillis();
            System.out.println("primitiveList -> "+(end-start)+" ms.");
        public static void main(String[] args) {
            long seed = System.currentTimeMillis();
            int numTests = 100000;
            testObjectsList(new ArrayList<Integer>(), numTests, seed);
            testPrimitiveList(new IntArrayList(), numTests, seed);
    }In the test above, Java's ArrayList is about 5 times faster. But when commenting out the remove(...) methods, the primitive 3rd party IntArrayList is about 4 to 5 times faster.
    Give it a spin.
    Again: just try to do it with the standard classes: if performance lacks, look at something else.

  • Variable size array of checkboxes

    I am new to weblogic. I am using weblogic 8.1 SP3.
    My problem is that i have to display a table with first coloumn of each row a name and rest coloumns should contain checkboxes. Each row has same number of checkboxes. But the number of checkboxes in each row everytime page is loaded is variable.
    If anyone can tell me how to do this and how to bind data to form bean. I tried using a repeater tag with a Boolean array but of no use.
    Thanks in advance
    Akshay

    Please create a new default application and drop the checkbox folder into
    the web project and run the jpf.
    Thanks
    Vimala
    <Vimala Ranganathan> wrote in message news:[email protected]..
    Hi Akshay
    I have attached a sample that will show a page that will take in the
    number of checkboxes the page will have (like you can get this as request
    attribute, req parameter etc) and displays the page using repeater tag.
    Steps:
    Unzip the file and open with workshop IDE
    Build and run the jpf in the folder checkbox
    I am not sure how to attach the file. Can you please let me know your
    email so I can send it to you?
    Thanks
    Vimala

  • Displaying the output from a java class executed from W/I another class

    I have compiled a java class, but I have run into a problem executing the class. I have read the posts and still have not solved the solution. I have tried to get the output of the Process by using "proc.getOutputStream().toString()", however it displays it in binary (ex. java.io.BufferOutputStream@48eb2067). If anyone can provide any assistance I would greatly appreciate it. Or if you could tell me if I'm on the right track or not. Thanks ALL. Here is a code segment:
    int truncStart = s.indexOf(".java");
                   s = s.substring(0,truncStart);
                   String[] command2 = {"java","c:/"+s};
                   try
                   //JOptionPane.showMessageDialog(null,"Exec. File "+s, "Exec. File : ",JOptionPane.ERROR_MESSAGE);
                   proc = Runtime.getRuntime().exec(command2);
                   JOptionPane.showMessageDialog(null,"Output: "+proc.getOutputStream().toString(),"Output"
    ,JOptionPane.ERROR_MESSAGE);
                   }

    You have to read the stream, like:
    InputStream stream = proc.getOutputStream();
    // now use methods on stream, such as read() to read the characters/lines - or wrap it in another line-friendly stream - see the java.io.* classes - keep reading until you get an end-of-stream indicator, depending on the API you end up using.

  • SWF size when output from CS5 vs. CS6

    Hi All,
    I've hit a wall and I'm really hoping to get some help!
    My company recently updated us from CS5 to CS6.  I was pretty excited to start using the new Flash IDE and, for the most part, it's been great.  However... there's one issue I can't seem to figure out.
    We create lots of banners ads so we have templates built.  If I open my 300x250 template in Flash CS5 and publish it's 8243 bytes per the size report.  If I open the exact same FLA in Flash CS6 and publish it's 9873 bytes.
    I've narrowed it down to miniscule differences in the shapes, but the main difference is in the fonts.  The same characters are embedded in the FLA, but the file size is bigger when exported from CS6 (~1449 bytes or 1.4kb).  Working in the advertising space we're constantly under the gun to keep our SWFs under 40kb so every little bit counts.  This is an issue for our team as that extra 1.4kb means other things have to be compressed further resulting in lower quality.
    Has anyone else run into this?  I've searched and searched, but could only find a few threads that lead to no definitive answers.  Is there a new setting in CS6 that can be turned off?  Is there a new way of compressing fonts?  For the time being we're reverting back to publishing our SWFs out of CS5 which is a huge headache and affects productivity.
    Any help anyone can offer would be VERY much appreciated!
    Best,
    Vern

    M47K / kglad...
    Thanks for the responses.  I double-checked and only the characters being used in the SWF are embedded, not the entire font.
    Further, I did some more experimentation and while switching to LZMA compression helped, it didn't fix the issue.  Here are some stats:
    Flash Pro CS6 using "Deflate"
    File Size: 9967 bytes
    ActionScript: 2322 bytes
    Font 1: 3665 bytes
    Font 2: 819 bytes
    Flash Pro CS6 using LZMA - Compared to CS6 using "Deflate"
    File Size: 9550 bytes (417 bytes smaller)
    ActionScript: 2236 bytes (86 bytes smaller)
    Font 1: 3506 bytes (159 bytes smaller)
    Font 2: 783 bytes (36 bytes smaller)
    Flash Pro CS5 - Compared to CS6 using "Deflate"
    File Size: 8353 bytes (1614 bytes smaller)
    ActionScript: 2266 bytes (56 bytes smaller)
    Font 1: 2472 bytes (1193 bytes smaller)
    Font 2: 556 bytes (263 bytes smaller)
    Any other help or tips that people might know about would be very much appreciated.  As I mentioned in my initial post... I have to squeeze every bit of kb out of the work I do while maintaining quality images and animation so every little kb helps!
    Thanks!
    Vern

Maybe you are looking for