Reading text file with multiple variables

When I open a text document containing 1 string of a Base64 Encoded Image, it works fine:
import flash.display.Loader;
import flash.utils.ByteArray;
import formatter.Base64;
var imgB64Str:String="";
var ld:Loader=new Loader();
var my_req:URLRequest = new URLRequest("horses.img");
var my_loader:URLLoader = new URLLoader();
my_loader.addEventListener(Event.COMPLETE, loadText);
my_loader.load(my_req);
function loadText(e:Event):void{
    // set string variable to loaded text
    imgB64Str = my_loader.data;
    // position, decode & display
    ld.x = ld.y = 50;
    ld.loadBytes(Base64.Decode(imgB64Str));
    addChild(ld);
The image displays and that's great, but I need to display multiple images; therefore, I used the standard format: var1=value1&var2=value2&...
(In reality, the values are the huge base64 strings.)
Then I just needed to add "my_loader.dataFormat = URLLoaderDataFormat.VARIABLES;" since the format of my source changed.
The thing that bugs me is that I'm tracing the imgB64Str after I set it and it traces fine (just like the other version). And from then on I'm not doing anything different!
See my comments for things I did different...
import flash.display.Loader;
import flash.utils.ByteArray;
import formatter.Base64;
var imgB64Str:String="";
var ld:Loader=new Loader();
var my_req:URLRequest = new URLRequest("images.img"); // CHANGED: source file, due to new format
var my_loader:URLLoader = new URLLoader();
my_loader.dataFormat = URLLoaderDataFormat.VARIABLES; // CHANGED: formatting input from text to variables
my_loader.addEventListener(Event.COMPLETE, loadText);
my_loader.load(my_req);
function loadText(e:Event):void{
    imgB64Str = my_loader.data.image1; // CHANGED: instead of grabbing whole data, grabbing the image1 variable
    trace(imgB64Str); // CHANGED: traces fine!
    // same as other from here down!
    ld.x = ld.y = 50;
    ld.loadBytes(Base64.Decode(imgB64Str));
    addChild(ld);
It runs with no errors, but the image no longer displays.
What's the deal?!? :/
Any help is greatly appreciated.

See this site: AN EASY REFERENCE FOR OLE AUTOMATION by Serder Simsekler.
Best!
Jim

Similar Messages

  • Read a file with a variable=counter : NAMEFILE001,NAMEFILE002..

    Hello,
    I would need your councils.
    I can read a logical file on my server(logical example of name: NAMEFILE) with function FILE_GET_NAME.
    But I would like to be able to read a file with a counter i.e.
    the first time: to read NAMEFILE001;
    the second time read NAMEFILE002;
    the third time read NAMEFILER003...
    How made you that?
    With function FILENAME_EXIT _?
    But, where do I put the variable = counter? In a table...?
    Thank you in advance of your answer
    Servane

    Hi Servane,
    You could also do the following:
    in transaction FILE you set up the physical path name as follows:
    /<i>path</i>/.../<FILENAME><PARAM_1>
    then you call the function FILE_GET_NAME:
      CALL FUNCTION 'FILE_GET_NAME'
           EXPORTING
             LOGICAL_FILENAME        = W_LOGICAL_FILENAME
             PARAMETER_1             = W_FILENUMBER
          IMPORTING
               FILE_NAME               = THEFILE
           EXCEPTIONS
                FILE_NOT_FOUND          = 1
                OTHERS                  = 2.
    This will equally construct the name/counter as you wish.
    AND, if I am not wrong, since the system does it, you will not have to worry about putting the last counter value away in the DB.
    cheers,
    Phil
    Message was edited by: Phillip Morgan

  • How to read text file with big5 into db

    hi,
    how can i use UTL_FILE package to
    read a text file with big5 characters and insert into db?
    my oracle charset is AL32UTF8.
    thx a lot!

    Thx for yr answer!!!
    I have followed and it works.
    However, I got another problem with HKSCS. When the text file contained HKSCS, the store procedure also treats it as Big5 and when I select it out, the character was not the orginal one.
    Please suggest if you have any ideas.
    Many Thanks!!!

  • Best way to read text files at multiple production sites

    Need to write a solution to read txt files that contain binary data on multiple SQL Servers. I have no control over the SQL servers, they are not mine. Thinking of BULK INSERT or bcp. But must something on the server be turned on for it to work? What are
    some other production solutions for reading files and loading the data into a SQL table?

    Hello,
    I think the best way is create a SSIS package to import data into SQL Server tables. Here are some articles for your reference:
    http://codejotter.wordpress.com/2010/04/06/importing-multiple-text-files-using-ssis/
    http://technet.microsoft.com/en-us/sqlserver/dd941934.aspx
    Regards,
    Elvis Long
    TechNet Community Support

  • Read ini file with multiple threads

    I have a state machine architecture, but I have multiple threads. For instance, one is dealing with listening for mulitple tcp connections and storing their refnums to an array in a functional global. Another thread is accessing these refnums and collecting data it's receiving from each tcp connection. This data is queued up and then dequeued in a third thread which does some modification and sends it out via serial. My question is, when you have a situation like this and have to read an ini file, where should you read it? It seems like the most logical place would be outside your loops so you can get all the tcp and serial info (port, baud rate, etc) then wire it it to your create listener or initialize serial connection despite them being in different threads. But then again, normal state machine architecture would want an "initialize" case. If you did this though which loop would you put the init case in? And you would then have to worry about synchronizing loops becuase you wouldn't want one to try and create a listener while another thread was still reading ini data which would include the port to listen on. Maybe I'm overthinking this haha. Suggestions? Edit: one more question. Does it seem overkill that I have a tcp loop listening for data and queuing it up and a separate loop sending out the processed data via serial? Or should I just have one state that gets tcp data stores it in a shift register, then another state that sends it out via serial, and returns the state machine to the tcp read state?
    Message Edited by for(imstuck) on 03-03-2010 01:13 PM
    Message Edited by for(imstuck) on 03-03-2010 01:17 PM
    CLA, LabVIEW Versions 2010-2013

    Most of the applications I work on at the moment are used for testing barcode and label printers. The test applications I design are focused on testing the printer's firmware, not the hardware. Within our applications we have three primary objects (Unfortunately they are not native LabVIEW objects yet. They were developed before native LVOOP.) The primary objects we use in our applications are a log object, a connection object (communication interface to the printer) and a printer object. In any single instance of a test we only have a single printer, a single connection to the printer and one or more discrete logs. Each instance of these objects represent a single, real physical entity. A singleton object is a virtual representation of the physical world. Let's take the log object since that is the most simple of the objects described above. Naturally for a given log file you have the log file name and path. We also provide other attributes such as the maximum size of a single file (we allow log files to span multiple files), whether it is a comma delimited file or if it contains raw data, if timestamps should be included with a log entry and so forth. Most of these attributes are static for a log file with the exception of the name and such things as whether the logging is actually enabled or disabled. If we split a wire and had multiple instances of the log file (the way native LVOOP actually works) the attribute for whether logging is currently enabled or disabled will only pertain to the specific instance, or specific wire for the that object. Since this truly represents a single item, one log file, we need that attribute to be shared for all references to the instance of the log object. Since we allow this we can set an attribute on the log object in any task and it will be reflected in any other task that is using it. Think of the way a action engine or functional global works. However, in this case we provide discrete methods for the various actions.
    I hope that made some sense. If not let me know since I just whipped up this response.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Reading a file with multiple threads?

    I have a file that contains some data. In my application, I currently have three worker threads that perform the same long-executing task using three different data sets. They each need to read some data from the same file. Is this a problem as long as they are only reading it? I know it would be if they modified it but I didn't think it was a problem if they were only reading it.
    Edit: It is an XML file and I am using the XML Decoder to read it.
    Edited by: Sch104 on Jul 2, 2008 9:08 AM

    If the file is on a diskdrive, it's likely that your program will be i/o bound and threads won't help.
    Edited by: ChuckBing on Jul 2, 2008 11:32 AM

  • File2Idoc: File with Multiple Occurence

    Hi,
    In  File2 Idoc scenario: how to read a file with multiple structure/occurrence. I tried as per below links, it is picking only first structure i.e - (Data0).
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    http://wiki.sdn.sap.com/wiki/display/XI/FiletoMultipleIDOCSplittingwithoutBPM
    My Input file as like :-
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_SENDER xmlns:ns0="http://FileToIdoc">
    - <DATA0>
      <DOC_NUM>0017000374</DOC_NUM>
      <POSITION_NUM>10</POSITION_NUM>
      <DELVRY_ITEM>000000000000000014</DELVRY_ITEM>
      <PLANT>1010</PLANT>
      <QUANTITY>3</QUANTITY>
      <DATE>2010.08.24</DATE>
      <SERIAL>AAAA01E1123458</SERIAL>
      </DATA0>
    - <DATA1>
      <DOC_NUM>0017000374</DOC_NUM>
      <POSITION_NUM>10</POSITION_NUM>
      <DELVRY_ITEM>000000000000000014</DELVRY_ITEM>
      <PLANT>1010</PLANT>
      <QUANTITY>3</QUANTITY>
      <DATE>2010.08.24</DATE>
      <SERIAL>AAAA01G1123456</SERIAL>
      </DATA1>
    - <DATA2>
      <DOC_NUM>0017000374</DOC_NUM>
      <POSITION_NUM>10</POSITION_NUM>
      <DELVRY_ITEM>000000000000000014</DELVRY_ITEM>
      <PLANT>1010</PLANT>
      <QUANTITY>3</QUANTITY>
      <DATE>2010.08.24</DATE>
      <SERIAL>AAAA01G1123457</SERIAL>
      </DATA2>
      </ns0:MT_SENDER>
    Please suggest concept.
    Thanks.

    Hi,
    The structure what you have created wrong, create this structure and change occurrence of DATA to 1 to unbounded.if you want to read multiple records (same structure) then it is not required to create same structure multiple times.
    *<DATA>+ 1 to unbounded.*
    >   +<DOC_NUM>0017000374</DOC_NUM>+

    >   +<POSITION_NUM>10</POSITION_NUM>+

    >   +<DELVRY_ITEM>000000000000000014</DELVRY_ITEM>+

    >   +<PLANT>1010</PLANT>+

    >   +<QUANTITY>3</QUANTITY>+

    >   +<DATE>2010.08.24</DATE>+

    >   +<SERIAL>AAAA01E1123458</SERIAL>+

    >   +</DATA>
    Regards,
    Raj

  • Importing a text file with variable values into web reporting

    Hello,
    I'm looking for a possibility to import values from a text file into a variable selection in Web reporting.
    With BEx reporting in Excel this is possible, by clicking on the multiple selection button in the variable popup screen, and subsequently selecting the "Import from Text file" button.
    However, this function seems not to be available for web-reporting...
    It would be great if someone could help me out with this!
    Thanks & regards,
    Arvid

    Hi,
    we could resolve this issue, so i thought it may also be helpful for others:
    In our example we used a file with numbers for materials. This file is stored somewhere in a directory, to which SAP BI must have authorization to read.
    The file looks something like this:
    4711
    4712
    4713
    4714
    The file is named "import.txt" and lays in directory "/usr/sap/EC6/files/bi/"
    *&  Include           ZXRSRU01
    * global variables
    Data: intern_range LIKE LINE OF i_t_var_range,
          l_s_range    TYPE rsr_s_rangesid,
          line(100)    TYPE c,
          p_file(128)  TYPE c,
          length_rangelow  type i,
          tmp_rangelow     like l_s_range-low.
    * internal tables for selection-transfer from transaction
    * Data: BEGIN OF it_file occurs 0,
    *        it_p_file(128) TYPE c,
    *      END of it_file.
    IF i_step = 1.
    ** variables can be changed or set before pop-up appears
      CASE i_vnam.
    * take material from external file to selection-list
         WHEN 'ZSD_UPMA'.
    ** call of transaction, with which the path can be set
    *CALL TRANSACTION 'ZBW_VARIABLE' using it_file
    *MODE 'A'      " call should be visible, so that variable can be set
    *UPDATE 'S'.   " first transaction, then processing
    ** Der Pfad, der in dem Selektionsbild eingegeben wird, wird an die Variable übergeben
    ** Der Set-Parameter ist in Report ZSD_SELECT_VARIABLE
    *  get parameter id 'VAR' field p_file.
    p_file = '/usr/sap/EC6/files/bi/import.txt'.
    * further handling of variable in BI
          OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
          IF sy-subrc = 0.
            READ DATASET p_file INTO line.
            WHILE sy-subrc = 0.
              IF line(2) <> '//'.
                l_s_range-sign = 'I'.
                l_s_range-opt  = 'EQ'.
                l_s_range-low  = line.
    * fill with leading Zeros
    * in variable tmp_rangelow the value from l_s_range-low is taken
        tmp_rangelow    = l_s_range-low.
    * read the length
        length_rangelow = strlen( tmp_rangelow ).
    * in our case: material has 18 characters
        while length_rangelow lt 18.
          CONCATENATE '0' tmp_rangelow INTO tmp_rangelow.
          length_rangelow = length_rangelow + 1.
        endwhile.
    * initialize l_s_range-low
        clear l_s_range-low.
    * set with filled values
        l_s_range-low = tmp_rangelow.
    * transfer to structure
                APPEND l_s_range TO e_t_range.
              ENDIF.
              READ DATASET p_file INTO line.
            ENDWHILE.
          ENDIF.
          CLOSE DATASET p_file.
        ENDCASE.
    ELSEIF i_step = 2.
    ** in step 2 all variable values from pop-up input can be processed or
    ** User Exit variables can be derived
    * UserExit Ende.
    ENDIF.
    Hope i could help!
    Best regards,
    Tobias

  • Reading dilimited input from a text file with tokenizer

    i am trying to read in a text file with the following structure: 2 integers on each line with comma as the delimitor.
    i am using the BufferedReader stream and Tokenizer to detect ",".
    try {
    BufferedReader in = new BufferedReader(new FileReader(filename));
    //read in the data file
    while ((s = in.readLine())!= null) {
    int i = 0;
    for (i = 0; i < 100; i++) {
    t = new StringTokenizer(s,",");
    A1 = Integer.parseInt(t.nextToken());
    catch (IOException e) {System.err.println(e);}
    When i print out A1[i], it only reads the last line of the text file. Please tell me what's wrong.
    Also i'd really like A1[i] to store the integer before the comma and another array A2[i] to store the integer after the comma. Please help.
    Thanks.
    p.s. A1 and A2 are arrays...when i previewd message in Netscape 7 it left out the brackets and the index....

    What is the for i loop for? If it is to read the next line from the file, then the while loop has taken care of it. Other than this there should be no problem with the rest of the code.
    Just add another line to store the next token into A2.

  • Importing text file with variable spaces

    Hi all
    I have a text file with a varying amount of spaces in it. Typical output from the file is attached.
    How can I separate the values into separate columns please?
    Thanks in advance.

    You're going to need some substrings:
    DECLARE @flatFileLine VARCHAR(MAX) = '2002 01118511 0.00 0 0.00 0.00 PENDING '
    SELECT
    SUBSTRING(@flatFileLine,1,4),SUBSTRING(@flatFileLine,5,17),SUBSTRING(@flatFileLine,22,17),SUBSTRING(@flatFileLine,39,17),SUBSTRING(@flatFileLine,56,17),SUBSTRING(@flatFileLine,73,17),SUBSTRING(@flatFileLine,90,17)

  • 'No Upload Authorization' While Uploading a Text File from Multiple Select

    Hi all,
       The User is trying to upload a text file from Multiple Selection screen of a Query in BEx and it gives the error message of 'No Upload Authorization' (Error DB886).
       In 'Logon data' tab of Tcode SU01, it has 'User' for 'User Group for Authorization check' for this User.
       I could upload a text file from Multiple Selection screen with my User Id.
       An idea about this error, PLEASE ?
    Thanks,
    Venkat.

    Hi Ron,
       This User does not have the access to Tcode ST01.
       The user executed Tcode SU53 immediately following the authorization failure to see the authorization objects. The 'Authorization obj' is blank and under the Description it has 'The last Authorization check was successful' with green tick mark.
      Any further suggestions, PLEASE.
    Thanks.

  • Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO

    Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO#, Date, ect.)

    When you say field, do you mean specifically a form field, such as a text field? Or is the information regular text on the page?

  • To read text file using utl_file

    I would like to read test_file_out.txt which is in c:\temp folder.
    create or replace create or replace directory dir_temp as 'c:\temp';
    grant read, write on directory dir_temp to system;
    then when i execute the below code i get the error .
    // to read text file using utl_file
    DECLARE
    FileIn UTL_FILE.FILE_TYPE;
    v_sql VARCHAR2 (1000);
    BEGIN
    FileIn := UTL_FILE.FOPEN ('DIR_TEMP', 'test_file_out.txt', 'R');
    UTL_FILE.PUT_LINE (FileIn, v_sql);
    dbms_output.put_line(v_sql);
    UTL_FILE.FCLOSE (FileIn);
    END;
    ERROR:
    invalid file operation
    i would like to use ult_file only and also can you let me know to read the text file and place its contents in tmp_emp table?

    Are you trying to read the contents of the file into the local variable? Or write the contents of the local variable to the file?
    Your text talks about reading the file. And you open the file in read mode. But then you call the UTL_FILE.PUT_LINE method which, as SomeoneElse points out, attempts to write data to the file. Since the file is open in read-only mode, you cannot write to the file.
    If the goal is really to read from the file, replace the UTL_FILE.PUT_LINE calls with UTL_FILE.GET_LINE. If the goal is really to write to the file, you'll need to open the file in write mode ('W' rather than 'R' in the FOPEN call).
    Justin

  • Pull a zip file with multiple files unzip it, and finally load one of the f

    Hi Aill,
    I have following query.
    Could we do the following with XI: pull a zip file with multiple files from a vendor which resides outside of XI server network, unzip it, and finally load one of the files to SAP?
    Regards
    Rohan S

    Hi Varadharajan,
    I have 10 text files in some ZIP file on one server which is out side of network. We can reach that file through Proxy only to read ZIP file.
    I need to extract the file and on the bases of some condition one of the file i need to upload data to SAP.
    Is it possible. If possible then How?
    Regards

  • Importing text file (with file names) into Automator.. is it possible?

    Hello all,
    I have been working with Windows Batch files for my line of work. I have a couple of file names in a text file (a column), which I want to copy from one folder of one hdd to another folder on a different hdd. I have been trying to do this kind of work with a Mac. I already know how you copy and rename files in automator (which isn't difficult, of course) but you have to 'select' the files in the finder first (with get specified items).
    But the only way i see that you can specify items is by selecting them... is there a way to import a text file with all the file names instead of selecting all the file names manually?
    or is there an AppleScript alternative which I can use to import the text file (or just copy into applescript) and run before the query's of copying and renaming the files? I am kind of new to Apple programming.
    The text file looks like this:
    image1.jpg
    image2.jpg
    etc..
    so there has to be a command to: 'goto' a specific folder as well.
    Thanks in advance!

    You can import text files, but if they are just names you will need an additional action to add the source folder path. A *Run AppleScript* action can be used, for example:
    Tested workflow:
    1) *Ask for Finder Items* {Type: files } -- choose the text file containing the names
    2) *Combine Text Files* -- this gets the text file contents
    3) *Filter Paragraphs* { return paragraphs that are not empty } -- skip blank lines
    4) *Run AppleScript* -- copy and paste the following script:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 680; height: 340px;
    color: #000000;
    background-color: #FFEE80;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters} -- add folder path
    add the specified folder path to a list of file names
    input: a list of text items (the file names)
    output: a list of file paths (aliases)
    set output to {}
    set SkippedItems to {} -- this will be a list of skipped items (errors)
    set SourceFolder to (choose folder with prompt "Choose the folder containing the file names") as text -- this is the folder containing the names
    repeat with AnItem in the input -- step through each name in the input
    try
    set AnItem to SourceFolder & AnItem -- add the prefix
    set the end of the output to (AnItem as alias) -- test
    on error number ErrorNumber -- oops
    set ErrorNumber to ("  (" & ErrorNumber as text) & ")" -- add the specific error number
    set the end of SkippedItems to (AnItem as text) & ErrorNumber
    end try
    end repeat
    ShowSkippedAlert for SkippedItems
    return the output -- pass the result(s) to the next action
    end run
    to ShowSkippedAlert for SkippedItems
    show an alert dialog for any items skipped, with the option to cancel the workflow
    parameters - SkippedItems [list]: the items skipped
    returns nothing
    if SkippedItems is not {} then
    set {AlertText, TheCount} to {"Error with AppleScript action", count SkippedItems}
    if TheCount is greater than 1 then
    set theMessage to (TheCount as text) & space & " items were skipped:"
    else
    set theMessage to "1 " & " item was skipped:"
    end if
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set {SkippedItems, AppleScript's text item delimiters} to {SkippedItems as text, TempTID}
    if button returned of (display alert AlertText message (theMessage & return & SkippedItems) ¬
    alternate button "Cancel" default button "OK") is "Cancel" then error number -128
    end if
    return
    end ShowSkippedAlert
    </pre>
    5) *Copy Finder Items* { To: _your external drive_ }

Maybe you are looking for

  • How to use same dynamic text, multiple times in a Movie

    FLASH CS5.5 How can a dynamic text field be used multiple times, on any frame, in any new layer during a Movie? ~~ A number of unique dynamic text fields are being used. The intent is to use them each, many times during a Movie. (i.e. a users first n

  • Org'l Unit date

    Hi, Can any one guide me, While we are creating our Org'l Unit through Simple maintenance, What date we should create in PPOC_OLD. But our client organization is started in 2003 & Company code is created in 2005. When am creating 2004, 0001 infotype

  • Enterprise Systems Vs Distributed Systems

    What is the difference between Enterprise system and Distriubted system and Role of J2EE in these two systems?

  • Archive Log file size

    I am using Oracle database 9.2.0.1.0, My OS is Linux AS4 Update version. My database is in archive log mode, the archive file size generated on disk is 100 MB. I want to monitor the reason that why the size of redo generated is too big. Kindly sugges

  • TLS support wildcard cert?

    Hi everyone, I'm planning to enable TLS on our email traffic, but was wondering if that will conflict with the wildcard certificate we currently have enabled on the server? I couldn't find any information about smtp tls errors because of it on google