Simple function of CF, I can't write it!

Hey guys,.

I feel totally stupid, but I can't figure out how the code this very simple function. I use a piece of softare (salesforce) and he has two kinds of IDs, a tank of 15 and 18 tank. You can turn a tank fifteen in a tank 18 following this trueearnings.

---------------------------------------------------------------------------

1. divide the 15 tank in 3 blocks of 5 characters each.

2. for each give character this position with a value of 1 if in uppercase, 0 otherwise (lowercase or number).

3. combine the bits of each piece into a 5-bit integer where the bit the most right is the most significant bit. This will get a number between 0 and 31 for each piece.

4 build an array that contains the sequence of letters from A - Z and 0-5.

5. use the integer of each piece to choose a character from the table.

6. Add 3 characters that results, in the order of piece, at the end of the 15 char id.

---------------------------------------------------------------------------

That's all I have to do. But I keep running into the stupid problems.

Here is a link with more information and an example of chart

https://NA1.salesforce.com/_ui/training/help/pub/UserEdSolution?ID=501300000000MX1 & retURL = e https%3A%2F%2Fna2.salesforce.com%2F_ui%2Ftraining%2Fhelp%2FCombinedSearchPage%3Fstr%3Dreco % 2Bid % B 2, 18 & p = 1 & orgId = 00D 000000000062

Here's a post with a basic example

http://reuvenab.blogspot.com/2009/03/convert-15-character-Salesforce-IDs-to.html

Attached is my code, but for some reason any the table continues to try to treat the string to a number or something and sticks, some of the front of the number 1 instead of adding them as it should.

<cffunction name="ExpandSFID" hint="I take a 15 char salesforce ID and turn it ino the 18 char one">
     <cfargument name="SFID" type="string" required="yes">
     <cfoutput>
     #arguments.SFID#<br>
     <cfset InChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345">
     <cfset InUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ">
     <cfset ChunkTotal = arraynew(1)>
     <cfset ChunkTotal[1] = "">
     <cfset ChunkTotal[2] = "">
     <cfset ChunkTotal[3] = "">
     
     <cfloop from="1" to="3" index="i">
          <br>
          <cfloop from="1" to="5" index="j">
               Char #J# of Chunk #i# is #right(left(arguments.SFID,(i-1)*5+j),1)#<br>
               <cfif find(right(left(arguments.SFID,(i-1)*5+j),1),InUpper) GT 0>
                    Adding 1 To Chunk #i#<br>
                    <cfset ChunkTotal[i] &= "1">
                    <cfelse>
                         <cfset ChunkTotal[i] &= "0">
               </cfif> 
               CHUNK IS #CHUNKTOTAL[i]#<br>
               <cfset ChunkTotal[i] = reverse(chunkTotal[i])>
          </cfloop>     
     </cfloop>
     </cfoutput>
     
     <cfdump var="#ChunkTotal#">
     <cfreturn ChunkTotal>
</cffunction>

Thanks to a bouquet.

A few observations.  The first is the most important:

(1) look carefully where you make your call reverse().  Are you sure that you do it in the right place?  You want to invert your string whenever you add to your piece, or you want to reverse your piece together once you have finished?

(2) you should study the mid(), rather than make the combo right () /left () function.

(3) always VAR your variables in a function.

(4) I would not do this:

Find (right (left(arguments.) SFID,(i-1) * 5 + j), 1), InUpper)

I could do this:

c = mid (arguments.sfid, ((i-1) * 5) + j, 1)

Find ("^ $[A - Z]", c)

5) rather than write the pieces in the form of binary numbers, reverse, then convert them in full, you could do this in one fell swoop.

-in the first loop

-ChunkTotal [i] the value zero

-Have the loop internal, run from 5-1, not 1-5

-instead of adding a 1 or a 0 to ChunkTotal [i], ADD this: 2 ^(j-1).

-After the loop, you will have the integer you were after in the first place.

Make sense?

--

Adam

Tags: ColdFusion

