Saving and Loading variables in a .txt file (Offline)

I'm working a software we've done with Flash, but we'd want
people to be able to save the variables they selected. We need them
to be able to save the value of about 10 variables in a file on
their desktop, and then be able to load that file again.
Is it possible to do that without having to use php or stuff
like that (that's why we want to make it an offline applications so
we don't have to use php to be able to save files).
I know Actionscript looks a lot like Javascript and with
Javascript it's really easy to do, but all the saving functions are
blocked in Flash for security reasons.
If anyone knows how to do that, to simply save and load a
.txt file, please let me know. If it would be possible also to
change the .txt to whatever else it would be even better. The file
can still be opened in Notepad but at least it looks a bit more
professionnal to have our own extension. Again in Javascript or
with a .bat file it's really easy to save variables to whatever
type of file, even to non existing types, it simply creates a text
file with an unknown ending.
Thanks!

I found a page that explains in a really easy way how to
communicate with Javascript if the flash object is contained in an
html page, but I couldn't find any page explaining how it works if
it's not in an html page. On our side, before using the software
we're creating we'll convert it to a .exe. How can we call a
Javascript from that .exe since we can't incorporate the Javascript
in the container since there isn't really a container... Is there a
way to link to a Javascript (.js) that would be in the same folder
as the .exe? Or would there be a way to incorporate the Javascript
right into the .exe?
Let me know if any of you have a solution for that.
Thanks!
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Liv eDocs_Parts&file=00000342.html#wp126566

Similar Messages

  • How to load variables from a .txt file

    Hi.
    I usually make a flash aplication in colaboration with a php
    programmer. But i want to test my swfs without having to wait for
    him. So i want to do that through a text file. I know that flash
    can load variables from text files. The problem is i don't know how
    to format the text file ( example.txt).
    Thank you

    Here's a couple of ideas.
    First you probably want to change what you have...and put
    your 'if (pVar==1' etc inside a separate function and call it from
    the onLoad handler after you have assigned the value to pVar...
    because the onLoad will run at some unknown point in time after
    loading has finished (actually in the test environment this might
    work... but that wouldn't be the same as what happens in a
    production setting).
    To create test files for loadvars... simply create a new as2
    file and put this code on the first frame and test movie:

  • Saving and loading 1D array to/from file

    Hi,
    i have some problems with my NI application. for the first, i have case structure with two cases: true and false.
    FALSE: in this case i have a for loop with 100 samples. i catch signal from my DAQ (now just Simulate Signal) and what i want is to save it in a 1D array and at the end of the loop the COMPLETE array into one text file. Problem in my vi: just the values from the last iteration are saved.
    TRUE: now i have while loop. AT THE BEGINN of the loop i need to load my array from the file and not in the middle of the loop. Why? The data from the file are needed during the loop.
    thanx in advance
    Vedran Divkovic
    RUB GERMANY
    Attachments:
    Regelsystem.vi ‏1494 KB

    According to your code, what you are saving is an array of means (one from each iteration), and NOT the last iteration. If you want to keep the entire data, it would be a 2D array.
    Why are you generating an entire waveform at each iteration? Shouldn't you just generate one point?
    LabVIEW Champion . Do more with less code and in less time .

  • Saving and Loading specific properties of an Image

    Hey everyone. I'm currently in the process of developing a game which allows you to customize the color (hue) of your character via a slider. What I would like to happen is: Upon clicking either Accept or Play, it will save the current hue of the image, navigating back to that page will load what was previously saved (hue), as well as when starting the game, it will replace the standard graphic with the previously saved image.
    Below is the code I have right now that pertains to the image with a basic non-functioning properly saving and loading code:
    import flash.events.KeyboardEvent;
    // open a local shared object called "myStuff", if there is no such object - create a new one
    var savedstuff:SharedObject = SharedObject.getLocal("myStuff");
    Accept.addEventListener(MouseEvent.CLICK, SaveData);
    PlayBTN.addEventListener(MouseEvent.CLICK, LoadData);
    function SaveData(MouseEvent){
               savedstuff.data.username = Sliders.Dino.MovieClip // changes var username in sharedobject
               savedstuff.flush(); // saves data on hard drive
    function LoadData(event: MouseEvent)
               if(savedstuff.size>0){ // checks if there is something saved
               Sliders.Dino.MovieClip = savedstuff.data.username} // change field text to username variable
    // if something was saved before, show it on start
    if(savedstuff.size>0){
    Sliders.Dino.MovieClip = savedstuff.data.username}
    What I have above is only saving the actual image, which is inside a movie clip names Sliders.
    Below is the Class I am using that associates with the slider that changes the hue of "Dino".
    package
              import flash.display.Sprite;
              import fl.motion.AdjustColor;
              import flash.filters.ColorMatrixFilter;
              import fl.events.SliderEvent;
              public class Main extends Sprite
                        private var color:AdjustColor = new AdjustColor();
                        private var filter:ColorMatrixFilter;
                        public function Main():void
                                  /* Required to create initial Matrix */
                                  color.brightness = 0;
                                  color.contrast = 0;
                                  color.hue = 0;
                                  color.saturation = 0;
                                  /* Add Listeners function */
                                  addListeners();
                        private final function addListeners():void
                                  colorPanel.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue);
                        private final function adjustHue(e:SliderEvent):void
                                  color.hue = e.target.value;
                                  update();
                        private final function update():void
                                  filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
                                  Dino.filters = [filter];
    Overall what I'm asking for is: How do I get it to save the current hue of an image by clicking a button, and then having that previously saved image be loaded upon reloading or clicking a button? To me, it doesn't seem like it should be too hard, but for some reason I can not grasp it.
    Thanks in advance for reading this and for any assistance you have to offer!

    This is the Class that you told me to use:
    package
              import flash.display.Sprite;
              import fl.motion.AdjustColor;
              import flash.filters.ColorMatrixFilter;
              import fl.events.SliderEvent;
              import flash.net.SharedObject;
              public class Main extends Sprite
                        private var color:AdjustColor = new AdjustColor();
                        private var filter:ColorMatrixFilter;
                        private var so:SharedObject;
                        public function Main():void
                                  color.brightness = 0;
                                  color.contrast = 0;
                                  color.saturation = 0;
                                  so = SharedObject.getLocal("myStuff");
                                  if (so.data.hue)
                                            color.hue = so.data.hue;
                                  else
                                            color.hue = 0;
                                  update();
                                  addListeners();
                        private final function addListeners():void
                                  colorPanel.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue);
                        private final function adjustHue(e:SliderEvent):void
                                  color.hue = e.target.value;
                                  so.data.hue = color.hue;
                                  so.flush();
                                  update();
                        private final function update():void
                                  filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
                                  Dino.filters = [filter];
    And this is the FLA Code:
    import flash.events.KeyboardEvent;
    // open a local shared object called "myStuff", if there is no such object - create a new one
    var savedstuff:SharedObject = SharedObject.getLocal("myStuff");
    Accept.addEventListener(MouseEvent.CLICK, SaveData);
    PlayBTN.addEventListener(MouseEvent.CLICK, LoadData);
    function SaveData(MouseEvent)
              savedstuff.data.username = Sliders.Dino.MovieClip;// changes var username in sharedobject
              savedstuff.flush();
              // saves data on hard drive;
    function LoadData(event: MouseEvent)
              if (savedstuff.size > 0)
              {// checks if there is something saved
                        Sliders.Dino.MovieClip = savedstuff.data.username;
              }// change field text to username variable
    // if something was saved before, show it on start
    if (savedstuff.size > 0)
              Sliders.Dino.MovieClip = savedstuff.data.username;

  • Problem on reading and writing from from a *.txt file

    I get Problem on reading and writing from from a *.txt file. The following is the read() method...
    The software said the DataInputStream is depreciated. Can anyone help me please?
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        String str = "";
        try
          in = new BufferedReader(file);
          //in = new FileInputStream(file);
          for(;;)
            str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);
      }

    Thank you for your reply. I have made some change. However, there is an incompetable type found error.
    in = new BufferedReader(new InputStreamReader(in));The following are all of the code.
    public void read()
        File file = new File("C://Documents and Settings//Charles//My Documents//Brunel//EE2065//Assignment and Lab//Assignment 4 and Lab 4//data.txt");
        FileInputStream in = null;
        //BufferedReader in = null;
        String str = "";
        try
          in = new BufferedReader(new InputStreamReader(in));
          //in = new FileInputStream(file);
          for(;;)
            BufferedReader Bstr = new BufferedReader(new InputStreamReader(in));
            //str = new BufferedReader(in).readLine();
            //str = new DataInputStream(in).readLine();
            if(str == null)
              break;
            System.out.print(str);
        in.close();
        catch(IOException e)
            System.err.println("execution error: " +e);

  • How to speed up my saving and loading of a psd. file?

    Hi.
    My laptop's 1 TB hdd recently crashed and I replaced it with a 500 GB ssd and Photoshop loads now from 10-12 sec since i re installed Photoshop cc.
    Unfortunately, the time it takes to save and load psd files has increased dramatically (I'm comparing it to how it was with my normal hdd). It also, sometimes freezes a bit and then after about 10 sec it unfreezes.
    I have looked online for help, but have been unable to find anything that could really help me (or it just went over my head, as I am not very tech savvy).
    Any help would be greatly appreciated.
    If this has been discussed before, can someone please post the link for me.

    The rule of thumb I follow to figure out scratch space says to figure on 50 to 100 times the size of your largest file ever multiplied by the number of files you have open.  I have seen the scratch file exceed 800 GB once, an admittedly rare occurrence, but it often exceeds 200 GB when stitching large panoramas and the like.
    As an example—and stressing that I'm aware that others have even more scratch space than I do—I keep two dedicated, physically separate hard drives as my primary and secondary Photoshop scratch disks and a lot of GB free on my boot drive for the OS.  I also have 16 GB of RAM installed.
    Additionally, if you only have a single HD, i.e. your boot drive, you'd need it to be large enough to accommodate both the swap files of the OS as well as Photoshop's scratch.

  • Please help me understand making and loading variable classes

    Hi guys ,
    I know that I am stupid but I just can't get this!  AS3 says you need to load variables into a class?  Please please give me a simple example
    my variables look like this... (the whole point of playing around with variables was that if I had to make a change I could access one place and change them...
    but now I realse that I can't access or call them outside the movie clip they are in:(
    please hlep me!
    var ans1="";
    var ans2="";
    var w1="ABN";
    var def1="An ABN (Australian Business Number), is a personal number for your business that makes it easier and quicker to deal with  government and other businesses.";
    var w2="ACN";
    var def2="An ACN is an Australian Company Number, which is a special number that each company gets to identify it.  No two companies can have the same ACN";
    var w3="Action Plan";
    var def3="A business Action Plan will show What needs to be done and When it needs to be done by."
    var w4="Advertising";
    var def4="Advertising is producing information to let people know about your business and try to increase sales."
    var w5="Promotions";
    var def5="Promotions are where your business tries to increase the sales of a particular item through offering a good deal, advertising or a special display.";
    var w6="Benefit";
    var def6="A benefit is something good that you get.  One benefit of doing exercise is getting fit, another benefit is losing weight.";
    var w7="Business Mentor";
    var def7="A business mentor is a trusted guide. Someone who has experience and has been successful in business and can help and advise you.";
    var w8="Business Name";
    var def8="A Business name is the name a business uses to do its work.  It lets customers know who you are.";
    var w9="Business Registration";
    var def9="When you start a business you need to register your ABN, you may need to register your business name.";
    var w10="Cash flow";
    var def10="Cash Flow for a business is having enough cash saved to be able to pay your bills when they are due.";
    var w11="Characteristic";
    var def11="The characteristics of something are describing words about that thing.";
    var w12="Charges";
    var def12="A charge is something you have to pay, an expense.";
    var w13="Company";
    var def13="Is the same as a corporation. A company is a type of business that needs to be registered (either State or Federal) and has special legal status.  A company can put Pty. Ltd after it’s business name.";
    var w14="Competitor";
    var def14="A competitor is another business that is challenging you for customers.";
    var w15="Constitution";
    var def15="A constitution in business is a list of rules and principles that a company has agreed to follow.";
    var w16="Corporations Aboriginal and Torres Strait Islander Act";
    var def16="In the 1960s and 1970s, various reviews advised the Australian Government of the need for legislation to make it easier for Indigenous communities and organisations to form corporations. As a result, the ACA Act was passed, allowing Aboriginal and Torres Strait Islander groups to form corporations for any social or economic purpose.";
    var w17="Corporations Act";
    var def17="The Australian Securities and Investments Commission (ASIC) have laws that apply to corporations and these are found in the Corporations Act.";
    var w18="Cultural knowledge";
    var def18="Cultural knowledge is special information that is held by a particular cultural group, this could include technologies (e.g. special ways of using materials, making and using tools), stories, language and song, cultural rules, taboos, regulations and oral history.";
    var w19="Customer";
    var def19="The customer is someone who is buying something from a business.";
    var w20="Debt";
    var def20="Is something that you have to pay back. If you borrow 20 dollars you have a $20 debt.";
    var w21="Direct competitor";
    var def21="Is selling exactly the same thing as your business and competing for your customers.";
    var w22="Dividend";
    var def22="A dividend is money that is paid to shareholders regularly out of the company’s profits.";
    var w23="(Microsoft) Excel";
    var def23="Microsoft Excel is a computer program that lets you keep lists of numbers and also add up totals and do other sums to those numbers.";
    var w24="Fees";
    var def24="A fee is something that you have to pay, an expense.";
    var w25="Financial Management";
    var def25="Financial Management is the planning, organising, checking  and controlling of the income, expenses and Tax for a business.";
    var w26="Franchise";
    var def26="A franchise is a type of business you can buy. When you buy a franchise you set up the same type of business that has been successful somewhere else.";
    var w27="General ledger";
    var def27="A general ledger for a business is where all of the income and expenses for that business are kept in a document.";
    var w28="Goal";
    var def28="A goal is a target that you set yourself or your business.  Something that you want to achieve.";
    var w29="Growth opportunity";
    var def29="A growth opportunity is a chance for a business to get bigger.";
    var w30="GST";
    var def30="The Goods and Services Tax is paid when you buy things. Some items like food and medicine do not have the Goods and Services tax charged to them.";
    var w31="ICN";
    var def31="Indigenous Corporations Number is a special number given each indigenous corporation to identify it. No two indigenous corporations can have the same ICN.";
    var w32="Incorporate";
    var def32="Incorporate is what people do when they create a company or corporation.";
    var w33="Indirect competitor";
    var def33="An indirect competitor is selling a similar product or service to your business.  E.g. If you had a pizza shop, a fried chicken shop is an indirect competitor because it sells food and your customers might want to eat chicken instead of pizza.";
    var w34="Labour";
    var def34="Labour is all the work done by people (including you) in your business.";
    var w35="Legal name";
    var def35="Your Legal Name is the name that is on your Birth Certificate.";
    var w36="Legal protection";
    var def36="Legal protection means you are protected under the law from certain things happening.";
    var w37="Legal structure (business)";
    var def37="Legal structure is the type of business, sole trader, company, partnership.";
    var w38="Liability";
    var def38="A liability is something you are responsible for.";
    var w39="Licence";
    var def39="A license is proof that you have permission to do something.  For example, if you have a driving license you can drive a car.";
    var w40="Lodge";
    var def40="To lodge a form means to send it to where it has to go.";
    var w41="Manufacturing";
    var def41="A manufacturing business makes things.";
    var w42="Marketing budget";
    var def42="A marketing budget is the amount of money you have set aside for advertising and promotion for your business.";
    var w43="Minor criminal convictions";
    var def43="A minor criminal conviction is something small you have been in trouble over with the police.  Shop lifting is an example of a minor criminal conviction. ";
    var w44="MYOB";
    var def44="MYOB is financial management software for business.";
    var w45="Networks";
    var def45="A network for business is all of your contacts, customers and the people you know through doing business. ";
    var w46="Obligations";
    var def46="Obligations are things you are responsible for.";
    var w47="One off";
    var def47="A “one off” cost is something that only needs to be paid for once.";
    var w48="Operating budget";
    var def48="The Operating Budget is a record of the income and expenses of a business.";
    var w49="Overheads";
    var def49="Overheads are the expenses or costs in running your business, the things you have to pay for.";
    var w50="Partnership";
    var def50="A partnership is where two or more people own and run a business.";
    var w51="Permission";
    var def51="Permission is where you ask if you can do something.  If you ask and the person, group or council and they say yes, you have permission.";
    var w52="Permit";
    var def52="A permit is a special license or permission to do something";
    var w53="Personal assets";
    var def53="Personal assets are things that you own, like your car, house and furniture.";
    var w54="Personal protection";
    var def54="Being part of a company offers the shareholders some personal protection from legal and debt liabilities. This means that they have less responsibility than a Sole trader.";
    var w55="Photo identification";
    var def55="Photo Identification is a document that shows who you are and has your photo on it, like a Driver’s License, 18+ card or a passport.";
    var w56="Postal address";
    var def56="Your postal address is the address where you get your mail sent.  It might be different to the address where you live.";
    var w57="Pricing structure";
    var def57="Pricing structure is where prices for something can change depending on how much the customer orders.  The bigger the order the cheaper the price becomes.";
    var w58="Private";
    var def58="Private means not part of government.";
    var w59="Profitable";
    var def59="Profitable means that there is money left over after a business pays for all of its expenses out of the money it has made.";
    var w60="Promote";
    var def60="When you promote something you try to advertise or increase the amount of people who know about it.";
    var w61="Public liability insurance";
    var def61="Public Liability Insurance gives legal protection to the business owner against getting sued by a member of the public for things like injury or property damage. ";
    var w62="Quickbooks";
    var def62="Quickbooks is financial management software for business. ";
    var w63="Registered";
    var def63="Registered means that you have recorded your information on an official list.  You register your car to be able to drive it on the road.";
    var w64="Regulations";
    var def64="Regulations are rules or laws that control what you can and can’t do.";
    var w65="Retail";
    var def65="Retail is where things get sold in small amounts to customers.  Retail usually happens in a shop and the prices are higher.";
    var w66="Service";
    var def66="A Service business provides a service, like lawn mowing or accounting services.";
    var w67="Shareholders";
    var def67="Shareholders are people that own part of a company.";
    var w68="Sole trader";
    var def68="A sole trader is where one person owns and runs a business.";
    var w69="Start up budget";
    var def69="A Start Up Budget is the first Budget that gets done for a starting business and includes all of the costs involved in setting up the business.";
    var w70="strategy";
    var def70="A strategy in business is a plan of attack, or a plan of how to get something done.";
    var w71="system";
    var def71="A system is business is a set of detailed plans and rules for how to do something in your business.";
    var w72="Vision";
    var def72="Vision in business is being able to imagine and see something in the future.  To set up a new business you need to be able to see something new that wasn’t there before.";
    var w73="Wholesale";
    var def73="Wholesale is where things get sold in large amounts, usually for a cheaper price. The Wholesale price. A wholesaler is usually a big shed where goods are stored. Wholesale is not usually available to just anyone.";

    no, that's not a reason you would use a class file.
    anyway, your document class variables are defined on the main timeline so to reference them from any timeline you can use:
    MovieClip(root).w36;  // for example  (but it's really undesirable to have coding in more than one timeline)

  • Saving an integer array into a .txt file

    hii, im only a beginner in java, so this is the only code i've learned so far for saving array elements into a file
         public static void saveNames(String [] name) throws IOException
                   FileWriter file = new FileWriter("Example\\names.txt");
                   BufferedWriter out = new BufferedWriter(file);
                   int i = 0;
                   while (i < name.length)
                             if (name[i] != null)
                                  out.write(name);
                                  out.newLine();
                                  i++;
                   out.flush();
                   out.close();
    However, this is only used for string arrays; and i can't call the same method for an integer array (because it's not compatible with null)
    I don't really understand this code either... since my teacher actually just gave us the code to use, and didn't really explain how it works
    I have the same problem for my reading a file code as well --> it's only compatible with string
         public static String [] readNames (String [] name) throws IOException
              int x = 0;
              int counter = 0;
              String temp = "asdf";
              name = new String [100];
              FileReader file = new FileReader("Example\\names.txt");
              BufferedReader in = new BufferedReader(file);
              int i = 0;
              while (i < array.length && temp != null)                    // while the end of file is not reached
                   temp = in.readLine();
                   if (temp != null)
                        name[i] = temp;                    // saves temp into the array
                   else
                        name[i] = "";
                   i++;
              in.close();                                   // close the file
              return name;
    Could someone suggest a way to save elements from an integer array to a file, and read integer elements of that file?
    Or if it's possible, replace null with a similar variable (function?), that is suitable for the integer array (i can't use temp != 0 because some of my elements might be 0)
    Thanks so much!!!!!

    because it's not compatible with nullI think it should be okay to just remove the null condition check since there are no null elements in a primitive array when writing.
    Use Integer.parseInt() [http://java.sun.com/javase/6/docs/api/java/lang/Integer.html] to convert the String into an Integer when you read it back and use Integer.toString() to be able to write it as a String.

  • Loading text from a .txt file

    I want to do something that should be VERY simple, but due to
    Adobe's insistence on using #$%^ing tutorials instead of just
    providing step by step instructions, it's very frustrating to
    figure out how to do it.
    All I want to do is load the contents of a text file into a
    dynamic text field, but I can't figure out how to do it (I'm not
    all that familiar with AS). I'm working with Flash 8. Please help.
    Thanks.

    Create the dynamic text box, and name it schedule.
    Then, in the frame on the timeline that the text box resides
    in, the corresponding actionscript would be used to create a text
    variable and assign the text from a txt file to it:
    loadText = new LoadVars();
    loadText.load("externalfile.txt");
    loadText.onLoad = function() {
    schedule.text = this.textbody;
    Where does the "textbody" variable come from? In the external
    text file (externalfile.txt in this example), you have a variable
    called textbody, and the externalfile.txt should read along the
    lines of:
    textbody = "I'm the external text that needs to be read
    in"

  • Assigning a value to a variable from a .txt file

    Hello, I'm having a slight problem doing this.
    I have a text file called text.txt, and within it is the text "one two" (minus the speechmarks).
    I'm simply trying to assign the second one of these words, (i.e. "two"), to a string variable of mine called second.
    import java.util.*;
    import java.io.*;
    public class Class
        public static void main() throws FileNotFoundException
            FileReader file = new FileReader("C:\\Documents and Settings\\Admin\\Desktop\\numbers.txt");
            Scanner scanner1 = new Scanner(file);
    String first = scanner1.next();
    //String second =   // this is the part I don't know.
    System.out.println(first); //this works fine, and shows "one"
    System.out.println(second) // this is what I'm trying to make work, by showing "two".
    }I hope I've explained myself clearly.
    Thanks a lot, I'm really struggling with this seeminly-simple problem.

    The Scanner API has good examples of how to use the class's methods. Try
    String second =scanner1.next();And change the name of your class from "Class" to something else. Java uses that name for one of its classes.

  • Saving a CSV report output as TXT file

    Hi,
    We are generating reports on the web using Intenet Explorer. The report is a CSV report, i.e. the data displayed is comma separated. After generating the report, we need to save it as TXT file.
    If the length of a line is long (let us say more than 80 chars) while saving it as TXT file, it is saving as 2 lines. If the length of a line is less, then it is saving in a single line.
    How can I avoid this 2 line problem?
    I am not facing this problem if I generate report with Netscape browser and save as TXT file.
    We are using Reports 6i.
    Thanks in Advance,
    Srinivas

    Hello,
    I had the same problem. And I think what I did to fix it is I made the mode=charcter, batch=yes, and background=yes. Hope this helps.
    Martin

  • Help needed saving text members to TAB delimited txt file

    I have 7 text memebrs each containing several lines of text
    that were pulled in and sorted from a TAB delimited text file.
    What I'd like to know is, is there any way to convert those
    text members back into the TAB delimited format from which they
    came? I'd like to be able to pull in the data, let it be edited to
    some extent, then saved back out..... and I'm not too sure how to
    go about it.
    Example of txt file:
    ID_No Name Age
    1 Phil 26
    2 Sam 34
    3 Mary 21
    They're then sorted in to text files of ID_No, Name, and Age,
    with the lists of the relevent items in each.
    Like.....
    ID_No
    1
    2
    3
    Name
    Phil
    Sam
    Mary
    Age
    26
    34
    21
    Certain lines of these text members change, depending on what
    the user selects. I'd like to put these sections back in their
    original TAB delimited format, but with any changed data replacing
    the old, so next ime the app is opened the new data is pulled in
    from the txt file.
    I know I'm probably going about this the wrong way, but it's
    the only way I know so far lol
    Any ideas?

    global filex, idlst, namelst, agelst
    on readtabline (str)
    tmpstr = ""
    y = 1
    repeat with x = 1 to the number of chars in str do
    if str.char[x] = tab then
    case y of
    1 : idlst.add (tmpstr)
    2 : namelst.add (tmpstr)
    3 : agelst.add (tmpstr)
    end case
    tmpstr = ""
    y = y + 1
    else
    tmpstr = tmpstr & str.char[x]
    end if
    end repeat
    agelst.add (tmpstr)
    end
    on exitFrame me
    idlst = [] --set up some lists to hold that data we read in
    namelst = []
    agelst = []
    filex = new (xtra "fileio")
    filex.openfile ("t.txt", 1)
    indata = filex.readfile() -- read the data in
    filex.closefile()
    filex = void
    repeat with x = 1 to the number of lines in indata do
    readtabline(indata.line[x]) --seprate it into its diffrent
    elements
    end repeat
    -- you now have your data sorted in to three list of id, age
    and name
    -- so you would now do what ever editing you wanted to do
    --now to write it out to a new file
    filex = new (xtra "fileio")
    filex.createfile (the moviepath & "tout.txt")
    filex.openfile (the moviepath & "tout.txt", 2)
    repeat with x = 1 to idlst.count() do
    filex.writestring (idlst[x] & tab & namelst[x] &
    tab & agelst[x] & return)
    end repeat
    filex.closefile()
    end
    I tested this on your exact scenario and it worked a brezze
    hope it helps
    Regards
    David

  • Increment  variable in a txt file

    Hello hello [[]] =)
    Just wondering if is it possible to change on string to another , inside a txt file. The problem is:
    Someone ask a question , choose the number of answers, write those answers and send it to a comboBox ( the answers) .
    The person who's gonna answer that question pick an answer from the ComboBox, and the program saves it in a txt file the number of times that that answer was picked. like an inquiry.
    And at the end , it gives the % of each answer, that was picked.
         private class handler implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   String option = combo.getSelectedItem().toString();   // get the selected item from the combobox (answer)
                   int index = combo.getSelectedIndex();     //position of that answer from the comboBox          
                   int count_answer =0;
                   for (int i=0; i!= array.length; i++) // array -> an array of Strings that has all the answers inside it
                        if(option.equals(array)) ++count_answer; // option is the answer picked by the user.
                        try{
                             r = new BufferedReader(new FileReader(option));
                             frame.setVisible(false);
                             rewrite(index, option, count_answer);     
                        }catch(IOException ex){
                             try {
                                  w = new PrintWriter(new FileWriter(option));
                                  w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count_answer +" time(s)");
                                  frame.setVisible(false);
                                  w.close();
                             } catch (IOException e1) {
                                  e1.printStackTrace();}
         public void rewrite(int index, String option, int count) throws IOException{
         int increment ;
              w = new PrintWriter(new FileWriter(option));
              count = count + increment++;
              w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count +" time(s)");
              w.close();
    I don't know how to change that variabel "count " inside a txt, so what im doing is increment the variable count++ and rewrite the string again inside that file.
    The problem is that, the variabel "count" counts until two , and that's all, if u run the program again (third time) , it should shows " 3 times ...4 times and so on.."
    but it doesn't.
    thanks

    total code to run :
    package ClienteMsn;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.Label;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class Poll {
         private String pergunta;
         private int num_respostas;
         private String[] respostas_possiveis;
         String [] array;
         String [] nomeFiles;
         private JTextArea area = new JTextArea(2,3);
         private JPanel painel_respostas = new JPanel(new FlowLayout(FlowLayout.LEFT));
         private JPanel painel =new JPanel(new BorderLayout());
         private JButton submit = new JButton("Confirm");
         private JPanel painel_botao = new JPanel(new FlowLayout(FlowLayout.CENTER));
         private JFrame frame = new JFrame("Questionario");
         private SentinelaParaAc??es sentinela = new SentinelaParaAc??es();
         private JComboBox combo;
         PrintWriter w;
         BufferedReader r;
         public Poll(final String pergunta, final int num_respostas, final String[] respostas_possiveis) {
              this.respostas_possiveis = respostas_possiveis;
              this.pergunta = pergunta;
              this.num_respostas = num_respostas;
              array = respostas_possiveis;
              combo = new JComboBox(respostas_possiveis);
              nomeFiles = new String[num_respostas];
              Container contentor = frame.getContentPane();
              contentor.setLayout(new BorderLayout(0, 20));
              area.setBackground(Color.WHITE);
              Label label = new Label("Resposta:     ");
              label.setFont(new Font("", Font.BOLD, 12));
              painel_botao.add(submit);
              area.setFont(new Font("", Font.BOLD, 13));
              area.append(pergunta);
              painel.add(label, BorderLayout.WEST);
              painel.add(combo, BorderLayout.CENTER);
              painel_respostas.add(painel);
              contentor.add(painel_respostas, BorderLayout.CENTER);
              contentor.add(area, BorderLayout.NORTH);
              contentor.add(painel_botao, BorderLayout.SOUTH);
              submit.addActionListener(sentinela);
         public int getNum_respostas() {
              return num_respostas;
         public String getPergunta() {
              return pergunta;
         public String[] getRespostas_possiveis() {
              return respostas_possiveis;
         public void executa() {
              frame.setLocation(300,300);
              frame.setSize(550, 190);
              frame.setVisible(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private class SentinelaParaAc??es implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   String option = combo.getSelectedItem().toString();
                   int index = combo.getSelectedIndex();               
                   int cont_answer =0;
                   for (int i=0; i!= array.length; i++)
                        if(option.equals(array)) ++cont_answer;
                        try{
                             r = new BufferedReader(new FileReader(option));
                             frame.setVisible(false);
                             rewrite(index, option, cont_answer);     
                        }catch(IOException ex){
                             try {
                                  w = new PrintWriter(new FileWriter(option));
                                  w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ cont_answer +" time(s)");
                                  frame.setVisible(false);
                                  w.close();
                             } catch (IOException e1) {
                                  e1.printStackTrace();}
         public void rewrite(int index, String option, int count) throws IOException{
              w = new PrintWriter(new FileWriter(option));
              int increment = 0 ;
              count = count + (++increment);
              w.write("Answer("+(index+1)+ ")- "+ option +"\nSelected "+ count +" time(s)");
              w.close();
         public static void main(String[] xxx){
              String [] recolhe = null;
              String pergunta = JOptionPane.showInputDialog("Question: ");
              String r = JOptionPane.showInputDialog("Number of answers: ");
              int numrespostas = Integer.parseInt(r);
              recolhe = new String[numrespostas];
              int i = 0;
              while(i != numrespostas){
                   String respostas = JOptionPane.showInputDialog("Answer ("+(i+1)+") :");
                   recolhe[i] = respostas;
                   i++;
              new Poll(pergunta, numrespostas, recolhe).executa();
    Message was edited by:
    Java__Estudante

  • Saving and loading images (png) on the iPhone / iPad locally

    Hi,
    you might find this helpful..
    Just tested how to save and load images, png in this case, locally on the i-Devices.
    In addition with a SharedObject it could be used as an image cache.
    Make sure you have the adobe.images.PNG encoder
    https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/PNGEncoder.as
    Not really tested, no error handling, just as a start.
    Let me know, what you think...
    Aaaaah and if somebody has any clue about this:
    http://forums.adobe.com/thread/793584?tstart=0
    would be great
    Cheers Peter
        import flash.display.Bitmap
         import flash.display.BitmapData
        import flash.display.Loader   
        import flash.display.LoaderInfo
        import flash.events.*
        import flash.filesystem.File
        import flash.filesystem.FileMode
        import flash.filesystem.FileStream
        import flash.utils.ByteArray;
        import com.adobe.images.PNGEncoder;
    private function savePic(){
        var bmp =  // Your Bitmap to save
        savePicToFile(bmp, "test.png")
    private function loadPic(){
         readPicFromFile("test.png")
    private function savePicToFile(bmp:Bitmap, fname:String){
           var ba:ByteArray = PNGEncoder.encode(bmp.bitmapData);
            var imagefile:File = File.applicationStorageDirectory;
            imagefile = imagefile.resolvePath(fname);
            var fileStream = new FileStream();
            fileStream.open(imagefile, FileMode.WRITE);
            fileStream.writeBytes(ba);
             trace("saved imagefile:"+imagefile.url)
    private function readPicFromFile(fname:String){
            var imagefile:File = File.applicationStorageDirectory;
            imagefile = imagefile.resolvePath(fname);
            trace("read imagefile:"+imagefile.url)
            var ba:ByteArray = new ByteArray();
            var fileStream = new FileStream();
            fileStream.open(imagefile, FileMode.READ);
            fileStream.readBytes(ba);
            var loader:Loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPicRead)
            loader.loadBytes(ba);   
    private function onPicRead(e:Event){
        trace("onPicRead")
         var bmp:Bitmap = Bitmap(e.target.content)
         // Do something with it

    Are the movies transferred to your iPhone via the iTunes sync/transfer process but don't play on your iPhone?
    Copied from this link.
    http://www.apple.com/iphone/specs.html
    Video formats supported: H.264 video, up to 1.5 Mbps, 640 by 480 pixels, 30 frames per second, Low-Complexity version of the H.264 Baseline Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; H.264 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Baseline Profile up to Level 3.0 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats.
    What are you using for the conversion? Does whatever you are using for the conversion include an iPod or iPhone compatible setting for the conversion?
    iTunes includes a create iPod or iPhone version for a video in your iTunes library. Select the video and at the menu bar, go to Advanced and select Create iPod or iPhone version. This will duplicate the video in your iTunes library. Select this version for transfer to your iPhone to see if this makes any difference.

  • SFE2000 saving and loading configuration

    I have a number of SFE2000 10/100 24 port POE switches.
    They are configured and running OK. I want to be able to save the configuration and be able to load that saved configuration into another new swich in the case of a failure.
    I have logged in and gone to Admin-File Management-Save Configuration. I then select the 'Backup' radio button and TFTP the configuration to my TFTP server. All works OK and I have a readable text file with the switch configuration on my TFTP server.
    Now, here comes the problem.
    I want to be able to restore that saved configuration on to a new switch.
    I have set the new switch back to factory defaults. I go to  Admin-File Management-Save Configuration. I then select the 'Upgrade' radio button and try and uploade the file into the switch.
    If load to 'Running Configuration' the switch shows a status of 'Copy Finished' but says 'Copy completed with errors'
    If load to 'Startup Configuration' the switch shows a status of 'Copy Failed' and says 'Copy completed with errors'
    Am I missing something here???
    I am guessing I should be able to load my saved Configuration back into a switch, shouldn't I??
    And yes the switches are running the same firmware 3.0.0.17
    Any help gratefully received. I am scratching my head here...
    Alan

    Hi Alan,
    Thank you so much for your feedback.
    When copying over TFTP, is there another error message following the described : %COPY-W-TRAP: The copy operation has failed ? I would suppose that at least a second message would be logged with the reason for the failure.
    As far as the transfer of configuration files is concerned, it is always safer to make sure the FW versions of both devices are the same. As far as upgrading is concerned. Switches that use the older fw version 1.0.0.x need to be upgraded to 3.0.0.17 first using the easy upgrade utility. Switches with HW version 2 and FW version 2.x should be upgraded using the regular TFTP or HTTP method (not the easy upgrade utility). All of this can be read in the release notes for fw 3.0.0.17 and 3.0.0.18
    As far as Xmodem is concerned, you make the connection to the switch using Hyperterminal, TeraTerm Pro or any other terminal emulator supporting Xmodem, when booting the switch, you can escape the boot sequence (given the switch does not boot up) by pressing Esc or Enter when this appears on the screen. You'll then have an option to "Download Software", select this option. Then on your terminal emulator, select to transfer file (send) using Xmodem. This should do the trick.
    Hope this helps,
    Best regards,
    Nico Muselle
    Sr. Network Engineer - CCNA

Maybe you are looking for