Reading data from a text file but can't use the data outside of the function.

I am trying to load a variable from data in a text file.
I can read the text file fine but the variable data seems
only to be available with in the function that reads it.
I need to use the variable data outside of the function.
Does anyone have any suggestions to work around this issue?
This is the actionscript code i'm using.
var pathVars= new LoadVars();
pathVars.onLoad=function(ok) {
if(ok)
trace("Loading");
path_var=pathVars.path;
trace("This is within the function "+path_var);
pathVar0="This is within the function... "+path_var;
Yet the path_var is available here fine.
pathVars.load("mypath.txt");
This is where the path_var becomes undefined
trace("This is outside the function... "+path_var);
pathVar1="This is outside the function... "+path_var;
This
is a download link for the FLA zip file
This
is a demo of the script loading the text file

The external traces are being executed before the file is
loaded.

Similar Messages

  • Reading fields from a text file

    Hi, I'm fairly new to this so bear with me.
    This is for an assignment - the idea is to cretae an online system for booking seats at a cinema - haven't got past the login stage yet?
    I've got an applet that needs to read in a field from a text file.
    I'm using the StringTokenizer function.
    I've put a test in to check that the applet can find the file, which seems to be ok.
    However, it's not reading from the file.
    Te file is a simple text file - fields are seperated by a comma and a space.
    Any ideas?
    Please help as this is quite urgent.
    Prototype Code is below
    public class cinema extends Applet implements ActionListener, ItemListener{
    private List ActionList;
    private int listIndex;
    TextArea t = new TextArea(5, 30);
    private Button gobutton, writebutton, login, logout;
    private PrintWriter suggestfile;
    TextField Userid, password, enterField;
    private int count, checkuser;
    private BufferedReader firstn;
    File myFile = new File("e:\\Ian\\Unistuff\\2nd Year\\se2\\cinema2\\src\\cinema2\\member.txt");
    //Construct the applet
    public cinema() {
    enterField = new TextField("Please enter user ID and Password");
    enterField.setEditable(false);
    add(enterField);
    Userid = new TextField(3);
    add(Userid);
    password = new TextField(10);
    password.setEchoChar('*');
    add(password);
    //Initialize the applet
    public void init() {
    BorderLayout borderLayout1 = new BorderLayout();
    //some code ommitted
    t.setEditable(false);
    add(t);
    gobutton = new Button("Go!");
    add(gobutton);
    gobutton.addActionListener(this);
    public void actionPerformed(ActionEvent event) {
    if (event.getSource() == gobutton) {
    try {
    firstn = new BufferedReader( new FileReader(myFile));
    catch (IOException e) {
    t.setText("Member database missing - please contact Chairperson");
    return;
    try {
    String line1;
    boolean found = false;
    while (( ( line1 = firstn.readLine() ) != null) && (! found))
    {StringTokenizer token1 = new StringTokenizer (line1, " ,");
                              String user = token1.nextToken();
                                 if (Userid.getText().equals(user))
                                   { found = true;
                                     t.setText("Hello");
    firstn.close();
    catch (IOException e) {
    System.err.println("Error Reading File " + myFile + ": " + e.toString());
    Here's the text file:
    Ian, Dodson, 001, rubbish
    Joe, Bloggs, 002, medway
    Bill, Smith, 003, unique
    Guest, , Guest,
    To test that it is working, it should just put a message in the Text Area, but nothing happens when you press the "go" button.

    1. Your applet will not work, because it is trying to
    read file from local disk.
    2. This task can be solved by simple CGI script
    (which is much more common and universal thing than
    java), so you do not need to use java if you want to
    send 3 lines to a server.
    3. See examples and read some books.1. Stated the obvious.
    2. This is a java forum, not Perl.
    3. Pathetic and patronizing.
    Very helpful.

  • Hi i am new to labview. i want to extract data from a text file and display it on the front panel. how do i proceed??

    Hi i am new to labview
    I want to extract data from a text file and display it on the front panel.
    How do i proceed??
    I have attached a file for your brief idea...
    Attachments:
    extract.jpg ‏3797 KB

    RoopeshV wrote:
    Hi,
    The below code shows how to read from txt file and display in the perticular fields.
    Why have you used waveform?
    Regards,
    Roopesh
    There are so many things wrong with this VI, I'm not even sure where to start.
    Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
    Not using Read From Spreadsheet File.
    Use of local variables to populate an array.
    Cannot insert values into an empty array.
    What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
    Also, how does this answer the poster's question?

  • I cant seem to scan from my hp photosmart 7520 printer to my iMac but can scan using the iMac? photosmart cant see the iMac.

    I cant seem to scan from my hp photosmart 7520 printer to my iMac but can scan using the iMac? Photosmart cant see the iMac. Mac is wired to the router printer over wi fi.

    Hi Shlomi
    It worked!!! Thanks so much, I've been messing about with this for hours.
    As you are so good I do have another problem. I have another 2 pc's on the network that show on the iMac but iMac cannot conect to. One is XP and the other is Vista both with Norton fire wall installed.
    Any thoughts you have would be much appriciated
    Rob

  • How many times can you install Lightroom 5? My problem is that I have saved my programs on C. To I have more space, I want to save my programs now on E. Can I now uninstall Lightroom and reinstall from C to E? Can I use the same license code as the first

    Please help!!
    How many times can you install Lightroom 5? My problem is that I have saved my programs on C. To I have more space, I want to save my programs now on E. Can I now uninstall Lightroom and reinstall from C to E? Can I use the same license code as the first installation?

    Thank you for your answers, it helps me a lot.
    But sorry for my ignorance. I understand how you mean it, but I don't know how to do it. I'm scared to lose the settings/edits of the images.

  • Installing but can't use the css

    I bought the P'shop CS6 at the Apple store, as well as my imac but ,even though I've regeistered with Adobe and have Reader, I'm not told how to get the program onto my compter. I'd appreciate any help. John

    jrock wrote:
    Hi. i didn't mention  'css'.
    It's the subject heading of this thread which confused us: "installing but can't use the css". I suspect "css" is a typo and you meant CS6.
    CS6 can be downloaded from
    http://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html
    Enter your serial number to license the software on your iMac.

  • My ipod will not charge from a wall socket but will charge using the same cable if the usb end is plugged into a computer or an airport power source. My iphone and ipad charge fine on the same cable usin ghte same wall plug in the same wall socket?

    My ipod will not charge from a wall socket but will charge using the same cable if the usb end is plugged into a computer or directly into an airport power source. My iphone and ipad charge fine on the same cable using the same wall plug in the same wall socket. This makes no sense but I see that it has been posted as a problem elsewhere. This must be due to some kind of degredation of the Ipod. . It is not fixed by IOS resets as others have noted.
    Has anyone asked Apple directly about this?

    Hi there Apples or Pears,
    I would recommend taking a look at the troubleshooting steps found in the articles below.
    Charging your iPod battery
    http://support.apple.com/kb/ht1384
    iPod's battery doesn't charge
    http://support.apple.com/kb/ta44551
    -Griff W.

  • How can i detach the video from a clip so i can only use the audio when using imovie?

    how can i detach the video from a clip so i can only use the audio when using imovie?

    First, go to iMovie/Preferences and enable the Advanced Tools.
    Import the video clip into an iMovie Event. When you get ready to use it in an iMovie Project, select the clip in the Event and drag & drop it on top of a video or photo clip in the project at the place where you want it to begin. When the pop-up menu appears, choose Audio Only.

  • I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button

    I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button to navigate back to my starting point the bookmarks are replaced by "page thumbnails". Is there anyway to stop this from happening?

    Hi Pusman,
    While setting up the links, if you choose to open the file in a new window then you won't face this issue, then you can simply switch to the previous file and bookmark view will remain as it is.
    Does that helps with your query?
    Regards,
    Rahul

  • I used my husband's email for my apple ID.  I just got him a new ipad but can't use the email to register.  If I change my ID now, will that email be available for him on his ipad?

    I used my husband's email for my apple ID.  I just got him a new ipad but can't use the email to register.  If I change my ID now, will that email be available for him on his ipad?

    Hey LamFY,
    Thanks for the question. The short answer is Yes. Once you change your Apple ID primary email address, the previous email address will be freed up for use with another account:
    Apple ID: Changing your Apple ID
    http://support.apple.com/kb/ht5621
    Be sure to follow all of the steps in this resource, most importantly the first step of signing out of all Apple features and services.
    Thanks,
    Matt M.

  • Installing a d2 quadra but can't use the setup assistant because PowerPC Applications are no longer supported. Help...

    I'm tring to install a d2 quadra external drive but can't use the setup assistant because "PowerPC Applications are no longer supported". Anyone have any ideas?

    You shouldn't need to install anything just to use the drive. Just connect it to your Mac and it should mount. If it's the Intego Backup Assistant you're trying to install, try the latest version which you can download here:
    http://www.lacie.com/products/product.htm?id=10323
    Regards.

  • Hi, I have apple account/password on laptop but can't use the same ID etc on new Ipad.  On my account it says ID is only for 1 system.  I really want only one ID for both Ipad and laptop. Thanks

    Hi,
    I have apple account/password on laptop but can't use the same ID etc on new Ipad.  On my account it says ID is only for 1 system.  I really want only one ID for both Ipad and laptop.
    Thanks

    It seems that you have used the AppleIDs to "Purchase" your devices, which marries the two for all time and eternity.
    For info - Using your Apple ID for Apple services
    For Account security issues - Apple ID: Contacting Apple for help with Apple ID account security
    regards
    CCC

  • I can't use the function of "print to video".

    I've recently purchased FCPX and Blackmagic Design Decklink HD Extreme 3(version 7.5.2) but I already know this combination looks quite weird because I'm using only DSR. This is the first time I have installed FCP.
    I installed FCPX and figured out there's no way to get the video from Decklink on FCPX so that I deleted FCPX, installed FCP 2009 instead and installed FCPX again on the same disk as Final Cut Pro 7... It's a shame to get rid of it.
    At first, I could get a good result when printing to tape. There's no problem. But it's not long before I failed to get what i wanted. VCR detects input signal from FCP 7 through Decklink but the monitor of VCR shows only noise. For now, I can't use the function of "print to video".
    Also, I connect the input of Decklink to the output of DSR and the output of Decklink to the input of DSR at the same time and monitor w/ the output of DSR. However, the output on the monitor shows something weird when I capture the video from DSR as if the signal is fed back.
    Someone told me that I have to use other version of decklink but i'm not sure it would be better if I just change the version.
    What's wrong?
    What should I do for fixing these all mess?

    I've recently purchased FCPX and Blackmagic Design Decklink HD Extreme 3(version 7.5.2) but I already know this combination looks quite weird because I'm using only DSR. This is the first time I have installed FCP.
    I installed FCPX and figured out there's no way to get the video from Decklink on FCPX so that I deleted FCPX, installed FCP 2009 instead and installed FCPX again on the same disk as Final Cut Pro 7... It's a shame to get rid of it.
    At first, I could get a good result when printing to tape. There's no problem. But it's not long before I failed to get what i wanted. VCR detects input signal from FCP 7 through Decklink but the monitor of VCR shows only noise. For now, I can't use the function of "print to video".
    Also, I connect the input of Decklink to the output of DSR and the output of Decklink to the input of DSR at the same time and monitor w/ the output of DSR. However, the output on the monitor shows something weird when I capture the video from DSR as if the signal is fed back.
    Someone told me that I have to use other version of decklink but i'm not sure it would be better if I just change the version.
    What's wrong?
    What should I do for fixing these all mess?

  • Reading PublicKey from a text file..

    Hi,
    I generated Public Key using RSA algorithm, and getEncoded() using Base64Encoder, after that I saved it as TEXT file. Here goes the code.
         KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
         keyGen.initialize(512);
    KeyPair keypair = keyGen.generateKeyPair();
    PublicKey publicKey = keypair.getPublic();
         PrivateKey privateKey = keypair.getPrivate();
         //Get bytes of the public and private keys
         byte[] privateKeyBytes = privateKey.getEncoded();
         byte[] publicKeyBytes = publicKey.getEncoded();
         byte[] keypb = publicKey.getEncoded();
         BASE64Encoder pubEncod = new BASE64Encoder();
         String pub64 = pubEncod.encode(publicKey.getEncoded());
         char c1[] = new char[pub64.length()];
         pub64.getChars(0, pub64.length(), c1, 0);
    String fileName1 = "D:\\PublicKey\\PublicKey.txt";
         FileWriter f1 = new FileWriter(fileName1);
         f1.write(c1);
         f1.close();
    After that, I tried to decoded PublicKey from this text file, using this code..
    //Read public Key from txt file
    //FileReader
    FileReader fr = new FileReader("D:\\PublicKey\\PublicKey.txt ");
    //BufferedReader - uses the FileReader
    BufferedReader br = new BufferedReader(fr);
    //String to contain lines from the file
    String s;
    //StringBuffer used store the file contents
    StringBuffer sb = new StringBuffer("");
    //Final output from the operation
    String output;
    //Loop through lines of the file, storing the file content
    while((s = br.readLine()) != null)
    {       sb.append(s + "<br>");
    //Store the file contents in the output string
    output = sb.toString();
    //Close the file
    fr.close();
    BASE64Decoder decoder = new BASE64Decoder();
    byte[] decodedPublicKey = decoder.decodeBuffer(output);
    // bytes can be converted back to public key
    X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(decodedPublicKey);     
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    PublicKey pubk = keyFactory.generatePublic(pubKeySpec);
    And got InvalidKeyException and lengthTag is TOO BIG.. Any one can tell what is the problem while reading back??
    Thanks
    Ameri

    while((s = br.readLine()) != null)
    {       sb.append(s + "<br>");
    //Store the file contents in the output string
    output = sb.toString();Hi,
    Ouch! Your extra data is probably coming from the <br>s. the 'b' and 'r' are being Base-64 decoded and producing extraneous bytes. I'm not sure why you have the <br> in there, but try removing it an see what happens. Good luck.

  • Reading characters from a text file into a multidimensional array?

    I have an array, maze[][] that is to be filled with characters from a text file. I've got most of the program worked out (i think) but can't test it because I am reading my file incorrectly. However, I'm running into major headaches with this part of the program.
    The text file looks like this: (It is meant to be a maze, 19 is the size of the maze(assumed to be square). is free space, # is block, s is start, x is finish)
    This didn't paste evenly, but thats not a big deal. Just giving an idea.
    19
    5..................
    And my constructor looks like follows, I've tried zillions of things with the input.hasNext() and hasNextLine() to no avail.
    Code:
    //Scanner to read file
    Scanner input = null;
    try{
    input = new Scanner(fileName);
    }catch(RuntimeException e) {
    System.err.println("Couldn't find the file");
    System.exit(0);
    //Set the size of the maze
    while(input.hasNextInt())
    size = input.nextInt();
    //Set Limits on coordinates
    Coordinates.setLimits(size);
    //Set the maze[][] array equal to this size
    maze = new char[size][size];
    //Fill the Array with maze values
    for(int i = 0; i < maze.length; i++)
    for(int x = 0; x < maze.length; x++)
    if(input.hasNextLine())
    String insert = input.nextLine();
    maze[i][x] = insert.charAt(x);
    Any advice would be loved =D

    Code-tags sometimes cause wonders, I replaced # with *, as the code tags interprets # as comment, which looks odd:
    ******...*.........To your code: Did you test it step by step, to find out about what is read? You could either use a debugger (e.g., if you have an IDE) or system outs to get a clue. First thing to check would be, if the maze size is read correctly. Further, the following loops look odd:for(int i = 0; i < maze.length; i++) {
        for(int x = 0; x < maze.length; x++) {
            if (input.hasNextLine()) {
                String insert = input.nextLine();
                maze[x] = insert.charAt(x);
    }Shouldn't the nextLine test and assignment be in the outer loop? And assignment be to each maze's inner array? Like so:for(int i = 0; i < maze.length; i++) {
        if (input.hasNextLine()) {
            String insert = input.nextLine();
            for(int x = 0; x < insert.size(); x++) {
                maze[i][x] = insert.charAt(x);
    }Otherwise, only one character per line is read and storing a character actually should fail.

Maybe you are looking for

  • Problem with self-referral

    How can I write an formula for a cell which evaluates the content of that cell, then performs the rest of the equation if the cell is blank, but leaves the cell unchanged if it is not blank?

  • What does it mean if my location services are turned on, but not working?

    What does it mean if my location services are turned on, but not working?  It has always worked before.  It is turned on in Settings but when I try to use an app that requires location services, it says they are not on, and the little arrow is not ap

  • Plug-in stops in 1.3.1_02 (and _01a) with IE

    We're having a problem with the latest versions of the plug-in. We've been using the plug-in in IE (various versions) for sometime with 1.3.0.4 and 1.3.1.1. However, when we try 1.3.1_01a and 1.3.1_02, the plug-in stops working: our html causes the p

  • HP TrueVision HD FIX

    Hi there guys. I have seen so many people with a malfunctioning webcam in their HP laptop, and I also had this problem. But, after a lot of trying i have found a fix to get the TrueVision HD webcam back to work! Here it is: I extracted one folder fro

  • Transmiting video captured from a webcam to another system through internet

    Hi there, I developed an application catch video stream from the webcam and transmit it another system within LAN network , I would like know possibility to senting it over internet to another system?? is it possible sent this streams to more than on