Similar Questions

  • New user trying to create this simple function of Xcode

    I'm a programmer windows trying to learn Xcode / swift.

    How can I get this simple function to work?

    He complains about the pi in the line "access to".

    I hope this is enough information.

    Thank you

    disp_to_acceleration Func (freq: Float, disp: Float)-> {Float

    Let pi = M_PI

    Let accel = disp * 2 * powf (freq * pi, 2.0)

    Back to accel

    }

    Oops error in the post "Let's accel.

  • I can't write CD on Satellite Pro P100-347

    I was recently bought a Satellite Pro P100-347 with Windows XP MCE installed as a desktop computer (the store didn't inform the person who has bought a laptop that was not networked). We have purchased a full copy of Windows XP Pro and booted from the disk, formatted the hard drive and installed XP Pro instead of the ERM and then downloaded and installed all the drivers on the Toshiba site.

    I had the "failure to obtain read handle" error starting but followed the recommendations on this site and removed the toshibarc.exe of the registry. Now, the only thing I still need is to get the CD of drivers, because even though I can play CDs and copy on their part, I can't write CD - if I put a blank CD in the drive and select the option to create the writable CD folder, I get an error that says ' D: / is not accessible. Incorrect function. "

    I downloaded and installed the DVD-RAM drivers, but I can't find those specifically for the CD. Can anyone help?

    Thanks in advance,

    Jeremy Jones

    Hello

    In my opinion, you should check the properties of the disk and click the recording tab.
    CD recording option on this drive must be marked.

    I had a similar problem and this hidden option was responsible for registration on my laptop problems

  • I can't write operating records

    My hay program mast view some data from a controller. This with an Ethernet connection. I read everything and I can write coils bet I can't write operating records. I hope someone can help? Heir my VI: Rutte

    With split or join in the digital numbers / range of data manipulation, you can take two U8 and join them in a single U16 (and vice-versa using split).  And you can take two U16 and join them in an only U32.

    Take a look at the attached Subvi, I did.  It is a wrapper for the Modbus VI functions so that I could use enumerations to read or write specific registers by name and manage the manipulation of data as a result.  It may call for a couple of typedef, that I created for my particular application, but that should not prevent you to see the structure and how I did the manipulation of data using the split and join.

  • If I have floating values such as 6.3 6.7, 6.9, 7.1, 7.2, how can I write a case statement to handle this

    How can I write a case statement if I want a case for x< 1.5;  ="" a="" case="" for="" 1.5=""><= x=""><= 3.7; ="" case="" for ="" 3.7="">< x="">< 7.2.....etc.  ="" my="" input="" is="" a="" floating="">

    Thank you.

    You don't seem to have set rules on inclusion, but I often use the function in the range and Coerce in these cases.

  • How can I write the value of floats Unitronics vision230 PLC with modbus Ethernet

    How can I write the value of type Float in unitronics PLC Vision230 modbus ethernet (Ethernet Master Query.vi MB) usinsg I read and write register 32 bits, for example, I want to write the value 23.45 2nd Add. MF. And registry MF is the 32-bit registry. I read and write register 32-bit.

    Narendra.

    Narendra,

    Two characters can type cast into a uint16 you VI supports.

    To summarize. Take one (4 bytes). Flatten it to a string (4-byte) divided this string into two parts of 2 bytes each. Cast in u16 (16 x 2 = 32-bit).

    However, if you really want to follow the IEEE standards then you will need refer this KB. His is not that simple, but seems closer to what you are looking for.

    Amit

  • How can I write in a table cell (row, column appear) in a databae?

    How can I write in a table cell (row, column appear) in a database using LabVIEW Database Toolkit? I use Ms Access. Suppose I have three columns in a table, I write 1 row of the 1st column, then 1st rank of the 3rd column. The problem I have is after writing the 1st column of 1st row, the reference goes to the second row, and if I write in the 3rd column, he goes to the 2nd row 3rd column. Any suggestion?

    When you perform a SQL INSERT command, you create a new line. If you want to change an existing line, you must use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column = some_value). The some_column could be the unique ID of each line, date and time, etc.

    I don't know what is the function to use in the Toolbox to execute a SQL command, since I do not use the Toolbox. Also, I don't understand why you don't do a single INSERT. It would be much faster.

  • Can I write a .bat file to list all files of a specific type?

    With the help that I am here, I wrote a simple .bat file that lists all the files in a directory that I chose.

    I would now like to make a version of which lists all the files in the specified directory that have a .wav extension. Is this possible?

    Here are the existing syntax:

    D:
    CD D:\inetpub\kthings
    dir > C:\tftDocuments.txt
    TYPE tftDocuments.txt

    Can I write a .bat file to list all files of a specific type?

    I do not know.  Can you?

    Tips:

    Go here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true

    Or just open a command prompt window (start > run > cmd > OK), and then type a command followed by the characters /? to see information about this command.

    For example, try

    dir /?

    You should also read http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true this http://technet.microsoft.com/en-us/library/bb490982.aspx and maybe this http://www.pcstats.com/articleview.cfm?articleID=1767

  • Why I can not write in the contact form?

    I use the widget simple contact form. Unfortunately, when the site has been uploaded to the server, I can not write in the form.

    Anyone have an idea why?

    Thanks for the reply,

    Angelika

    Your page uses a 3rd party widget that adds some javascript to try to block the right mouse clicks - which interferes with by clicking on the form in firefox. I suggest you remove this widget or by contacting the promoter to see if they have an updated version that works with the forms of the Muse in firefox.

  • Hello.. I'm from the programming, but new to actionscript. I would like to ask if there was a library where all built in functions, methods, and events can be searched. As for VB, MSDN (of Microsoft Developer Network) used to be there. More than once it h

    Hello.. I'm from the programming, but new to actionscript. I would like to ask if there was a library where all built in functions, methods, and events can be searched. As for VB, MSDN (of Microsoft Developer Network) used to be there. More than once it happens that I write a few lines of code, but a built-in function already exists for the same thing. Is there a way to check it out ahead of time?

    An online resource are QAnywhere® to Adobe ActionScript 3 (AS3)

  • Simple function to create ToolTip in Actionscript 3

    Hello

    I'm new to Actionscript 3 and I'm creating an application in which I need to use tooltips.  I thought it would be simple because in VBA and other object-oriented languages, you have a tooltip for a button and all property you need to enter the text (or even schedule it, which is very simple).  However, I can't seem to create tooltips in Flash using AS3, I tried 6 different methods (fairly complex) from code I found online but could get any of them to work.  Can someone please give me a simple function that takes as parameters the ToolTip text and the original button, then the right function creates the ToolTip automatically once it's called? Any help would be greatly appreciated. Thank you.

    If the two functions add and remove are on the same timeline you will not see this error message.  but I see typo:

    create a buttonObj for all your buttons

    var buttonObj:Object = {};

    //////////////////////////////////////change nothing above ////////////////////////////////////

    the next 3 lines must be made for all your buttons

    buttonObj [yourbutton] = ['Hello', 2, 2];

    yourbutton.addEventListener (MouseEvent.MOUSE_OVER, addToolTipF);

    yourbutton.addEventListener (MouseEvent.MOUSE_OUT, removeToolTipF);

    change nothing below.

    function addToolTipF(e:MouseEvent):void {}

    var a: Array = buttonObj [e.currentTarget];

    var tf:TextField = new TextField();

    buttonObj [e.currentTarget] .push (tf);

    TF. Text = a [0];

    TF. Multiline = false;

    tf.autoSize = "left";

    TF. Border = true;

    addChild (tf);

    TF.x = a [1] + e.currentTarget.x;

    TF.y = a [2] + e.currentTarget.y;

    }

    function removeToolTipF(e:MouseEvent):void {}

    removeChild(buttonObj[e.currentTarget][3]);

    buttonObj [e.currentTarget]. splice (3,1);

    }

  • How can I write this loop?

    How can I write this code works as follows.

    When btn1 is clicked, SenderLoad must be 'clay' AND click btn2, SenderLoad must be 'iron', etc...

    var mgB:Array = [btn1, btn2, btn3 btn4];

    var mgBW:Array = ["clay", "railway", "cotton", "leather"];

    var SenderLoad: LoadVars = new LoadVars();

    var ReceLoad: LoadVars = new LoadVars();

    var mgNum:Number = 0;

    for (i = 0; i < mgBW.length; i ++) {}

    mgBW [i] .onRelease = function () {}

    mgNum ++

    SenderLoad.word = mgB [mgNum];

    SenderLoad.sendAndLoad ("http://www.web.com/my.php", ReceLoad, "POST" ');

    ReceLoad.onData = {function (src)}

    var messageA:Array = src.split(",,,");

    ldrB2.html = true;

    for (var i: Number = 0; i < messageA.length; i ++) {}

    var a:Array is get [i].split(",,");.

    ldrB1.htmlText += a [0];

    ldrB2.htmlText += a [1];

    }

    }

    }

    };

    If you use the movieclip buttons:

    var mgB:Array = [btn1, btn2, btn3 btn4];
    var mgBW:Array = ["clay", "railway", "cotton", "leather"];
    var SenderLoad: LoadVars = new LoadVars();
    var ReceLoad: LoadVars = new LoadVars();

    for (i = 0; i
    .Ivar Construction [i] = i;
    mgB [i] .onRelease = function() {}
    SenderLoad.word = mgBW [this.ivar];
    SenderLoad.sendAndLoad ("http://www.web.com/my.php", ReceLoad, "POST");

    };
    }
    ReceLoad.onData = {function (src)}
    var messageA:Array = src.split(",,,");
    ldrB2.html = true;
    for (var i: Number = 0; i
    var a: Array = get [i] .split (",");
    ldrB1.htmlText += a [0];
    ldrB2.htmlText += a [1];
    }
    };

  • How can I write this GREP query correctly (CS4)

    Hello.

    I have a, uh, interesting problem. I got a HUGE page layout document. copy typed in word... and have ' cleaned every regular:

    -to - and multi-retourne to the simple and so on.

    However, the editor has throughout the copy (by effect? LOL) decided to single space the letters of the words randomly in the text as follows:

    It is a E x a m p l e, of what he has done and is a massive p r o b l e m / e h a d a, c e h!

    Ok... I try to work on the proper GREP but have so far failed. What I need, is to find any space white between two simple letters and replace it with, well, to remove them. I'm into hysteria with myself as it seems so simple and yet I can not understand it.

    So, here I am enlisting the help of the GREP Boffins out there.

    Thank you sincerely

    Grant

    It would be: search

    (? <><\w) (?="\w\">)

    replacing it with nothing - assuming that these spaces, as Peter points out. It really could be followed as well. It's (I think) so a style German emphasis to the space of words (but not as big as a set of 'regular' space).

    You'd also better to check than if there are really just words at random, otherwise you will lose focus. If you want to mark the words with a character style, you cannot use the above GREP. Interestingly, I can not write a single GREP that removes the spaces and add a character style to the text at a time... But you can use the GREP

    \<\w( \w)+\="">

    with a character style in the replace with formatting field to mark any text with a style, and then remove the outdoor areas.
  • Now, I can't write to NTFS HDD I could do before with the company paragon software.

    Apple you are completely unforgivable, please tell us how can I write my HARD drives?

    How old is your version of Paragon NTFS? Like many other software titles, they may have to be updated to work with a newer operating system. A level system especially the module. The latest version is noted as being compatible with El Capitan. Upgrade if necessary.

  • Stop Autoplay is my favorite Firefox app. It is no longer supported. Can I write a new version for Firefox?

    Stop Autoplay has been withdrawn at the request of the creator. I strongly dislike the feature of auto-play on Web sites and want to disable on the new Firefox. Can I write an app to do this and offer it to other users?
    I don't have to upgrade my version of Firefox because this app is no longer supported.

    I found it! It is on the website of the creator, but it's an addon of the 3 - rd party, so someone out there must be updated.

    http://NettiCat.ath.CX/MyAddons/MyAddons.htm#SAP

Maybe you are looking for