Getting raw data of a variable

Is anyone aware of a handy way to get the raw (hex) data of an AppleScript variable into a text string? For example:
«data rdatEFBBBF»
«data isot323030372D31322D31325431373A34393A3130»
I can do some comparisons, and put the raw data as text into a variable, but trying to get the actual raw data as text either fails or gets coerced into whatever it is supposed to be (such as ISOT). Well, actually I can do the "force an error and grab the error message" trick, but there has got to be a better way. Perhaps something along the lines of set X to do shell script "whattheheck " & (SomeVariable as data)?

Hello
Under OS9/Classic, we can use a mighty 'cast' command of 'programmer's tool' OSAX made by Ed Lai for this kind of task.
http://osaxen.com/files/programmerstool1.0a10.html
Under OSX, the ladder has been removed.
One dirty way I can think of is to use write and read commands to force to replace the class of given data. Somethnig like this, though it won't work properly with AppleScript 2.0 if the input or output data is a sort of text object.
--SCRIPT
set x to «data isot323030372D31322D31325431373A34393A3130»
--set x to «data rdatEFBBBF»
--set x to current date
--set x to {1, 2, 3}
--set x to "ABC" as Unicode text
set y to dump(x, string)
set z to dump(y, data)
return {x, y, z}
on dump(x, cls)
  anything x : anything to be dumped [1]
  type class cls : resulting class of dumped data. e.g. string, data etc.
  return anything : dumped data as given class [2]
  * Notes.
  [1] x must be what 'write' osax can write to file. (E.g. script object etc cannot be processed by this method)
  [2] It won't return exact raw byte sequence in AppleScript 2.0 if
    - x's class is one of {Unicode text, string, text}; or
    - cls is one of {Unicode text, «class utf8», string, text}.
set fp to (path to "desk" from user domain as Unicode text) & "scptdump_tempfile" & (random number 1000000)
try
set fref to open for access file fp with write permission
set eof fref to 0
write x to fref
close access fref
set d to read file fp as cls
on error errs number errn
try
close access file fp
end try
error "dump():" & errs number errn
end try
do shell script "rm -f " & quoted form of POSIX path of fp
return d
end dump
--END OF SCRIPT
Hope this may be of some help,
Hiroto
PS.
In pre-AS 2.0, we can use 'string' to hold raw byte sequence of any kind of data, although it might be indeed an abuse of 'string' object. In AS 2.0, we seem to have lost this final way to abuse string and I'm yet to know any alternative way to process raw byte sequence safely.
Now, I think, it would be really nice to see the following basic features being implemented with «class rdat» in order to process raw byte sequence in AppleScript 2.0 or later, where we cannot 'abuse' string anymore:
• length property; e.g. length of «data rdat0032» (count «data rdat0032») returning 2.
• way to extract element(s); e.g. item 4 of «data rdat32303037» returning «data rdat37»
• way to concatenate two data; e.g. «data rdat32» & «data rdat30» returing «data rdat3230»
• way to perform valid coercion to other class, e.g. «data rdat0032» as Unicode text returning "2" (= U+0032).
• way to perform coercion from other class, e.g. ("2" as Unicode text) as data returning «data rdat0032»
Just my daydream. ; )
Message was edited by: Hiroto (corrected typo)

Similar Messages

  • How to get raw data into BI system from maxdb database

    Hi Friends
    I have a scenario where i need to get the raw data from a maxdb database into my BI system.The data is stored in the sapdata folder of maxDB.
    Can you please throw somelight on it?
    Thanks in advance.....................................................

    Hi Rajat
    Please check SAP note 520647.
    It explain the steps for DB Multiconnect using DBCON
    Hope this helps
    Ravinder

  • Get the Data from a DataSource

    Hi,
    I start with JMF. I use a processor to get DataSource from an audio file. Until there, all runs very well.
    But after that, I would like to get the raw data of my DataSource to aplly a filter on these data and after that, to create a new DataSource with filters data and play these data with my processor.
    I searched in the API documentation of JMF but I did'nt find the solution to get the raw data of my DataSource !
    Someone could help me ? and give me an idea of how to proceed ?
    Thanks for yours answers.
    Sylvain.

    Hi,
    It seems no one has replied to this post. I have a sample code that can help getting raw data from a DataSource. Here it is:
              PushBufferDataSource source = null;
              source = (PushBufferDataSource)processor.getDataOutput();
              /* Now we can retrieve the PushBufferStreams that will enable us to
              * access the data from the camera
              PushBufferStream[] streams = source.getStreams();
              camStream = null;
              for (int i = 0; i < streams.length; i++) {
              /* Use the first Stream that is RGBFormat (there should be only one */
              if (streams.getFormat() instanceof RGBFormat) {
                   camStream = streams[i];
                   RGBFormat rgbf = (RGBFormat)streams[i].getFormat();
                   converter = new BufferToImage(rgbf);
                   break;
    Please let me know whether it helped solving your problem..
    Suresh

  • Use a String to get data from a variable?

    Hi, I've got a major problem, I need to get data (int []) from a variable, using a String with the name of the variable..
    Does anyone know if this is possible?
    public class Commands {
        private static final int[] deploy_1 = {64,37,73,1};
        private static final int[] deploy_2 = {4,167,6,51};
        /** Creates a new instance of Commands */
        public Commands() {
        public int[] get(String name)
    // what code here?
    }I should be getting the data with
    int[] command = Commands.get("deploy_1");
    or something like that...
    Please help me!
    FYI, a hashtable is not a option!
    Many thanks, Vikko

    java.lang.NoSuchFieldException: deploy_1
    at java.lang.Class.getField(Class.java:1507)
    at dumb_commandstest.Commands.get(Commands.java:30)
    at dumb_commandstest.Main.getData(Main.java:36)
    at dumb_commandstest.Main.<init>(Main.java:21)
    at dumb_commandstest.Main.main(Main.java:28)
    Any ideas why I get a NoSuchFieldException?
    deploy_1 does exist.

  • How to get data type of variable in program..

    Hi ABAP Guru.
    I need to know how to get data type of variable or any structure field.. because I got short dump when use command REPLACE ALL OCCURANCE ... with variable/structure field that has data type I or P, I think it should be used with data type CHAR only, So I need to check the data type first.
    Please give me your advice
    Thank you all.
    Nattapash C.

    data : v_value type i,
             v_char(10) type c.
    v_value = 10.
    move v_value to v_char.
    REPLACE ALL OCCURRENCES of '#' from v_char....
    Best regards,
    Prashant

  • When connected to wifi, I get an error message saying "cannot decode raw data"

    While I am at school, I can connect to the wifi, however I can only access google, and the apple website. When I try and google something to work on a project, I get a messgae that says "Cannot Decode Raw Data" it is getting rather annoying, and I was wondering if anyone else has had this problem. The only time I have gotten this message is while at my school, it has worked before but only started this recently.
    Is there a quick fix for this? Is it something caused by the wifi at school?
    Thanks in advance.

    While I am at school, I can connect to the wifi, however I can only access google, and the apple website. When I try and google something to work on a project, I get a messgae that says "Cannot Decode Raw Data" it is getting rather annoying, and I was wondering if anyone else has had this problem. The only time I have gotten this message is while at my school, it has worked before but only started this recently.
    Is there a quick fix for this? Is it something caused by the wifi at school?
    Thanks in advance.

  • How to get the data type of a variable

    Hi
    I'm new to java and I'd like to put some variables with different data type into the HashMap. But when I'm going to get the value
    of the variable I want to know its data type (int,String,long,float etc.) before I do some processing.
    here's my sample code:
    //start...
    Map m = new HashMap();
    String s1 = "String1";
    String s2 = "String2";
    int i1 = 5;
    int i2 = 10;
    m.put(1,s1);
    m.put(2,i1);
    m.put(3,12);
    m.put(4,s2);
    //end...
    when I'm going to retrieve the variable, I'd like to assign it to another variable with the same data type. but the problem is, before
    I assign it I must know its data type so that I could not have an error.
    thanks in advance

    I don't think you will be able to put primitives (ints, floats, etc) in, without wrapping 'em first (java.lang.Integer, java.lang.Float...).
    You can get the type with
    Object biggles;
    // Get biggles
    if( biggles instanceof String )
       System.out.println( "Biggles is a string, yeah biggles" );or with refection
    Class bigglesClass = biggles.getClass();
    System.out.println( "Biggles is of type: " + bigglesClass.getName() );

  • To Split a variable to get the date.

    Hi all,
        I have a variable 'file1'.This variable stores the names of the pdf files located in SAP directory.
    The name of the file is like:'PDFST0000098357US81042008',
    which containg order no ,sales org, month and date of that file creation.
    Now i have a requirement to extract that  month and year from this variable.
    Also some filenames have different format like'PDFIPF......' instead of 'PDFST.....'.
    so kindly suggest how to extract month and year from this variable.
    Thank You.

    Hi,
    You can use fm STRING_REVERSE to reverse the name of the filename. Then go ahead and extact eight letters of the reversed string and once again reverse that, so at this you will get the date part in DDMMYYYY.
    Again you can manipulate this date string to get back the original date.
    1.  use string_reverse input filename, output reversed string.
    2.  reversedstring+0(8) will extract date part ( reverse ).
    3.  Again reverse this string.
    But seeing at the example, this would be tougher if the date in the filename is not in DDMMYYYY, meaning that if the date is 1st april 2008 then if the date format is DMYYYY(142008), then the logic would go for a toss.
    Thanks and regards,
    S. Chandramouli.

  • Getting ¿¿¿¿¿¿ while converting Raw data to Varchar2.

    Hi All,
    We are fetching data from as400 database to Oracel using a dblink.
    It gives us Raw data. But when we tried converting Raw data to Varchar2 at Oracle side Its returning ¿¿¿¿¿¿ instead of actual data.
    We are using Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    We used following SQL:
    select UTL_RAW.CAST_TO_varCHAR2(ordno) from amflib6.pomast@as400_pub
    OUTPUT :     ¿¿¿¿¿¿
    However we also tried to run it withoout dblink as following but not getting required data.
    select UTL_RAW.CAST_TO_varCHAR2('4DAC') from dual
    OUTPUT  :     M¿
    Is it something to do with installed fonts or soem thing else.. Please help us out.
    Any help would be appreciated.
    Thanks and Regards
    Indu

    Hi,
    Probably a multibyte data vs. characterset issue.
    What is the outcome of:
    select * from nls_database_parameters where parameter like '%CHAR%';?
    Perhaps you'll find some similar problem here:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5783936214008#12758388562377
    And check the [Globalisation Support Guide | http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/toc.htm]

  • Getting the message cannot decode raw data when accessing a Joomla website.

    Getting the message cannot decode raw data when accessing a Joomla website.I can acess the homepage but cannot get on to look at any of the products. Have tried using other peoples iphones to view the same website and the same error appears works fine in a web browse or android.

    Was the other iPhone the same model, running the exact same iOS, accessing the website through the same App?
    Try using Google Chrome.  Do you still have the issue?
    Edit: Just realized you said that the other iPhone had the same issue. 
    Here's how troubleshooting works.
    Look for a single common element. 
    If two iPhones cannot connect to a particular wi-fi router (but CAN connect to other wi-fi routers, like a public one at McDonalds), does that suggest a problem with BOTH iPhones, or a problem with that wi-fi router?
    Now:
    If two iPhones cannot connect to a particular website (but CAN connect to other websites, like a public one like Google or Yahoo), does that suggest a problem with BOTH iPhones, or a problem with that wi-fi router?

  • Is it possible to get the raw data?

    Hi,
    I am trying to do a program that sends to a server the data captured by a webcam, but I need to send it with java sockets.
    How can I get the raw data from a DataSource to send it myself?
    Thanks

    Hi
    It is absolutely possible to get the data - anyone you have in your org with basic SQL skills can move the data off to a standalone SQL server. This could be done most simply by backing up and restoring the DB using SQL Enterprise Manager.
    Moving the CAR/ART reporting tool would be more difficult... if you do actually use that for reporting (most people find it doesn't do what they need and don't use it for anything but basic troubleshooting, and get a third party package) then the best option may be to keep your publisher (possibly assigning it a new IP) and leave it running for as long as you need reporting.
    You would then need a new server to run your upgraded V6 CCM; you may find you need this anyway.
    Regards
    Aaron
    Please rate helpful posts...

  • How to get max date in variable using  dynamic query

    Hi,
    the following code gets all dates from sourcetable i want only max date , so i thought max function can be added and it will work
    but still i have to create a table for one value(scalar) can get it in any other effeciant way.
    declare
    TYPE date_string IS TABLE OF VARCHAR(1000);
    date_obj date_string;
    BEGIN
    EXECUTE IMMEDIATE 'SELECT to_char('''||day1||'-'||month1||'-'||year1||''') FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;
    FOR indx IN date_obj.FIRST..date_obj.LAST loop
    dbms_output.put_line(
    date_obj(indx));
    END loop;
    DBMS_OUTPUT.PUT_LINE('Sample output');
    END;
    yours sincerely

    944768 wrote:
    the following code gets all dates from sourcetableNo it doesn't. What is the datatype of day1, month1 and year1? They cannot be DATE datatypes otherwise your TO_CHAR would fail with all that concatenation going on. And your TO_CHAR is returning a VARCHAR2 datatype... so you cannot say that it is getting all dates... because there are no DATE datatypes returned. It's getting a lot of strings, but certainly not DATE's.
    i want only max date , so i thought max function can be added and it will work You can use the MAX function on a DATE datatype, but not on strings (at least not in the way you intend it to work).
    Converting it to a DATE before doing the MAX will allow you to get the maximum date (assuming the date format is correct)
    EXECUTE IMMEDIATE 'SELECT max(to_date(to_char('''||day1||'-'||month1||'-'||year1||'''),''DD-MM-YYYY'')) FROM  '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;Then you will find have the other issues...
    a) you are then going to be fetching your DATEs in to a collection of VARCHAR strings. (Not even VARCHAR2, very poor). This should be DATE datatype
    b) you are bulk collecting into a collection, when you are using MAX which will return a single value in your example
    And you really should address the design issues:
    c) why are day, month and year, not being stored in the database as a single DATE datatype in the first place
    d) why does your code not know the name of the table it's querying requiring the use of very poor dynamic SQL techniques.
    e) why are you loading data in a collection in expensive PGA memory... what can't you do in SQL that requires you to collect the data into memory first?

  • How to get the raw data from particular document's schedule ?

    Hello,
    I am now able to get the data from a document usign RESTful Web Services SDK and what I need is to
    get the data not from the current version of the document but from the schedule that were executed some time ago
    with the older data than the current data.
    Any hints ?

    Hey Jacek,
    Please, look at the /schedules into Raylight API.
    Regards,
    Anthony

  • How to convert raw data to original data

    Hi,
    I'm using db10g.
    I have stored the blob of a word doc into the database using dbms_lob package.
    Now during retrieval, i'm getting the raw data using the code
    dbms_lob.read( l_lob, l_amt, l_off, l_raw );
    l_raw is of type raw.
    I want to convert the raw data to original string.
    Please Help
    Thanks

    Divya wrote:
    I think I have clearly told that i have blobs of different files in my database.
    The files are of different type, I have blob of pdf,doc,html,xml,gif etc...
    and in the procedure i have posted(get_file_contents), it is a database procedure and i'm calling it from the forms.
    So i'm passing the file_name and file_id to the procedure(file_name and file_id are the columns in the table.
    Table 'Blob_Details' have 4 columns file_id,file_name,file_type,theblob) and a varchar variable final_data.
    final_data varchar(32000)
    and in the procedure i'm taking the blob from database, reading it using dbms_lob.read in a loop and casting it to varchar and storing the contents in the variable final_data.
    So coming out of the loop, the variable final_data will have the contents of the given file.BLOB data (such as word or excel documents and PDFs containing images etc.) are Binary data, not Character data. Converting that raw binary data to VARCHAR will cause issues.
    If you have loaded a binary file and stored it on the database as a BLOB (Binary data) and you now want to create the original file from that BLOB, you will simply need to read the BLOB data from the database into BLOB variable and process it in chunks, using UTL_FILE to write out, in Binary mode, that data to a file with the appropriate filename. The actual process is quite simple...
    As sys user:
    CREATE OR REPLACE DIRECTORY MY_FILES AS 'c:\myfiles';
    GRANT READ,WRITE ON DIRECTORY MY_FILES TO myuser;As myuser:
    DECLARE
       -- Data Variables
       v_blob             BLOB;
       v_data_length      NUMBER;
       -- Loop Control Variables
       v_offset           NUMBER := 1;
       v_chunk   CONSTANT NUMBER := 32767; -- maximum chunk size
       -- UTL_FILE variables
       fh                 UTL_FILE.file_type;
    BEGIN
       v_blob := ... populate the blob variable here
       v_data_length := DBMS_LOB.getlength (v_blob);
       -- Open the file
       fh := UTL_FILE.fopen ('MY_FILES', 'myfile.dat', 'wb', v_chunk);
       LOOP
          -- Exit when our file offset is bigger than our file
          EXIT WHEN v_offset > v_data_length;
          -- Write the output chunk by chunk
          UTL_FILE.put_raw (fh, DBMS_LOB.SUBSTR (v_blob, v_chunk, v_offset), TRUE);
          -- Increment the offset by the amount written
          v_offset := v_offset + v_chunk;
       END LOOP;
       -- Close the file
       UTL_FILE.fclose (fh);
    END;

  • Basic BI questions of calculating formulas from raw data on 15-min and 1-hr intervals?

    I'm new to BI and I'm working on a project that (I believe) can help me gain experience with this technology. The formula I'm working on now is really the simplest one.
    We have 15-minute data that has tons of counters. I'm currently storing in a table called [Counter15MinCityDataRaw], like so:
    Id City Date Hour Minute KpiValue Counters InsertDate
    108823 Miami 20140930 9 0 100.00 Auto 2014-09-30 12:17:07.580
    108824 NYC 20140930 9 0 0.50 Added 2014-09-30 12:17:07.580
    108825 Vegas 20140930 9 0 12.00 Att 2014-09-30 12:17:07.580
    108826 Miami 20140930 9 0 40.00 Man 2014-09-30 12:17:07.580
    108823 Miami 20140930 9 15 100.00 Auto 2014-09-30 12:17:07.580
    108824 NYC 20140930 9 15 0.50 Added 2014-09-30 12:17:07.580
    108825 Vegas 20140930 9 15 12.00 Att 2014-09-30 12:17:07.580
    108826 Miami 20140930 9 15 40.00 Man 2014-09-30 12:17:07.580
    This is the raw data. The first formula I'll be working on is [TotalPopulation], that looks like this: [TotalPopulation] = (Q + (Auto+Man))
    / 400. Q equals the Number of quarters being processed (ie. Q =
    1 for 15-minute interval, Q = 4 for 1-hr interval)
    So my intial requirements is to create a report that displays the [TotalPopulation] for each City in 15-min and 1-hr intervals.
    So I already created both [DimDate] and [DimCity] tables, although I don't think they're going to help when I calculate the 15-minute intervals and the 1-hr intervals. Also, can I use the raw data as
    is for the fact table, or would I need to group the data by city and counter (in
    this case Auto and Man) into a new fact
    table?
    So my question is: do I need a dimension table for the 15-minute intervals and 1-hour intervals? How would my Fact table look like? Would I also need a dim table for the Q variable?

    If i understand it correct you can create one more dimension as DimQuarter, which will have members 15 Min interval, 30 Min interval, 45 min interval, 1 hour interval. 
    The next step is to add a column on top of Raw Data for Quarter surrogate key along with existing dimensions.
    Hope this will get you started.
    Be the change you want.

Maybe you are looking for

  • Delete overlapping requests of same DTP from cube

    Dear All, i want to delete over lapping requests of same DTP in cube, but here while i am searching for the DTP in process variant, the system is not showing the DTP(it is active). can you people have any suggestions. Br, Vamshi.

  • Can I see which of my skype number has been dialle...

    Hi, I have 4 skype numbers but would like to see when i receive a call which number was dialled.  Is this possible. I would also like to have different answer messages set up for each number, again is this possible. Many thanks

  • Any FM to change PR's customer's tab data

    is there any FM/BAPI to change PR's customer tab data .. i have tried to use ME_UPDATE_REQUISITION, it didn't change PR data BAPI_REQUISITION_CHANGE doesn't have customer tab fields

  • ALV + on_lead_select event

    Hi All, I have used the std ALV component in my component. the scenario is working fine...below the ALV(A) i have another table(B) ... when a particular row in the ALV is selected the corresponding records in table(B) should be shown.... I have writt

  • How do i call Indesign CC (64 bit) ?

    Currently running 32 bit in a 64 bit system. using InDesign.Application.CC Do i need to register in order to change to 64 bit instance?