Returning unicode string through function argument.

Hi all,
I have following function written in a C++ dll. I need to be able to call it from Java using JNI. This function expects to receive a buffer pointed by wchar_t * of "int len" length. It will copy write some text in to this buffer and i need to be able to get this updated Unicode string in Java code. please let me know how to write Java code to call this function.
int getWString(wchar *ch, int len)
     wcsncpy( ch, L"Hello unicode world", len);
     return 1; // no error
}Best Regards
Noman Khan

You can't.
You have to write some C "wrapper" code that meets the java interface, and have it call the C function and handle the return.
Java doesn't do output parameters, especially wchar_t* s.

Similar Messages

  • Lookup return value string as Function

    The only way which I know of is to define mapping parameters with the IsExprVar flag checked; then you can provide each individual business rule for one session run, source all records which have to be processed by this particular business rule and process them, and repeat the whole process until all business rules have been used. Regards,Nico

    Hi,I have a requirement to load close to 100 files. Each files has different business rules. Business Rules are saved in tableI'm planning to create one stage mapping and use the lookup to read the business rule apply them, but INFA is treating the look up return values as string  and not as function.. Is there a way to make INFA treat them as function Eg: Business Rule : col1|| col2 INFA load them as "col1||col2", instead of subsituting col1 value  Thanks

  • How to get unicode string through NCO 3.x ?

    Environment: ECC 6.0 Unicode
    Console.Wirte ( table.GetString("MAKTX") );
    This result will be more incorrect encoding ("question mark" ).
    how to fixed?

    Maybe you can help me now?
    I have a iPhone 1/8 inch microphone adapter - 3.5mm 4 conductor TRRS Male to 3.5mm Microphone Input Jack from here. that allows me to plug my lapel mic directly into my iphone and record, it is great.
    I was hoping I could also use it on my MBPRetina to accomplish the same purpose. Do you know if that is possible? I tried and tested it recording a video in iMovie, and didn't notice any change.
    I went to the Sound Input Preferences, and do not notice the mic input changing when I plug it in or remove it. In other words, it always says "internal mic."
    My lapel mic is battery operated, with a fresh battery, and it was turned on.
    What am I doing incorrectly? Any help would be wonderfully appreciated!

  • How to return a string or a comment through ODI os command

    Hi,
    Is there any way so to return any string through odi os command.
    I want to return that error back through odi operator.
    Thanks

    I dont think so. You can modify your script file so that in case of any error it will write a flag (your string values) to another temp file (temp.txt)
    Then read the file via jython. If flag =1 (or your req values) then there is some error in your script. Now Raise error in odi which print the string in operator.
    Thanks.
    Bhabani
    http://dwteam.in

  • Converting unicode string to ASCII

    I'm using a 3rd party API and I'm receiving the following unicoded string through an API:
    Original string: "Bill%u002b%u002526%u002bHarry%u002bUsers"
    The ASCII value is supposed to be:
    Desired string: "Bill & Harry Users"
    How do I convert the original string to the desired string?
    Any sample code would be greatly appreciated!
    Thanks

    could look someething like:
    public class Decoder
      public static String decode(String string)
        StringBuffer result = null;   
        int pos = 0;
        int idx;      
        if( string != null )
          result = new StringBuffer();
          while( pos < string.length() )
            idx = string.indexOf("%u", pos);
            if( idx >= 0
                && idx + "u0000".length() < string.length() )
              result.append( string.substring(pos, idx));
              pos = idx;
              result.append( (char)Integer.parseInt(
                      string.substring( idx + "%u".length(), idx + "%u0000".length() )));          
              pos += "%u0000".length();
            else
              result.append( string.substring(pos));
              pos = idx;
        return result != null ? result.toString() : null;
    }

  • Unicode strings

    Hi!
    Does anybody have experience with unicode strings through OCCI interface processing?
    How can i write and read unicode string to table field? This question rises because of functions setString and getString which works with std::strings objects.
    Thanks.

    OCCI supports Unicode with the 10g release. Please check the documentation at :-
    http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10778/globalization.htm#i1000999
    and check the demos : occiuni1, occiuni2
    Thanks,
    Shankar

  • Can I call a function from a dll in LabVIEW that returns:double*string and int.?

    I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?

    pcbv wrote:
    > Hello all,<br><br>The header of the function is:
    >
    > "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
    >
    > where WRAPI_NDIS_DEVICE have this form:
    >
    > typedef struct WRAPI_NDIS_DEVICE<br>{<br>
    > WCHAR *pDeviceName;<br>
    > WCHAR *pDeviceDescription;<br><br>}
    > WRAPI_NDIS_DEVICE;<br><br>
    >
    > The function is from WRAPI.dll, used for communication with wireless card.
    > For my application I need to call in LabVIEW this function.
    Two difficulties I can see with this.
    First the application seems to allocate the array of references
    internally and return a pointer to that array. In that case there must
    be another function which then deallocates that array again.
    Then you would need to setup the function call to have a pointer to an
    int32 number for the deviceList parameter and another pointer to int32
    one for the plItems parameter.
    Then create another function in your DLL similar to this:
    HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
    CHAR lpszDeviceName, LONG lenDeviceName,
    CHAR lpszDeviceDesc, LONG lenDeviceDesc)
    if (!lpDeviceList)
    return ERROR_INV_PARAMETER;
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceName, -1,
    lpszDeviceName, lenDeviceName,
    NULL, NULL);
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceDescription, -1,
    lpszDeviceDesc, lenDeviceDesc,
    NULL, NULL);
    return NO_ERROR;
    Pass the int32 you got from the first parameter of the previous call as
    a simple int32 passed by value to this function (and make sure you don't
    call this function with a higher index than (plItems - 1) returned from
    the first function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Calling c function that return a string

    Hallo,
    I found an example for calling void c function(http://zone.ni.com/devzone/cda/epd/p/id/1513). I could adapt the example and make the function return an integer. the code of the adapted function would look like this:
     int __declspec(dllexport) multiply(int number) {return number*3; }
    But I have problems when I want to return a string. Does someone knows how I should do. I tried:
     char* __declspec(dllexport) say(int number) {return "hallo"; }  
    but won't compile.

    yes the question was  more a c question then a labview question. I found the solution anyway, the correct code in order to get string is:
    _declspec(dllexport) char* testchar2();_declspec(dllexport) char* testchar2() {      return "hallo"; }

  • Maximum length of query string for functions return a SELECT

    Hi all,
    I have a report that gets it's SELECT statement from a function, instead of being coded into the region. All was well but I suspect now I'm blowing some kind of limit as I'm getting an error :
         ORA-06502: PL/SQL: numeric or value error
         Error      ERR-1101 Unable to process function body returning query.
    However if I run the procedure out of ApEx and grab the SELECT statement then it works fine. The length of the query is 8636 bytes (yup, it's a beauty!).
    Does anyone know if there is a hard limit to the size of the string that can be returned?
    I'm using ApEx 3.1.
    Thanks,
    Steve H

    I do have a similar painfull scenario - Although my query length is very less i.e 618 bytes only.
    I have defined a stored function, which returns an SQL query string, this return SQL string executes fantastic but when I tried to to call this function from a APEX report it gives error. the details are as follows. Please help.......
    The function code:
    CREATE OR REPLACE function PROD."TEST_C_QRY"
    return VARCHAR2
    is
    msql VARCHAR2(32767);
    Begin
    msql:='Select null,statusname,AgeInd, ';
    For m_stat in (select statusname from a02_status)
    loop
    msql:= msql || q'[decode(statusname,']';
    msql:= msql || m_stat.statusname;
    msql:= msql || q'[',count(id),0) ]';
    msql:= msql || m_stat.statusname|| ',';
    end loop;
    msql:=rtrim(msql,',');
    msql:= msql||' from ';
    msql:= msql||'( ';
    msql:= msql||'select a.id, round(sysdate-a.registeredon) TimeSpan,';
    msql:= msql||'case ';
    msql:= msql||q'[when round(sysdate-a.registeredon)<=7 then 'Week' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' ]';
    msql:= msql||q'[else 'More...'  end ageind,]';
    msql:= msql||'a.status_id,b.statusname ';
    msql:= msql||'from a02_task a,a02_status b ';
    msql:= msql||'where b.id=a.status_id) ';
    msql:= msql||'group by statusname,AgeInd;';
    return msql;
    end TEST_C_QRY;
    The Output SQL comes from this is
    SQL> Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,
    'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round
    (sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then
    'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    The result that comes when I execute the above resultant SQL is as follows.
    N STATUSNAME AGEIND SCHEDULED EXECUTING COMPLETED
    Completed More... 0 0 4
    Completed Week 0 0 1
    Scheduled Week 1 0 0
    Completed Month 0 0 3
    Executing More... 0 1 0
    Executing Month 0 6 0
    Scheduled More... 1 0 0
    7 rows selected.
    But the surprising error that comes from Oracle XE when I use the following code for stacked bar chart
    Code:
    begin
    return TEST_D_QRY;
    end;
    Error thrown by XE report builder is as follows:
    1 error has occurred
    Failed to parse SQL query!
    Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Regards,
    Soumen

  • Unicode string now returned from Stored Proc., used to be ANSI.

    Using ADO to connect VB6 to Oracle 8 stored procedures used to return strings in ANSI format. At some point in the last year or so, strings suddenly began to be returned as Unicode, unreadable by VB.
    Same problem now occurs using VB.Net and ODP.Net; I need to support both VB6 and .NET versions.
    Why are strings being encoded differently than before? Has anybody else seen this problem? What can be done?
    The NLS_LANG registry entries on the server and client machines match each other. Some of our installed base of customers reported this change, too.
    Below are some demonstration code examples.
    Stored procedure looks like this:
    CREATE OR REPLACE PROCEDURE MyStoredProc
    (sMyMsg IN OUT VARCHAR2) AS
    BEGIN
         sMyMsg := 'My test string';
    RETURN;
    END;
    On the VB6 side, my code looks like this:
    Dim vParam As Variant
    Dim cmdExecute As ADODB.Command
    Dim pParam As ADODB.Parameter
    Set cmdExecute = New ADODB.Command
    cmdExecute.CommandType = adCmdStoredProc
    cmdExecute.CommandText = "MyStoredProc"
    Set pParam = cmdExecute.CreateParameter("PARAM1", vbString, adParamInputOutput, 0, vParam)
    cmdExecute.Parameters.Append pParam
    cmdExecute.ActiveConnection = ADOConnect
    cmdExecute.Execute
    vParams = cmdExecute.Parameters(0)
    Result of VB code is that vParams now contains a Unicode string.
    Any suggestions as to what's happening, where the problem might be, what to do about it, or where else to post this question (I'm not sure which Forum is the best place to look for answers) would be appreciated.
    Is "force SQL_WCHAR" relevant to this problem? If so, what does that mean and how/where do I apply it?

    The Force WCHAR option forces the ODBC driver to
    report columns and return data as Unicode. If that
    is checked, you probably want to uncheck it.But how do I do that? I can't find any documentation for a SQL_WCHAR option. Where do I go to read/change the current setting of this switch?
    What character set is your client & database?NLS_LANG, for both machines, is "AMERICAN_AMERICA.WE8ISO8859P1". BTW, the client is 9.2, but the database is version 8.1.7. I'm fairly certain that the problem also existed when the client was also running ver. 8.

  • Min aggregate function returns empty string

    I have a data set with a column named "month" which contains string values like 1,2,3... etc. including empty string. When I apply an aggregate Min function like below, it returns empty string instead of 1. or the lowest month number.
    Min(Fields!month.Value, "Financial")
    Please if any one can assist me on this.
    Regards

    Hi ABDUL-HAFEEZ,
    As you know the Min() function returns the minimum value of all non-null numeric values specified by the expression, because you have null string in the field and also the field type is string but not numeric, so this function will not works fine.
    I have tested on my local environment that we can get the first convert the string to numeric type value and then get the min value of the month field by using the query not the expression.
    Details information below for your reference:
    Create an new dataset(DataSet2) to get the minimum value from the Month and the query like below:
    SELECT     Min(CAST(Month AS INT)) as NewMonth
    FROM         TableName
    Using below expression in the main dataset will display the minimum value of the month:
    =Sum(Fields!NewMonth.Value, "DataSet2")
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu
    If you have any feedback on our support, please click
    here.
    Vicky Liu
    TechNet Community Support

  • The value returned from the load function is not of type numeric  errors after migration to Coldfusion 11

    I am currently testing our website with CF11. It is currently working with CF8 however after migrating it to a new server running CF11 I have encountered the following error.
    The value returned from the load function is not of type numeric.
    The error occurred in
    D:/Applications/CFusion/CustomTags/nec/com/objects/address.cfc: line 263
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/contact.cfc: line 331
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 510
    Called from D:/Applications/CFusion/CustomTags/nec/com/objects/user.cfc: line 1675
    Called from D:/website/NECPhase2/action.validate.cfm: line 54
    261 : <cfif isNumeric(get.idCountry)>
    262 : <cfset rc = this.objCountry.setID(get.idCountry)>
    263 : <cfset rc = this.objCountry.load()>
    264 : </cfif>
    265 : <cfset this.sPostcode = get.sPostcode>
    Have there been any changes between CF8 and CF11 that could  cause this error?
    Does anyone have ideas?

    This is the code in file object file country.cfc (nec.com.objects.country):
    <cfcomponent displayname="Country object" hint="This is a Country object, it allows you to access and set values in the Country.">
    <!---
    // Construct this object
    --->
    <cfset this.objFunctions = CreateObject( 'component', 'nec.com.system.functions' )>
    <cfscript>
      this.idCountryID = 0;
      this.sCountryName = "";
      this.sISOCode = "";
      this.sDHLCode = "";
      this.iErrorID = "";
    </cfscript>
    <!---
    // The following functions are the setters and getters. offering us a better way to get
    // at the contents of the object
    --->
    <!---
    // Getters
    --->
    <cffunction name="getID" displayname="Get ID" returntype="numeric" output="false" hint="This returns the ID of the current item.">
      <cfreturn this.idCountryID>
    </cffunction>
    <cffunction name="getsCountryName" displayname="Get sCountryName" returntype="string" output="false" hint="This gets the sCountryName value of this item.">
      <cfreturn this.sCountryName>
    </cffunction>
    <cffunction name="getsISOCode" displayname="Get sISOCode" returntype="string" output="false" hint="This gets the sISOCode value of this item.">
      <cfreturn this.sISOCode>
    </cffunction>
    <cffunction name="getsDHLCode" displayname="Get sDHLCode" returntype="string" output="false" hint="This gets the sDHLCode value of this item.">
      <cfreturn this.sDHLCode>
    </cffunction>
    <cffunction name="iError" displayname="Get iError" returntype="numeric" output="false" hint="This returns the iError of the current item.">
      <cfreturn this.iError>
    </cffunction>
    <!---
    // Setters
    --->
    <cffunction name="setID" displayname="Set ID" returntype="boolean" output="false" hint="This sets the ID value of this item.">
      <cfargument name="idCountryID" required="true" type="numeric" displayname="ID" hint="The ID to use.">
      <cfset this.idCountryID = arguments.idCountryID>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsCountryName" displayname="Set sCountryName" returntype="boolean" output="false" hint="This sets the sCountryName value of this item.">
      <cfargument name="sCountryName" required="true" type="string" displayname="sCountryName" hint="The sCountryName to use.">
      <cfset this.sCountryName = arguments.sCountryName>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsISOCode" displayname="Set sISOCode" returntype="boolean" output="false" hint="This sets the sISOCode value of this item.">
      <cfargument name="sISOCode" required="true" type="string" displayname="sISOCode" hint="The sISOCode to use.">
      <cfset this.sISOCode = arguments.sISOCode>
      <cfreturn true>
    </cffunction>
    <cffunction name="setsDHLCode" displayname="Set sDHLCode" returntype="boolean" output="false" hint="This sets the sDHLCode value of this item.">
      <cfargument name="sDHLCode" required="true" type="string" displayname="sDHLCode" hint="The sDHLCode to use.">
      <cfset this.sDHLCode = arguments.sDHLCode>
      <cfreturn true>
    </cffunction>
    <!---
    // Clear, to empty out the contents of this object
    --->
    <cffunction name="clear" displayname="Clear items Details" returntype="boolean" output="false" hint="Clears out all of the items details.">
      <cfscript>
       this.sCountryName = "";
       this.sISOCode = "";
       this.sDHLCode = "";
       this.iErrorID = "";
      </cfscript>
      <cfreturn true>
    </cffunction>
    <!---
    // The following functions deal with the load, save and deleting of objects
    --->
    <!---
    // Load
    --->
    <cffunction name="load" displayname="Load items details" returntype="numeric" output="false" hint="This loads in all the information about an item.">
      <cfset rc = this.clear()>
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Check to see if it exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("load: checkID: '#this.idCountryID#' #cfcatch.detail#");
        </cfscript>
        <cfset this.iErrorID = iErrorID>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif not checkID.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         if(isDefined("session.afr")){
          whichOne = "#session.afr.getsAFRNumber()#";
         } else {
          whichOne = "";
         iErrorID = objError.addError("A Country with that id doesn't exists.[#this.idCountryID#][#whichOne#]");
        </cfscript>
       <cfset this.iErrorID = iErrorID>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // If we got past all then then load in the details
      --->
      <cftry>
       <cfquery name="get" datasource="#sDatasource#">
        SELECT idCountryID, RTRIM(sCountryName) as sCountryName, RTRIM(sISOCode) as sISOCode, RTRIM(sDHLCode) as sDHLCode
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("load: get: #cfcatch.detail#");
        </cfscript>
        <cfset this.iErrorID = iErrorID>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfset this.idCountryID = get.idCountryID>
      <cfset this.sCountryName = get.sCountryName>
      <cfset this.sISOCode = get.sISOCode>
      <cfset this.sDHLCode = get.sDHLCode>
      <cfset this.iErrorID = "">
      <cfreturn true>
    </cffunction>
    <!---
    // Save
    --->
    <cffunction name="save" displayname="Save items Details" returntype="numeric" output="false" hint="Saves (to some source) the current details for the ID of the item.">
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Now check to see if ithat ID exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("save: checkID: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <!---
      // If it doesn't exist, then add the record, otherwise update the record
      --->
      <cfif not checkID.recordCount>
       <cfreturn this.add()>
      <cfelse>
       <cfreturn this.update()>
      </cfif>
    </cffunction>
    <!---
    // Add
    --->
    <cffunction name="add" displayname="Add Country" returntype="numeric" output="false" hint="This adds a Country.">
      <!---
      // Check to see if that a different item isn't already using the same unique details
      --->
      <cftry>
       <cfquery name="checkUnique" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
        OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#'
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("add: checkUnique: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkUnique.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("A Country with that name or ISO code already exists. idCountryID=#checkUnique.idCountryID#");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <cftry>
       <cfquery name="add" datasource="#sDatasource#">
        SET nocount on
        INSERT INTO tblCountry(sCountryName, sISOCode, sDHLCode)
        VALUES('#this.objFunctions.scrubText(this.sCountryName)#','#this.objFunctions.scrubText(t his.sISOCode)#','#this.objFunctions.scrubText(this.sDHLCode)#')
        SELECT @@identity as autoID
        SET nocount off  
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("add: add: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn add.autoID>
    </cffunction>
    <!---
    // Update
    --->
    <cffunction name="update" displayname="Update Country" returntype="numeric" output="false" hint="This updates a Country record.">
      <!---
      // Check to see if that a different item isn't already using the same unique details
      --->
      <cftry>
       <cfquery name="checkUnique" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE (sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#'
        OR sISOCOde = '#this.objFunctions.scrubText(this.sISOcode)#')
        AND idCountryID <> #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("update: checkUnique: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkUnique.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("Another Country with that name already exists. idCountryID=#checkUnique.idCountryID#");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Attempt to update the record to the datasource
      // if this fails for any reason then we submit an error message
      // to the error component and return the ID of the error
      --->
      <cftry>
       <cfquery name="update" datasource="#sDatasource#">
        UPDATE tblCountry
        SET sCountryName = '#this.objFunctions.scrubText(this.sCountryName)#',
        sISOCode = '#this.objFunctions.scrubText(this.sISOCode)#',
        sDHLCode = '#this.objFunctions.scrubText(this.sDHLCode)#'
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("update: update: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn this.idCountryID> 
    </cffunction>
    <!---
    // Delete
    --->
    <cffunction name="delete" displayname="Delete Country" returntype="numeric" output="false" hint="This deletes a Country record.">
      <!---
      // First of all we need to get the name of the data source we are going to be using
      --->
      <cfscript>
      objDS = CreateObject("component","nec.com.system.settings");
      sDatasource = objDS.getDatasource();
    </cfscript>
      <!---
      // Now check to see if ithat ID exists
      --->
      <cftry>
       <cfquery name="checkID" datasource="#sDatasource#">
        SELECT idCountryID
        FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: checkID: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif not checkID.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("A Country with that id doesn't exists, delete failed.");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Now check to see if there are any dependancies, if so we can't delete the item
      --->
      <cftry>
       <cfquery name="checkDependancies" datasource="#sDatasource#">
        SELECT idCountry
        FROM tblAddress
        WHERE idCountry = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: checkDependancies: idCountry: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfif checkDependancies.recordCount>
       <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("That Country is being used by an address, delete failed.");
        </cfscript>
       <cfreturn iErrorID>
      </cfif>
      <!---
      // Now attempt to remove the record.
      // if this fails for any reason then we submit an error message
      // to the error component and return the ID of the error
      --->
      <cftry>
       <cfquery name="delete" datasource="#sDatasource#">
        DELETE FROM tblCountry
        WHERE idCountryID = #this.idCountryID#
       </cfquery>
       <cfcatch>
        <cfscript>
         objError = CreateObject("component","nec.com.system.errors");
         iErrorID = objError.addError("delete: delete: #cfcatch.detail#");
        </cfscript>
        <cfreturn iErrorID>
       </cfcatch>
      </cftry>
      <cfreturn this.idCountryID>
    </cffunction>
    </cfcomponent>

  • Unicode(String) to actual Unicode !

    Hi, i have an unicode data which is retrieved from database, the unicode is in String format(\u4eba\u53c2), how to make it to be actual unicode "\u4eba\u53c2". i have a problem where the unicode from database doesn't give me the actual character but the unicode string itself. Please comment on it . Thanks.
    _calv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hi Calv,
    I'm pretty sure that the conversion from the ASCII string to Unicode is not available within the API. (If someone knows otherwise please jump in). However it should be fairly easy for you to program this conversion: for example, you could parse your string into the six character substrings that represent characters, strip off the \u, and then cast the sixteen bit integer into a Character.
    In case it's helpful, I am pasting a couple of methods I wrote to go in the opposite direction:
    returns a (ASCII) string that represents the specified character by a  unicode escape sequence
    static public String toUnicodeString(  char character) {
         short unicode = (short) character;
       char hexDigit[] = {
          '0', '1', '2', '3', '4', '5', '6', '7',
          '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
       char[] array = {hexDigit[( unicode >> 12) & 0x0f],hexDigit[( unicode >> 8) & 0x0f],
            hexDigit[( unicode >> 4) & 0x0f], hexDigit[ unicode & 0x0f] };
    String result = new String ("\\u" + new String (array));
       return result;
    returns a (ASCII)  string representing the java string argument:
    e.g. -> "\u1234\u5678"
    static public String toUnicodeString(  String  string) {
         String result = "\"";
         for (int   index =      0; index < string.length (); index++) {
              result = result +  toUnicodeString (string.charAt (index));
         result = result + "\"";
       return result;
    }   Regards,
    Joe

  • Bypassing function argument without changing default value

    Hi there
    I’m having some problems understanding how I can bypass function arguments without changing its default value. Here are some examples:
     function myFunction ( arg1:Boolean, arg2:String="default string", arg3:Number=3 ):Array
        return new Array (arg1, arg2, arg3);
    trace(myFunction(true, "new string", 5));
    // true,new string,5
    trace(myFunction(true, undefined, 5));
    // true,,5
    trace(myFunction(true, null, 5));
    // true,,5
    trace(myFunction(true));
    // true,default string,3
    trace(myFunction(true, null));
    // true,,3
    My question is: Shouldn't I be able to call a function bypass the second argument (that has a default value), change third argument and on result second argument maintains its default value?
    Example:
    trace(myFunction(true, null, 5));
    // not desired: true,,5
    // desired: true,default string,5
    I know that applying a defult value to the argument allows one to bypass it. But it will always be redefined or to null or to undefined. At the moment I only see one solution.
    function myFunction ( arg1:Boolean, arg2:String="default string", arg3:Number=3 ):Array
         if (!arg2)arg2 = "deafult string";
         return new Array (arg1, arg2, arg3);
    It just seems like too much code repeated
    Regards

    Hi dmennenoh,
    Yup, this was just an example to show that the use of a default value only helps you to bypass the need to simulate a MouseEvent Object for an onRollOver MouseEvent argument. Other than that you can never bypass it without changing its value. You must always apply a null or undefined value and work with that.
    Thanks anyway

  • Javascript function arguments

    When using JavasScript code in ASP on Sun's server I have encountered a strange problem:-
    Simple code to illustrate is
    <%
    function myClass()
    this.myMethod=myClass_myMethod;
    function myClass_myMethod(nNumber)
    return nNumber+1;
    var oObject=new myClass();
    var nValue=oObject.myMethod(2);
    %>
    I am finding that the interpreter is not able to access the argument nNumber by name in myMethod.
    Instead I have to use:
    function myClass_myMethod()
    var nNumber=myClass_myMethod.arguments[0];
    return nNumber+1;
    Any clues? Is it because the script is enclose in <% %> and not <SCRIPT runat=server> tags.

    Hello,
    Well this is more a pure javascript question than a HTML DB you should ask google.
    But it depends what you are doing with your function, if each value is a specific variable then no your function will have to look like f(nul,null,null,1,null,null,null,.........) .
    If you are using them to populate an js array you can iterate through your arguments or just provide the array are your argument.
    Personally and I do know a little about javascript I would avoid like the plague any js function that requires 50 arguments ( i usally start looking at a different solution at abut 10 arguments) especially if most of them could be null, there absolutely has to be a better way to do it.
    Like breaking up into smaller more specific functions or creating a js object that is more robust, agian you should ask google.
    Carl

Maybe you are looking for

  • Error by creating datasource in r/3

    Hi, i have a problem with creating a datasouce in r/3. Error message : Units field WAERS for field VERPR of DataSource ZBW_MBEW is hidden I use for extraction function module with extraction structure. There is in this structure field VERPR, which is

  • Jump Drive does not appear in finder

    Since installing Leopard none of my jump drives appear in the finder even after checking the appropriate boxes.

  • Setting different mouse speed for different mice

    I have an Apple Magic Mouse that I've used with my iMac for a while. I recently picked up a wireless Kensington laptop mouse for my 4 year-old twins to use because the Magic Mouse is difficult for my daughter to use. The Kensington mouse is good beca

  • Old HP DesignJet printer bypasses RIP after upgrade to Leopard

    My hp DesignJet 10ps has a print driver that has been bundled in the new OS, but when I print documents they bypasses the RIP software and my color quality is poor. The hp website says the driver is included in the OS & has nothing for me to download

  • Tinyurl plugin for Safari

    Is there a plugin that allows one to create a tinyurl for a page that is being viewed? There is one for Firefox, but I can't find one for Safari.