Search Results

Search found 37183 results on 1488 pages for 'string conversion'.

Page 81/1488 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • XSLT - make xsl:analyze-string return string instead of sequence of strings?

    - by tohuwawohu
    Is it possible to make xsl:analyze-string return one string instead of a sequence of strings? Background: I'd like to use xsl:analyze-string in a xsl:function that should encapsulate the pattern matching. Ideally, the function should return an xs:string to be used as sort criteria in an xsl:sort element. At the moment, i have to apply string-join() on every result of the function call since xsl:analyze-string returns a sequence of strings, and xsl:sort doesn't accept such a sequence as sort criteria. See line 24 of the stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="www.my-personal-namespa.ce" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output indent="yes" method="xml" /> <xsl:function name="my:sortierung" > <xsl:param name="inputstring" as="xs:string"/> <xsl:analyze-string select="$inputstring" regex="[0-9]+"> <xsl:matching-substring> <xsl:value-of select="format-number(number(.), '00000')" /> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="." /> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:function> <xsl:template match="/input"> <result> <xsl:apply-templates select="value" > <xsl:sort select="string-join((my:sortierung(.)), ' ')" /> </xsl:apply-templates> </result> </xsl:template> <xsl:template match="value"> <xsl:copy-of select="." /> </xsl:template> </xsl:stylesheet> with this input: <?xml version="1.0" encoding="UTF-8"?> <input> <value>A 1 b 120</value> <value>A 1 b 1</value> <value>A 1 b 2</value> <value>A 1 b 1a</value> </input> In my example, is there a way to modify the xsl:function to return a xs:string instead of a sequence?

    Read the article

  • Code golf - hex to (raw) binary conversion

    - by Alnitak
    In response to this question asking about hex to (raw) binary conversion, a comment suggested that it could be solved in "5-10 lines of C, or any other language." I'm sure that for (some) scripting languages that could be achieved, and would like to see how. Can we prove that comment true, for C, too? NB: this doesn't mean hex to ASCII binary - specifically the output should be a raw octet stream corresponding to the input ASCII hex. Also, the input parser should skip/ignore white space. edit (by Brian Campbell) May I propose the following rules, for consistency? Feel free to edit or delete these if you don't think these are helpful, but I think that since there has been some discussion of how certain cases should work, some clarification would be helpful. The program must read from stdin and write to stdout (we could also allow reading from and writing to files passed in on the command line, but I can't imagine that would be shorter in any language than stdin and stdout) The program must use only packages included with your base, standard language distribution. In the case of C/C++, this means their respective standard libraries, and not POSIX. The program must compile or run without any special options passed to the compiler or interpreter (so, 'gcc myprog.c' or 'python myprog.py' or 'ruby myprog.rb' are OK, while 'ruby -rscanf myprog.rb' is not allowed; requiring/importing modules counts against your character count). The program should read integer bytes represented by pairs of adjacent hexadecimal digits (upper, lower, or mixed case), optionally separated by whitespace, and write the corresponding bytes to output. Each pair of hexadecimal digits is written with most significant nibble first. The behavior of the program on invalid input (characters besides [a-fA-F \t\r\n], spaces separating the two characters in an individual byte, an odd number of hex digits in the input) is undefined; any behavior (other than actively damaging the user's computer or something) on bad input is acceptable (throwing an error, stopping output, ignoring bad characters, treating a single character as the value of one byte, are all OK) The program may write no additional bytes to output. Code is scored by fewest total bytes in the source file. (Or, if we wanted to be more true to the original challenge, the score would be based on lowest number of lines of code; I would impose an 80 character limit per line in that case, since otherwise you'd get a bunch of ties for 1 line).

    Read the article

  • one to many jpa relationship

    - by user309944
    Hai I have created two table first table as student package com.crimson.rship; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToMany; @Entity(name="student") public class student { @Id private String stumailid; @Basic private String fathername; @Basic private String mothername; @Basic private String doa; @Basic private String dob; public student(String stumailid,String fathername,String mothername,String doa,String dob) { // TODO Auto-generated constructor stub this.stumailid=stumailid; this.fathername=fathername; this.mothername=mothername; this.doa=doa; this.dob=dob; } public void setStumailid(String stumailid) { this.stumailid = stumailid; } public String getStumailid() { return stumailid; } public void setFathername(String fathername) { this.fathername = fathername; } public String getFathername() { return fathername; } public void setMothername(String mothername) { this.mothername = mothername; } public String getMothername() { return mothername; } public void setDoa(String doa) { this.doa = doa; } public String getDoa() { return doa; } public void setDob(String dob) { this.dob = dob; } public String getDob() { return dob; } } Second table as mark package com.crimson.rship; import java.util.Collection; import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.OneToMany; @Entity(name="mark") public class mark { @Id private String stumailid; @Basic private String fathername; @Basic private String mothername; @OneToMany(mappedBy="mark",targetEntity=student.class,fetch=FetchType.EAGER) private Collection orders; public mark(String stumailid,String fathername,String mothername) { // TODO Auto-generated constructor stub this.stumailid=stumailid; this.fathername=fathername; this.mothername=mothername; } public void setStumailid(String stumailid) { this.stumailid = stumailid; } public String getStumailid() { return stumailid; } public void setFathername(String fathername) { this.fathername = fathername; } public String getFathername() { return fathername; } public void setMothername(String mothername) { this.mothername = mothername; } public String getMothername() { return mothername; } public void setOrders(Collection orders) { this.orders = orders; } public Collection getOrders() { return orders; } } But this above coding working is not working correctly.can any one help me Thanks in advance

    Read the article

  • Float Conversion Issue

    - by user1407570
    I have an issue after converted a float from a string, the result of my operation is null The NSLogs give the right value but vitesseMoyenne is equal to null -(void)setVitesseMoyenne:(float)uneDistanceTotale:(NSString*)unTempsTotal { //float tempEnFloat = [unTempsTotal floatValue]; NSLog(@"%@",unTempsTotal); float calculVitesseMoyenne = uneDistanceTotale / [unTempsTotal floatValue]; NSLog(@"%f",calculVitesseMoyenne); vitesseMoyenne = [NSString stringWithFormat:@"%f", calculVitesseMoyenne]; } Can you see what is wrong ?

    Read the article

  • Program crashes when item selected from listView

    - by philip
    The application just crash every time I try to click from the list. ListMovingNames.java public class ListMovingNames extends Activity { ListView MoveList; SQLHandler SQLHandlerview; Cursor cursor; Button addMove; EditText etAddMove; TextView temp; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.selectorcreatemove); addMove = (Button) findViewById(R.id.bAddMove); etAddMove = (EditText) findViewById(R.id.etMoveName); temp = (TextView) findViewById(R.id.tvTemp); MoveList = (ListView) findViewById(R.id.lvMoveItems); SQLHandlerview = new SQLHandler(this); SQLHandlerview = new SQLHandler(ListMovingNames.this); SQLHandlerview.open(); cursor = SQLHandlerview.getMove(); startManagingCursor(cursor); String[] from = new String[]{SQLHandler.KEY_MOVENAME}; int[] to = new int[]{R.id.text}; SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to); MoveList.setAdapter(cursorAdapter); SQLHandlerview.close(); addMove.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub try { String ssmoveName = etAddMove.getText().toString(); SQLHandler entry = new SQLHandler(ListMovingNames.this); entry.open(); entry.createMove(ssmoveName); entry.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); MoveList.setOnItemClickListener(new OnItemClickListener() { @SuppressLint("ShowToast") public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { // TODO Auto-generated method stub // String moveset = cursor.getString(position); // temp.setText(moveset); Toast.makeText(ListMovingNames.this, position, Toast.LENGTH_SHORT); } }); } } and here's my database handler. But I'm sure that there's nothing wrong with it, its probably the cursor adapter. SQLHandler.java public class SQLHandler { public static final String KEY_ROOMMOVEHOLDER = "roommoveholder"; public static final String KEY_ROOM = "room"; public static final String KEY_ITEMMOVEHOLDER = "itemmoveholder"; public static final String KEY_ITEMNAME = "itemname"; public static final String KEY_ITEMVALUE = "itemvalue"; public static final String KEY_ROOMHOLDER = "roomholder"; public static final String KEY_MOVENAME = "movename"; public static final String KEY_ID1 = "_id"; public static final String KEY_ID2 = "_id"; public static final String KEY_ID3 = "_id"; public static final String KEY_ID4 = "_id"; public static final String KEY_MOVEDATE = "movedate"; private static final String DATABASE_NAME = "mymovingfriend"; private static final int DATABASE_VERSION = 1; public static final String KEY_SORTANDPURGE = "sortandpurge"; public static final String KEY_RESEARCH = "research"; public static final String KEY_CREATEMOVINGBINDER = "createmovingbinder"; public static final String KEY_ORDERSUPPLIES = "ordersupplies"; public static final String KEY_USEITORLOSEIT = "useitorloseit"; public static final String KEY_TAKEMEASUREMENTS = "takemeasurements"; public static final String KEY_CHOOSEMOVER = "choosemover"; public static final String KEY_BEGINPACKING = "beginpacking"; public static final String KEY_LABEL = "label"; public static final String KEY_SEPARATEVALUES = "separatevalues"; public static final String KEY_DOACHANGEOFADDRESS = "doachangeofaddress"; public static final String KEY_NOTIFYIMPORTANTPARTIES = "notifyimportantparties"; private static final String DATABASE_TABLE1 = "movingname"; private static final String DATABASE_TABLE2 = "movingrooms"; private static final String DATABASE_TABLE3 = "movingitems"; private static final String DATABASE_TABLE4 = "todolist"; public static final String CREATE_TABLE_1 = "CREATE TABLE " + DATABASE_TABLE1 + " (" + KEY_ID1 + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_MOVEDATE + " TEXT NOT NULL, " + KEY_MOVENAME + " TEXT NOT NULL);"; public static final String CREATE_TABLE_2 = "CREATE TABLE " + DATABASE_TABLE2 + " (" + KEY_ID2 + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_ROOMMOVEHOLDER + " TEXT NOT NULL, " + KEY_ROOM + " TEXT NOT NULL);"; public static final String CREATE_TABLE_3 = "CREATE TABLE " + DATABASE_TABLE3 + " (" + KEY_ID3 + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_ITEMNAME + " TEXT NOT NULL, " + KEY_ITEMVALUE + " TEXT NOT NULL, " + KEY_ROOMHOLDER + " TEXT NOT NULL, " + KEY_ITEMMOVEHOLDER + " TEXT NOT NULL);"; public static final String CREATE_TABLE_4 = "CREATE TABLE " + DATABASE_TABLE4 + " (" + KEY_ID4 + " INTEGER PRIMARY KEY AUTOINCREMENT," + KEY_SORTANDPURGE + " TEXT NOT NULL, " + KEY_RESEARCH + " INTEGER NOT NULL, " + KEY_CREATEMOVINGBINDER + " TEXT NOT NULL, " + KEY_ORDERSUPPLIES + " TEXT NOT NULL, " + KEY_USEITORLOSEIT + " TEXT NOT NULL, " + KEY_TAKEMEASUREMENTS + " TEXT NOT NULL, " + KEY_CHOOSEMOVER + " TEXT NOT NULL, " + KEY_BEGINPACKING + " TEXT NOT NULL, " + KEY_LABEL + " TEXT NOT NULL, " + KEY_SEPARATEVALUES + " TEXT NOT NULL, " + KEY_DOACHANGEOFADDRESS + " TEXT NOT NULL, " + KEY_NOTIFYIMPORTANTPARTIES + " TEXT NOT NULL);"; private DbHelper ourHelper; private final Context ourContext; private SQLiteDatabase ourDatabase; private static class DbHelper extends SQLiteOpenHelper{ public DbHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub db.execSQL(CREATE_TABLE_1); db.execSQL(CREATE_TABLE_2); db.execSQL(CREATE_TABLE_3); db.execSQL(CREATE_TABLE_4); } @Override public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE1); db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE2); db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE3); db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE4); onCreate(db); } } public SQLHandler(Context c){ ourContext = c; } public SQLHandler open() throws SQLException{ ourHelper = new DbHelper(ourContext); ourDatabase = ourHelper.getWritableDatabase(); return this; } public void close(){ ourHelper.close(); } public long createMove(String smovename){ ContentValues cv = new ContentValues(); cv.put(KEY_MOVENAME, smovename); cv.put(KEY_MOVEDATE, "Not yet set"); return ourDatabase.insert(DATABASE_TABLE1, null, cv); } public long addRooms(String sroommoveholder, String sroom){ ContentValues cv = new ContentValues(); cv.put(KEY_ROOMMOVEHOLDER, sroommoveholder); cv.put(KEY_ROOM, sroom); return ourDatabase.insert(DATABASE_TABLE2, null, cv); } public long addItems(String sitemmoveholder, String sroomholder, String sitemname, String sitemvalue){ ContentValues cv = new ContentValues(); cv.put(KEY_ITEMMOVEHOLDER, sitemmoveholder); cv.put(KEY_ROOMHOLDER, sroomholder); cv.put(KEY_ITEMNAME, sitemname); cv.put(KEY_ITEMVALUE, sitemvalue); return ourDatabase.insert(DATABASE_TABLE3, null, cv); } public long todoList(String todoitem){ ContentValues cv = new ContentValues(); cv.put(todoitem, "Done"); return ourDatabase.insert(DATABASE_TABLE4, null, cv); } public Cursor getMove(){ String[] columns = new String[]{KEY_ID1, KEY_MOVENAME}; Cursor cursor = ourDatabase.query(DATABASE_TABLE1, columns, null, null, null, null, null); return cursor; } } can anyone point out what I'm doing wrong? here's the log 09-19 03:22:36.596: E/AndroidRuntime(679): FATAL EXCEPTION: main 09-19 03:22:36.596: E/AndroidRuntime(679): android.content.res.Resources$NotFoundException: String resource ID #0x0 09-19 03:22:36.596: E/AndroidRuntime(679): at android.content.res.Resources.getText(Resources.java:201) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.widget.Toast.makeText(Toast.java:258) 09-19 03:22:36.596: E/AndroidRuntime(679): at standard.internet.marketing.mymovingfriend.ListMovingNames$2.onItemClick(ListMovingNames.java:78) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.widget.ListView.performItemClick(ListView.java:3382) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.os.Handler.handleCallback(Handler.java:587) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.os.Handler.dispatchMessage(Handler.java:92) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.os.Looper.loop(Looper.java:123) 09-19 03:22:36.596: E/AndroidRuntime(679): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-19 03:22:36.596: E/AndroidRuntime(679): at java.lang.reflect.Method.invokeNative(Native Method) 09-19 03:22:36.596: E/AndroidRuntime(679): at java.lang.reflect.Method.invoke(Method.java:521) 09-19 03:22:36.596: E/AndroidRuntime(679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-19 03:22:36.596: E/AndroidRuntime(679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-19 03:22:36.596: E/AndroidRuntime(679): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Powershell: Cannot connect via SSL

    - by JSWork
    Am following "secrets to powershell remoting" to setup an SLL account and seem to be missing a step. I ran Winrm create winrm/config/Listener?Address=*+Transport=HTTPS @{Hostname="redacted";CertificateThumbprint="redacted"} and got PS WSMan:\localhost&gt; dir wsman:\localhost\listener\Listener_1184937132 WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1184937132 Name Value Type ---- ----- ---- Address * System.String Transport HTTP System.String Port 5985 System.String Hostname System.String Enabled true System.String URLPrefix wsman System.String CertificateThumbprint System.String ListeningOn_756355952 10.0.0.54 System.String ListeningOn_1201550598 127.0.0.1 System.String PS WSMan:\localhost&gt; dir wsman:\localhost\listener\Listener_1187163138 WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_1187163138 Name Value Type ---- ----- ---- Address * System.String Transport HTTP System.String Port 80 System.String Hostname System.String Enabled true System.String URLPrefix wsman System.String CertificateThumbprint System.String ListeningOn_756355952 10.0.0.54 System.String ListeningOn_1201550598 127.0.0.1 System.String PS WSMan:\localhost&gt; dir wsman:\localhost\listener\Listener_220862350 WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Listener\Listener_220862350 Name Value Type ---- ----- ---- Address * System.String Transport HTTPS System.String Port 5986 System.String Hostname redacted System.String Enabled true System.String URLPrefix wsman System.String CertificateThumbprint redacted System.String ListeningOn_756355952 10.0.0.54 System.String ListeningOn_1201550598 127.0.0.1 System.String Trouble is when i do this PS C:\Users\redacted> enter-pssession -Computername redacted -Credential redacted\redacted -UseSSL I get this Enter-PSSession : Connecting to remote server failed with the following error message : The client cannot connect to th e destination specified in the request. Verify that the service on the destination is running and is accepting requests . Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or Win RM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:16 + enter-pssession <<<< -Computername redacted -Credential redacted\redacted -UseSSL + CategoryInfo : InvalidArgument: (redacted:String) [Enter-PSSession], PSRemotingTransportException + FullyQualifiedErrorId : CreateRemoteRunspaceFailed This happens even when the firewall is off completely and when the machine tires to connect to itself locally. On top of that, despite the listners eing lsited on wsman, when I run PS WSMan:\localhost&gt; Get-PSSessionConfiguration I get Name PSVersion StartupScript Permission ---- --------- ------------- ---------- Microsoft.PowerShell 2.0 PS WSMan:\localhost&gt; Any ideas what I'm missing/doing wrong? edit: Windows 2003. Powershell v2.0

    Read the article

  • Java conditional operator ?: result type

    - by Wangnick
    I'm a bit puzzled about the conditional operator. Consider the following two lines: Float f1 = false? 1.0f: null; Float f2 = false? 1.0f: false? 1.0f: null; Why does f1 become null and the second statement throws a NullPointerException? Langspec-3.0 para 15.25 sais: Otherwise, the second and third operands are of types S1 and S2 respectively. Let T1 be the type that results from applying boxing conversion to S1, and let T2 be the type that results from applying boxing conversion to S2. The type of the conditional expression is the result of applying capture conversion (§5.1.10) to lub(T1, T2) (§15.12.2.7). So for false?1.0f:null T1 is Float and T2 is the null type. But what is the result of lub(T1,T2)? This para 15.12.2.7 is just a bit too much ... BTW, I'm using 1.6.0_18 on Windows. PS: I know that Float f2 = false? (Float) 1.0f: false? (Float) 1.0f: null; doesn't throw NPE.

    Read the article

  • Cast then check or check then cast?

    - by jamesrom
    Which method is regarded as best practice? Cast first? public string Describe(ICola cola) { var coke = cola as CocaCola; if (coke != null) { string result; // some unique coca-cola only code here. return result; } var pepsi = cola as Pepsi; if (pepsi != null) { string result; // some unique pepsi only code here. return result; } } Or should I check first, cast later? public string Describe(ICola cola) { if (cola is CocaCola) { coke = (CocaCola) cola; string result; // some unique coca-cola only code here. return result; } if (cola is Pepsi) { pepsi = (Pepsi) cola; string result; // some unique pepsi only code here. return result; } } Can you see any other way to do this?

    Read the article

  • Help with debugging COM errors? (.mdi to .pdf file conversions using Microsoft Office Document Imagi

    - by RyanW
    I thought I had a working solution for converting .mdi files to PDF using the Microsoft Office Document Imaging object model. The solution is in a Windows Service, but now I'm running into some errors that I'm having trouble tracking down info on. The exception I get is: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) at MODI.DocumentClass.Create(String FileOpen) at DocumentStore.Mdi2PDF(String path, String newPath) Then, in the Event Viewer there is the following Application error: Faulting application MyWindowsServiceName.exe, version 1.0.0.0, time stamp 0x4b97f185, faulting module mso.dll, version 12.0.6425.1000, time stamp 0x49d65443, exception code 0xc0000005, fault offset 0x0000bd8e, process id 0xa5c, application start time 0x01cac08cf032914b. Here's the method that is doing the conversion: private int? Mdi2PDF(String path, String newPath) { int? pageCount = null; string tmpTif = Path.GetTempFileName(); MODI.Document mdiDoc = new MODI.Document(); mdiDoc.Create(path); mdiDoc.SaveAs(tmpTif, MODI.MiFILE_FORMAT.miFILE_FORMAT_TIFF_LOSSLESS, MODI.MiCOMP_LEVEL.miCOMP_LEVEL_HIGH); mdiDoc.Close(false); pageCount = Tiff2PDF(tmpTif, newPath); if (File.Exists(tmpTif)) File.Delete(tmpTif); return pageCount; } I removed all threading from the service invoking this, so that only the primary thread was initializing the MODI object, but still got the error, so it doesn't appear to be threading related. I also built a a console apps converting hundreds of documents and DID NOT get the exception. So, it seems to be caused by creating too many instances of the MODI object, but only instantiated within a Service? Doesn't quite make sense. Anybody have any clues about these errors and how to debug them further?

    Read the article

  • Strange behaviour when simply adding strings in Lazarus - FreePascal

    - by linkcharger
    The program has several "encryption" algorithms. This one should blockwise reverse the input. "He|ll|o " becomes "o |ll|He" (block length of 2). I add two strings, in this case appending the result string to the current "block" string and making that the result. When I add the result first and then the block it works fine and gives me back the original string. But when i try to reverse the order it just gives me the the last "block". Several other functions that are used for "rotation" are above. //amount of blocks function amBl(i1:integer;i2:integer):integer; begin if (i1 mod i2) <> 0 then result := (i1 div i2) else result := (i1 div i2) - 1; end; //calculation of block length function calcBl(keyStr:string):integer; var i:integer; begin result := 0; for i := 1 to Length(keyStr) do begin result := (result + ord(keyStr[i])) mod 5; result := result + 2; end; end; //desperate try to add strings function append(s1,s2:string):string; begin insert(s2,s1,Length(s1)+1); result := s1; end; function rotation(inStr,keyStr:string):string; var //array of chars -> string block,temp:string; //position in block variable posB:integer; //block length and block count variable bl, bc:integer; //null character as placeholder n : ansiChar; begin //calculating block length 2..6 bl := calcBl(keyStr); setLength(block,bl); result := ''; temp := ''; {n := #00;} for bc := 0 to amBl(Length(inStr),bl) do begin //filling block with chars starting from back of virtual block (in inStr) for posB := 1 to bl do begin block[posB] := inStr[bc * bl + posB]; {if inStr[bc * bl + posB] = ' ' then block[posB] := n;} end; //adding the block in front of the existing result string temp := result; result := block + temp; //result := append(block,temp); //result := concat(block,temp); end; end; (full code http://pastebin.com/6Uarerhk) After all the loops "result" has the right value, but in the last step (between "result := block + temp" and the "end;" of the function) "block" replaces the content of "result" with itself completely, it doesn't add result at the end anymore. And as you can see I even used a temp variable to try to work around that.. doesnt change anything though.

    Read the article

  • Struts 1 ActionForm - retrieving a collection from pure HTML

    - by Yaneeve
    Hi all I have (just like the rest) inherited some struts 1 code. I have had need to add a few more pages to this project. What I cannot figure out is how to map several distinct but similarly natured input elements to the my ActionForm. Let me elaborate. I create a new <Input> element dynamically as the user inputs more and more items (I use the YUI autocomplete form element and for each entered input I add it as an input element to my form and draw a new YUI autocomplete - complex sounding, I know) So... My form looks a bit like (... after some prettifying and some such...): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>My Cool App - Test Case Builder</title> <link rel="stylesheet" type="text/css" href="../script/yui/fonts/fonts-min.css" /> <link rel="stylesheet" type="text/css" href="../skins/myCoolApp/button/button.css" /> <link rel="stylesheet" type="text/css" href="../script/yui/autocomplete/assets/skins/sam/autocomplete.css" /> <link rel="stylesheet" type="text/css" media="screen" href="../skins/myCoolApp/testcase.css" /> <!-- YUI JAVA SCRIPTS --> <script type="text/javascript" src="../script/yui/yahoo-dom-event/yahoo-dom-event.js"></script> <script type="text/javascript" src="../script/yui/element/element-min.js"></script> <script type="text/javascript" src="../script/yui/button/button-min.js"></script> <script type="text/javascript" src="../script/yui/datasource/datasource-min.js"></script> <script type="text/javascript" src="../script/yui/autocomplete/autocomplete-min.js"></script> <!-- APP JAVA SCRIPTS --> <script type="text/javascript" src="../script/myCoolApp/myCoolApp.js" ></script> <script type="text/javascript" src="../script/myCoolApp/stack.js" ></script> <script type="text/javascript" src="../script/myCoolApp/testcase/testcase.js"></script> <script type="text/javascript" src="../script/myCoolApp/testcase/default-data.js" ></script> <script type="text/javascript" src="../script/myCoolApp/testcase/data-structs.js" ></script> <script type="text/javascript" src="../script/myCoolApp/testcase/ui-elements.js" ></script> </head> <body class="cf010"> <div id="wrap"> <div id="header"> <div id="main-header"> COOL APP </div> </div> <div id="main-body"> <div id="content"> <div class="col main"> <div id="main"> <form method="post" id="testcaseForm" class="typea" action=""> <fieldset> <legend>Test Case Builder</legend> <div id="tk1" class="tabcontrol"> <ul class="tabs"> <li class="first active"> <a href="#"> <span>General</span> </a> </li> <li class="last"> <a href="#"> <span>Parameters</span> </a> </li> </ul> <div id="tab0" class="tc-panel"> <dl class="cls9"> <dt> <label for="scenario">Choose Scenario:</label> </dt> <dd> <input type="text" id="scenario" name="scenario" class="text" /> <span id="scenarioToggle"></span> <div class="auto-complete" id="scenarioContainer"></div> </dd> <dt> <label for="ruleID">Choose Rule ID:</label> </dt> <dd> <input type="text" id="ruleID" name="ruleID" class="text" /> <span id="ruleIDToggle"></span> <div class="auto-complete" id="ruleIDContainer"></div> </dd> <dt> <label for="Test Case Name" accesskey="t"><span class="accesskey">T</span>est Case Name:</label> </dt> <dd> <input type="text" id="testCaseName" name="testCaseName" class="text" /> </dd> </dl> </div> <div id="tab1" class="tc-panel hidden"> <div class="toolbar" id="action-bar"> <ul> <li class="first"> <a title="select all" href="#" id="btmSelectAll" class="button"> <span>select all</span> </a> </li> <li> <a title="remove row" href="#" id="btmRemove" class="button"> <span>remove row</span> </a> </li> <li> <a title="undo last" href="#" id="btmRollBack" class="button disabled"> <span>undo last</span> </a> </li> <li class="last"> <a title="accept row" href="#" id="btmAccept" class="button disabled"> <span>accept row</span> </a> </li> </ul> </div> <div id="param.list" class="gridclip"> <table id='param.list.tbl' class='grid modela' > <caption>Test Case Summary</caption> <col/><col/><col/> <thead> <tr> <th class='hl center first'> <input class='grid-select-all' type='checkbox' /> <th> <th scope='col'>Row</th> <th scope='col'>Parameter</th> <th scope='col' class='last'>Value</th> </tr> </thead> <tfoot> <tr> <th scope='row'>Total</th> <td colspan='3'>2 parameters as Test Case input</td> </tr> </tfoot> <tbody id='param.list.tbl.body'> <tr class='odd'> <td class='rowcheck center first'> <input value='param1###value1' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/> </td> <td class='id'>1</td> <td>param1</td> <td class='last'>value1</td> </tr> <tr class='even'> <td class='rowcheck center first'> <input value='param2###value2' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/> </td> <td class='id'>2</td> <td>param2</td> <td class='last'>value2</td> </tr> <tr class='odd'> <td class='rowcheck center first' /> <td class='id'><em>new</em></td> <td> <dl class='clsTable'> <dt> <input type='text' id='param' name='param' class='text paramInput' /> </dt> <dd> <span id='paramToggle' /> </dd> <div class='auto-complete' id='paramContainer' /> </dl> </td> <td class='last'> <dl class='clsTable'> <dt> <input type='text' id='value' name='value' class='text valueInput' /> </dt> </dl> </td> </tr> </tbody> </table> </div> </div> </div> <!-- tabcontrol --> </fieldset> <div class="submit-box"> <input type="submit" name="formRun" id="formRun" class="form-save" value="Execute" accesskey="x" title="Run: Press Alt + [Shift] + x" /> <input type="submit" name="formSave" id="formSave" value="Save" accesskey="s" title="Save: Press Alt + [Shift] + s" /> <input type="submit" name="formLoad" id="formLoad" value="Load" accesskey="l" title="Load: Press Alt + [Shift] + l" /> <input type="submit" name="formCancel" id="formCancel" class="form-cancel" value="Cancel" accesskey="c" title="Cancel: Press Alt + [Shift] + c" /> </div> </form> </div> </div> </div> </div> </div> </body> </html> As you can see the following is pretty much a duplicate: <tr class='odd'> <td class='rowcheck center first'> <input value='param1###value1' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/> </td> <td class='id'>1</td> <td>param1</td> <td class='last'>value1</td> </tr> <tr class='even'> <td class='rowcheck center first'> <input value='param2###value2' id='cb1' name='SelectedRows' class='grid-select-row' type='checkbox'/> </td> <td class='id'>2</td> <td>param2</td> <td class='last'>value2</td> </tr> The relevant part of my stuts-config.xml file is: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans> <form-bean name="TestCaseForm" type="com.blahblah.mycoolapp.forms.TestCaseForm" /> </form-beans> <action-mappings> <action path="/pages/SaveTestCase" name="TestCaseForm" type="org.springframework.web.struts.DelegatingActionProxy" scope="request"> </action> </action-mappings> <message-resources parameter="MessageResources" /> </struts-config> I also use spring 2.56 (The relevant part being): <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean name="/pages/SaveTestCase" class="com.blahblah.mycoolapp.actions.TestCaseBuilderSaveAction" /> </beans> My Java ActionForm class (from what I had learned off the net) is: package com.blahblah.mycoolapp.forms; import java.util.ArrayList; import java.util.List; import org.apache.struts.action.ActionForm; public class TestCaseForm extends ActionForm { private static final long serialVersionUID = 2352146257739099766L; private String scenario; private String ruleID; private String testCaseName; private List<String> SelectedRows = new ArrayList<String>() ; public String getScenario() { return scenario; } public void setScenario(String scenario) { this.scenario = scenario; } public String getRuleID() { return ruleID; } public void setRuleID(String ruleID) { this.ruleID = ruleID; } public String getTestCaseName() { return testCaseName; } public void setTestCaseName(String testCaseName) { this.testCaseName = testCaseName; } public List<String> getSelectedRows() { return SelectedRows; } public void setSelectedRows(int index, String value) { this.SelectedRows.add(value); } } The question is why do I get an empty SelectedRows in my TestCaseBuilderSave Action? Thanks all who have the patience to read such a long question... and (hopefully) thanks to all you potential saviors :)

    Read the article

  • shortest digest of a string

    - by meta
    [Description] Given a string of char type, find a shortest digest, which is defined as: a shortest sub-string which contains all the characters in the original string. [Example] A = "aaabedacd" B = "bedac" is the answer. [My solution] Define an integer table with 256 elements, which is used to record the occurring times for each kind of character in the current sub-string. Scan the whole string, statistic the total kinds of character in the given string by using the above table. Use two pointers, start, end, which are initially pointing to the start and (start + 1) of the given string. The current kinds of character is 1. Expand sub-string[start, end) at the end until it contains all kinds of character. Update the shortest digest if possible. Contract sub-string[start, end] at the start by one character each time, try to restore its digest property if necessary by step 4. The time cost is O(n), and the extra space cost is constant. Any better solution without extra space?

    Read the article

  • Custom ConfigurationSection: CallbackValidator called with empty string

    - by Paolo Tedesco
    I am writing a custom configuration section, and I would like to validate a configuration property with a callback, like in this example: using System; using System.Configuration; class CustomSection : ConfigurationSection { [ConfigurationProperty("stringValue", IsRequired = false)] [CallbackValidator(Type = typeof(CustomSection), CallbackMethodName = "ValidateString")] public string StringValue { get { return (string)this["stringValue"]; } set { this["stringValue"] = value; } } public static void ValidateString(object value) { if (string.IsNullOrEmpty((string)value)) { throw new ArgumentException("string must not be empty."); } } } class Program { static void Main(string[] args) { CustomSection cfg = (CustomSection)ConfigurationManager.GetSection("customSection"); Console.WriteLine(cfg.StringValue); } } And my App.config file looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="customSection" type="CustomSection, config-section"/> </configSections> <customSection stringValue="lorem ipsum"/> </configuration> My problem is that when the ValidateString function is called, the value parameter is always an empty string, and therefore the validation fails. If i just remove the validator, the string value is correctly initialized to the value in the configuration file. What am I missing? EDIT I discovered that actually the validation function is being called twice: the first time with the default value of the property, which is an empty string if nothing is specified, the second time with the real value read from the configuration file. Is there a way to modify this behavior?

    Read the article

  • Problem with writing a hexadecimal string

    - by quilby
    Here is my code /* gcc -c -Wall -g main.c gcc -g -lm -o main main.o */ #include <stdlib.h> #include <stdio.h> #include <string.h> void stringToHex(const char* string, char* hex) { int i = 0; for(i = 0; i < strlen(string)/2; i++) { printf("s%x", string[2*i]); //for debugging sprintf(&hex[i], "%x", string[2*i]); printf("h%x\n", hex[i]); //for debugging } } void writeHex(char* hex, int length, FILE* file, long position) { fseek(file, position, SEEK_SET); fwrite(hex, sizeof(char), length, file); } int main(int argc, char** argv) { FILE* pic = fopen("hi.bmp", "w+b"); const char* string = "f2"; char hex[strlen(string)/2]; stringToHex(string, hex); writeHex(hex, strlen(string)/2, pic, 0); fclose(pic); return 0; } I want it to save the hexadecimal number 0xf2 to a file (later I will have to write bigger/longer numbers though). The program prints out - s66h36 And when I use hexedit to view the file I see the number '36' in it. Why is my code not working? Thanks!

    Read the article

  • N-gram split function for string similarity comparison

    - by Michael
    As part of excersise to better understand F# which I am currently learning , I wrote function to split given string into n-grams. 1) I would like to receive feedback about my function : can this be written simpler or in more efficient way? 2) My overall goal is to write function that returns string similarity (on 0.0 .. 1.0 scale) based on n-gram similarity; Does this approach works well for short strings comparisons , or can this method reliably be used to compare large strings (like articles for example). 3) I am aware of the fact that n-gram comparisons ignore context of two strings. What method would you suggest to accomplish my goal? //s:string - target string to split into n-grams //n:int - n-gram size to split string into let ngram_split (s:string, n:int) = let ngram_count = s.Length - (s.Length % n) let ngram_list = List.init ngram_count (fun i -> if( i + n >= s.Length ) then s.Substring(i,s.Length - i) + String.init ((i + n) - s.Length) (fun i -> "#") else s.Substring(i,n) ) let ngram_array_unique = ngram_list |> Seq.ofList |> Seq.distinct |> Array.ofSeq //produce tuples of ngrams (ngram string,how much occurrences in original string) Seq.init ngram_array_unique.Length (fun i -> (ngram_array_unique.[i], ngram_list |> List.filter(fun item -> item = ngram_array_unique.[i]) |> List.length) )

    Read the article

  • lstrcpy not updating passed in string

    - by Rorschach
    I'm trying to use kernel32.dll's lstrcpy to get a string from a pointer in C#, but it isn't working. lstrlenA IS working, it gives me the length of the string, so I'm hitting the kernel32.dll at least. lstrcpy is working in the VB6 app I'm converting, so I know it CAN work, but I don't have a clue why it isn't here. The string s never gets filled with the actual string, it just returns the initial padded string. [DllImport("kernel32.dll", EntryPoint = "lstrlenA", CharSet = CharSet.Ansi)] private static extern int lstrlen( int StringPointer ); [DllImport( "kernel32.dll",EntryPoint = "lstrcpyA", CharSet = CharSet.Ansi )] private static extern int lstrcpy(string lpString1, int StringPointer ); private static string StringFromPointer(int pointer) { //.....Get the length of the LPSTR int strLen = lstrlen(pointer); //.....Allocate the NewString to the right size string s = ""; for (int i = 0; i < strLen; i++) s += " "; //.....Copy the LPSTR to the VB string lstrcpy(s, pointer); return s; }

    Read the article

  • Converting Future Composer FC14 tracker music to MIDI data

    - by okw
    I have an old .FC music file from the Amiga/C64 days. It was made using Future Composer. The first four bytes of the file read as FC14 in ASCII; I'm pretty sure that's the version number. I need to dump the channels and their notes into a standard MIDI file in order to play it through my MIDI devices. Is there a way to do this with existing programs? If not, are there any specifications available on the format of these files? I do not require the samples, and I am aware that they will be lost during the conversion process.

    Read the article

  • In SSIS Convert European Currency Format to United States Currency Format

    - by Rob
    I have an interesting problem. I have an SSIS package that processes account data. We are now processing files from Europe. These files are in a CSV format using text qualifiers. For an example of the problem: In the United States the currency format is 123456.99 (We purposely leave the thousands separator out). The files sent from Europe are coming in with two formats. One is 123456,99 and the other is 123.456,00. SSIS is attempting to parse the text file and place it into a NUMERIC(20,2) field. This causes a parsing error in SSIS even with the text qualifiers. If I change the field to CURRENCY it sends a conversion error. I would like for SSIS to deal with this directly without requiring the data to be in the United States format. Has anyone had this problem? Any help will be greatly appreciated. Rob

    Read the article

  • How to convert series of MP3 to a M4B in a batch

    - by Artem Tikhomirov
    Hello. I have a batch of MP3 based books. Some of them divide into files according to book's own structure: chapters and so on. Some of them was just divided into equally lengthened parts. So. I've bought an iPhone, and I want to convert them all to M4B format. How could I convert them in a batch? I mean how cold I set up a process once, for each book, and then, after couple of weeks, receive totally converted library. The only able program for such conversion I've found was Audiobook Builder for a Mac. But it is pretty slow and do not support batching in principle. Solutions for any platform, please.

    Read the article

  • .vob to h.264 MP4 Files - Worth The Effort?

    - by harper89
    When I was doing the converting to digital format a while back I chose .VOB due to no quality loss. However recently I have been informed of this h.264 compression method. Time is not an issue here, I don't mind waiting for conversions etc. I also understand that any sort of compression will reduce quality. To test I converted a 4GB .VOB to a .mp4 using h264 in handbrake and the quality loss was very very very hard to notice. From what I have understood through research Space = .mp4(h.264) Quality = .Vob Playback = Both equally supported? But these concerns have yet to be answered: My comparison was done on a computer monitor, would the quality loss be substantially noticable if I purchased a 50 inch TV in the future? Is this type of file highly supported? (I don't want to experience incompatible players) What other issues could a conversion of files such as this cause in the future?

    Read the article

  • How to convert series of MP3 to a M4B in a batch

    - by Artem Tikhomirov
    I have a batch of MP3 based books. Some of them divide into files according to book's own structure: chapters and so on. Some of them was just divided into equally lengthened parts. So. I've bought an iPhone, and I want to convert them all to M4B format. How could I convert them in a batch? I mean how cold I set up a process once, for each book, and then, after couple of weeks, receive totally converted library. The only able program for such conversion I've found was Audiobook Builder for a Mac. But it is pretty slow and do not support batching in principle. Solutions for any platform, please.

    Read the article

  • How do I convert an animated GIF to a YouTube friendly video format?

    - by Dave Webb
    My son has made some animations with Pivot Stickfigure Animator which we'd like to upload to YouTube. The problem is Pivot saves as animated GIFs which I can't upload to YouTube. The Wikipedia article recommends using Windows Movie Maker to convert GIF to WMV, but unfortunatley I'm using Window 7 for which you can get the new Windows Live Movie Maker which doesn't seem to support GIFs. I Googled and found an article which said to use Beneton Movie GIF to convert animated GIF to AVI, but this seemed to rely on a 3rd Party application which wasn't installed and so failed. Installing the missing application - pjBmp2Avi - by hand and adding it to the path still didn't allow Beneton to do the conversion. I hoped FFmpeg might do the trick but this only outputs to animated GIFs, it won't read from then. Further Googling found lots of applications with 30 day trials and so on but I was hoping for something free. So any suggestions on how I can convert an animated GIF to a movie file on Windows using free (as in beer) software?

    Read the article

  • How do I convert an animated GIF to a YouTube friendly video format?

    - by Dave Webb
    My son has made some animations with Pivot Stickfigure Animator which we'd like to upload to YouTube. The problem is Pivot saves as animated GIFs which I can't upload to YouTube. The Wikipedia article recommends using Windows Movie Maker to convert GIF to WMV, but unfortunately I'm using Windows 7 for which you can get the new Windows Live Movie Maker which doesn't seem to support GIFs. I Googled and found an article which said to use Beneton Movie GIF to convert animated GIF to AVI, but this seemed to rely on a 3rd Party application which wasn't installed and so failed. Installing the missing application - pjBmp2Avi - by hand and adding it to the path still didn't allow Beneton to do the conversion. I hoped FFmpeg might do the trick but this only outputs to animated GIFs, it won't read from then. Further Googling found lots of applications with 30 day trials and so on but I was hoping for something free. So any suggestions on how I can convert an animated GIF to a movie file on Windows using free (as in beer) software?

    Read the article

  • Video converters don't work anymore after reinstalling Windows

    - by tassiekev
    A few days ago, I decided to reinstall Windows 7 as my HD partition seemed to be nearly full and things were slowing down. I'd been using Handbrake almost exclusively to convert TV recordings and used Freemake on occasion. Following the reinstall, I can't get either to work: Handbrake says it's encoding for about 2 seconds and then says it's finished, but there are no converted files of any size. Freemake just says 'Conversion Error' and won't go any further. As an experiment I tried two programs that I don't normally use, VideoReDo & Any Video Converter. Both worked fine. Anyone got any clues?

    Read the article

  • PDF to HTML - batch converter - most reliable and accurate free AND paid for software?

    - by Rob
    I'm look for either a free or paid-for (about 50$/40pounds) BATCH PDF to HTML converter to convert several PDF files at once. Needs to be able to handle vectored and bitmap images within the file, outputting both as jpegs referenced by the html pages. I've tried iorigsoft paid-for PDF to HTML - problems it seems to hang or just go idle, and the stuff it actually converts have broken links - the wrong name is used for constituent chapters as html. Also tried application from intrapdf.com but this crashes near the beginning of the conversion, consitently. Looked at opensource tools but they look equally flakey or use old PDF versions. Need it on Windows 7 32bit home. Thoughts?

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >