Search Results

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

Page 173/1488 | < Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >

  • How to evaluate text strings provided by sed/grep/whatever?

    - by T.J.
    This is for UNIX shell programming. It have to be supported by multiple UNIX platforms including Solaris, Linux, and AIX. I have this scenario -- I am to read from a text file a string that may or may not contain an environment variable that may or may not be defined. For example: <foo.bar> This error code was found: $(error_code) I have the following code: statement=$(sed -n $1'p' $messagefile) echo $echo_flag $statement $1 = line number supplied to this particular function/script. $messagefile = filename of log file. $echo_flag = "-e" in Linux, otherwise, empty. $(error_code) = 42. Instead of getting this when running: <foo.bar> This error code was found: 42 I still get this: <foo.bar> This error code was found: $(error_code) How exactly do I tell the shell script that the value of statement should be evaluated further beyond what sed have done?

    Read the article

  • Comparison question string vs int

    - by Mike
    Can someone explain to me why these comparisons work they way the do. I had a bug in one of my scripts that took me a little bit to work through. I was using read-host and typing a number. It was storing it as a string. Write-Host "(`'2`' -gt 9 ) = " ('2' -gt 9 ) Write-Host "(2 -gt 9 ) = " (2 -gt 9 ) Write-Host "(`'2`' -gt 10 ) = " ('2' -gt 10 ) If you are comparing a string to an Int does it use the Ascii value? If so why does the first one show $false, it should be $true. Then how is it when you chage it to an int of 10 it because $true.

    Read the article

  • C string program

    - by mrblippy
    Hi, i have been given a task to do ar school that must read three strings in, store the third string in dynamically allocated memory and print out the last 4 letters of the first word alphabetically. Here is the program i have so far but the strings are all stored in different variables, making them hard to sort. if anyone could give me a hand and help me finish this program i would be very grateful. thanks #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char word1[101]; char word2[101]; char* word3; char buffer[101]; scanf("%s", word1); scanf("%s", word2); scanf("%s", buffer); word3 = (char *) malloc(strlen(buffer)+1); strcpy(word3, buffer); return 0; }

    Read the article

  • Call load using a div id that has been passed into a function, div id is a parameter

    - by tittatty
    I am dynamically creating divs within a jquery accordion that are loaded with data as when the user clicks on the accordion title. I have this all working except that when I pass the div id into the load details method, the call to .load() does not work. What can I do to fix this? It seems like a simple javascript string eval would work but I can not find what I am looking for. Code: Here is the basic function: function loadDetails(div_id) { var load_string = "ajax/get_details.aspx"; $(div_id).load(load_string); } This function is called correctly on the click event and the div_id is passed in correctly but the load function is not working. If I use code like this it work correctly: $('#test').load(load_string);

    Read the article

  • Ruby Methods: return an usage string when insufficient arguments are given

    - by Shyam
    Hi, After creating a serious bunch of classes, with initialize methods, loading them in IRb requires to look back at the code. However, I think it should be easy enough to return a usage message, instead of: ArgumentError: wrong number of arguments (0 for 9) So I prefer to return a string with the human readable arguments, by example using "puts" or just a return of a string. Now I have seen the rescue keyword inside begin-end code, but I wonder how I could catch the ArgumentError when the initialize method is called. Thank you for your answers, feedback and comments!

    Read the article

  • Data Validation for Random varying Phone Numbers

    - by baron
    I am storing phone numbers of varying lengths in my WPF (C#, VS 08) App. I store them as strings. My question is about my method AddNewPhoneNo(string phoneNo). In this method, I use Int.TryParse to validate the incoming number (i.e. not null, is numeric...). I've since realized this is probably not the best way to do this, because then I am limited to a number which is ± 2147483647. Definetly this is not always the case with phone numbers. What is a good, easy way to validate phone numbers? I guess the basic rules would be as follows: All numeric All positive Upto 25 chars (could be more, but this will to do for time being) Can't thing if theres any more rules at the moment, that's probably it.

    Read the article

  • Returning different data types C#

    - by user1810659
    i have create a class library (DLL) with many different methods. and the return different types of data(string string[] double double[]). Therefore i have created one class i called CustomDataType for all the methods containing different data types so each method in the Library can return object of the custom class and this way be able to return multiple data types I have done it like this: public class CustomDataType { public double Value; public string Timestamp; public string Description; public string Unit; // special for GetparamterInfo public string OpcItemUrl; public string Source; public double Gain; public double Offset; public string ParameterName; public int ParameterID; public double[] arrayOfValue; public string[] arrayOfTimestamp; // public string[] arrayOfParameterName; public string[] arrayOfUnit; public string[] arrayOfDescription; public int[] arrayOfParameterID; public string[] arrayOfItemUrl; public string[] arrayOfSource; public string[] arrayOfModBusRegister; public string[] arrayOfGain; public string[] arrayOfOffset; } The Library contains methods like these: public CustomDataType GetDeviceParameters(string deviceName) { ...................... code getDeviceParametersObj.arrayOfParameterName; return getDeviceParametersObj; } public CustomDataType GetMaxMin(string parameterName, string period, string maxMin) { .....................................code getMaxMingObj.Value = (double)reader["MaxMinValue"]; getMaxMingObj.Timestamp = reader["MeasurementDateTime"].ToString(); getMaxMingObj.Unit = reader["Unit"].ToString(); getMaxMingObj.Description = reader["Description"].ToString(); return getMaxMingObj; } public CustomDataType GetSelectedMaxMinData(string[] parameterName, string period, string mode) {................................code selectedMaxMinObj.arrayOfValue = MaxMinvalueList.ToArray(); selectedMaxMinObj.arrayOfTimestamp = MaxMintimeStampList.ToArray(); selectedMaxMinObj.arrayOfDescription = MaxMindescriptionList.ToArray(); selectedMaxMinObj.arrayOfUnit = MaxMinunitList.ToArray(); return selectedMaxMinObj; } As illustrated thi different methods returns different data types,and it works fine for me but when i import the DLL and want to use the methods Visual studio shwos all the data types in the CustomDataType class as suggestion for all the methods even though the return different data.This is illusrtated in the picture below. As we can see from the picture with the suggestion of all the different return data the user can get confused and choose wrong return data for some of the methods. So my question is how can i improve this. so Visual studio suggest just the belonging return data type for each method.

    Read the article

  • Using nsIZipWriter or other to compress a string as a string?

    - by Daniel
    I need to be able to take a javascript string, compress it using any fast and available means and get back a binary string/blob. Background: The extension I'm developing needs to send various large content to my server. It does this conveniently by dynamically creating a form, adding fields to the form and posting it. Some of these fields are just too big bandwidth wise for multiple use. I'd like to be able to compress them before adding them and then maybe base64'ing them if the characters cause a problem in the message. Any ideas? I could use nsiZipWriter with temporary files on disk but that is quite ugly and probably sluggish.

    Read the article

  • Tokenizing a string with variable whitespace

    - by Ron Holcomb
    I've read through a few threads detailing how to tokenize strings, but I'm apparently too thick to adapt their suggestions and solutions into my program. What I'm attempting to do is tokenize each line from a large (5k+) line file into two strings. Here's a sample of the lines: 0 -0.11639404 9.0702948e-05 0.00012207031 0.0001814059 0.051849365 0.00027210884 0.062103271 0.00036281179 0.034423828 0.00045351474 0.035125732 The difference I'm finding between my lines and the other sample input from other threads is that I have a variable amount of whitespace between the parts that I want to tokenize. Anyways, here's my attempt at tokenizing: #include <iostream> #include <iomanip> #include <fstream> #include <string> using namespace std; int main(int argc, char *argv[]) { ifstream input; ofstream output; string temp2; string temp3; input.open(argv[1]); output.open(argv[2]); if (input.is_open()) { while (!input.eof()) { getline(input, temp2, ' '); while (!isspace(temp2[0])) getline(input, temp2, ' '); getline (input, temp3, '\n'); } input.close(); cout << temp2 << endl; cout << temp3 << endl; return 0; } I've clipped it some, since the troublesome bits are here. The issue that I'm having is that temp2 never seems to catch a value. Ideally, it should get populated with the first column of numbers, but it doesn't. Instead, it is blank, and temp3 is populated with the entire line. Unfortunately, in my course we haven't learned about vectors, so I'm not quite sure how to implement them in the other solutions for this I've seen, and I'd like to not just copy-paste code for assignments to get things work without actually understanding it. So, what's the extremely obvious/already been answered/simple solution I'm missing? I'd like to stick to standard libraries that g++ uses if at all possible.

    Read the article

  • Flexible string handling in Visual Studio 2008 C++

    - by David
    I'm slowly starting to get the hang of the _T stuff in Visual Studio 2008 c++, but a few things still elude me. I can see the benefit of the flexibility, but if I can't get the basics soon, I think I'll go back to the standard way of doing this - much less confusing. The idea with the code below is that it scans the parameters for -d and then stores the text that follows that in the string variable fileDir. It also ignores any other parameters. Any help is appreciated. //Console application Parameters::Parameters(int argc, _TCHAR* argv[]) { _Tstring fileDir; // Is there some kind of _t variable to use here for a string? for (int i = 0; i < argc; i = i + 1) { if (_tccmp(argv[i], _T("-d")) == 0) // this appeared to accept anything starting with - { i = i + 1; fileDir = argv[i] } } _tprintf("Parameter value found: %s\n", fileDir); }

    Read the article

  • how to convert the html tags and get a message in string

    - by Ranjana
    how to convert the html tags to the msg bodg in mail function. i.e i have   Company Name: BPL   Industry Type:   i have got the string as datatable dt=new datatable(); string msg= dt.rows[i]["Message"].tostring(); i need to convert this html tags to the exact message; if (boolcheck) { msg.Body = ????????? wat to use over here.... how to remove the html tags and get the exact message } pls help??????????/

    Read the article

  • int[] to string c#

    - by Robin Webdev
    Hi I'm developing an client application in C# and the server is written in c++ the server uses: inline void StrToInts(int *pInts, int Num, const char *pStr) { int Index = 0; while(Num) { char aBuf[4] = {0,0,0,0}; for(int c = 0; c < 4 && pStr[Index]; c++, Index++) aBuf[c] = pStr[Index]; *pInts = ((aBuf[0]+128)<<24)|((aBuf[1]+128)<<16)|((aBuf[2]+128)<<8)|(aBuf[3]+128); pInts++; Num--; } // null terminate pInts[-1] &= 0xffffff00; } to convert an string to int[] in my c# client i recieve: int[4] { -14240, -12938, -16988, -8832 } How do I convert the array back to an string? I don't want to use unsafe code (e.g. pointers) Any of my tries resulted in unreadable strings.

    Read the article

  • std::out_of_range error?

    - by vette982
    I'm dealing with a file with a linked list of lines with each node looking like this: struct TextLine{ //The actual text string text; //The line number of the document int line_num; //A pointer to the next line TextLine * next; }; and I'm writing a function that adds spaces at the beginning of the lines found in the variable text, by calling functions like linelist_ptr->text.insert(0,1,'\t'); The program compiles, but when I run it I get this error: terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at Aborted Any ideas?

    Read the article

  • Edit strings vars in compiled exe? C++ win32

    - by extintor
    I want to have a few strings in my c++ app and I want to be able to edit them later in the deployed applications (the compiled exe), Is there a way to make the exe edit itself or it resources so I can update the strings value? The app checks for updates on start, so I'm thinking about using that to algo send the command when I need to edit the strings (for example the string that contains the url used to check for updates). I don't want to use anything external to the exe, I could simply use the registry but I prefer to keep everything inside the exe. I am using visual studio 2010 c++ (or any other version of ms visual c++).

    Read the article

  • Problem with pointer copy in C

    - by Stefano Salati
    I radically re-edited the question to explain better my application, as the xample I made up wasn't correct in many ways as you pointed out: I have one pointer to char and I want to copy it to another pointer and then add a NULL character at the end (in my real application, the first string is a const, so I cannot jsut modify it, that's why I need to copy it). I have this function, "MLSLSerialWriteBurst" which I have to fill with some code adapt to my microcontroller. tMLError MLSLSerialWriteBurst( unsigned char slaveAddr, unsigned char registerAddr, unsigned short length, const unsigned char *data ) { unsigned char *tmp_data; tmp_data = data; *(tmp_data+length) = NULL; // this function takes a tmp_data which is a char* terminated with a NULL character ('\0') if(EEPageWrite2(slaveAddr,registerAddr,tmp_data)==0) return ML_SUCCESS; else return ML_ERROR; } I see there's a problem here: tha fact that I do not initialize tmp_data, but I cannot know it's length.

    Read the article

  • Reading Connection String from a class Library

    - by devnet247
    Hi all I have a .net class library 2.0 with an app.config with a connectionString section. I have 01 Method that this class library exposes " string GetConnectionString(string name) However even though the app.config in this class library has 3 connstrings it does not read this config.exe.How can I make it read the app.config that resides withing this dll? Again, Usually you will have a web or windows app with a config and it will all work. Mine is a special case I need to read the connectionstring within this class library. How can I do it? thanks a lot

    Read the article

  • Excel I have a .Net object compiled as a tlb but cant not access any methods apart from Dispose.

    - by Mark O'Grady
    Hi This is ongoing issue to something I posted yesterday. I have a .net object that I want to use in Excel. I have an existing VBA script that i need to alter to call this the object from. I have then converted the object to a TLB. I've not really touched on this area before so any help will be appreciated. I have created an interface [Guid("0F700B48-E0CA-446b-B87E-555BCC317D74"),InterfaceType(ComInterfaceType.InterfaceIsDual)] [ComVisible(true)] public interface IOfficeCOMInterface { [DispId(1)] void ResetOrder(); [DispId(2)] void SetDeliveryAddress(string PostalName, string AddressLine1, string AddressLine2, string AddressLine3, string AddressLine4, string PostCode, string CountryCode, string TelephoneNo, string FaxNo, string EmailAddress); } I have also created an class that inherits that object. [ClassInterface(ClassInterfaceType.None), ProgId("NAMESPACE.OfficeCOMInterface"), Guid("9D9723F9-8CF1-4834-BE69-C3FEAAAAB530"), ComVisible(true)] public class OfficeCOMInterface : IOfficeCOMInterface, IDisposable { public void ResetSOPOrder() { } public void SetDeliveryAddress(string PostalName, string AddressLine1, string AddressLine2, string AddressLine3, string AddressLine4, string PostCode, string CountryCode, string TelephoneNo, string FaxNo, string EmailAddress) { try { SalesOrder.AmendDeliveryAddress(PostalName, AddressLine1, AddressLine2, AddressLine3, AddressLine4, PostCode); MessageBox.Show("Delivery address set"); } catch (Exception ex) { throw ex; } } } I can't access the object methods apart from dispose, I guess IDisposable is working fine. Is there anything I need to my Interface?

    Read the article

  • using AutoCompleteTextField in wicket without String as the generic type

    - by Manuel
    Hi! This question follows this: handling to onchange event of AutoCompleteTextField in wicket I'm trying to use the AutoCompleteTextField with a custom class as the generic type, and to add an AjaxFormComponentUpdatingBehavior. What I mean is I want to have a AutoCompleteTextField<SomeClass> myAutoComplete = ...; and after that add a AjaxFormComponentUpdatingBehavior: myAutoComplete.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println( "Value: "+getValue() ); } }); The problem is that for some reason, adding that behavior makes the form try to set the model object with a String (even though the AutoCompleteTextField has a generic type of SomeClass), causing a ClassCastException when the onchange event fires. Is there a way to use AutoCompleteTextField without it being AutoCompleteTextField<String>? I couldn't find any example. Thanks for your time! and thanks to the user biziclop for his help in this matter.

    Read the article

  • Storing a big xml string in a xml document in java

    - by shyam R
    Hi All, I Have a Java object which I am converting into a xml file. I am getting a big xml file here after converting java object. I am capturing that converted xml file in a string like below String ouputXML = xmlfile; Noe If I pring the ouputXML on the console of IBM RSA in the proper format only it is printing but my requirement is I need to redirect outputXML in to an XML instead of printing in IBm RSA console. I am able to do this but the problem is if I open the craetd XML file the xml structure is not proper , it is showing so many special characters . Please help me !!

    Read the article

  • Help with algorithm to determine phrase occurrence in string in PHP

    - by Will M.
    I have an array of phrases (max 2 words) like $words = array('barack obama', 'chicago', 'united states'); and then I have a string like: $sentence = "Barack Obama is from Chicago. Barack Obama's favorite food it pizza."; I want to find/create an efficient algorithm that would return the number of occurrences of the words in the array $words in the string $sentence. In this case it would be: 'barack obama' => 2 'chicago' => 0 How can I built this?

    Read the article

  • String translation to Portuguese

    - by xrx215
    I wanted to translate strings groupbytext, show in groups in the column menu of a grid panel. In ext-lang-pt.js the string are not included. wheres as in other languages thse string are included. These strings are in cluded in ext-lang-pt_PT.js. what is the difference between ext-lang-pt.js and ext-lang-pt_PT.js. Do I have to include the file ext-lang-pt_PT.js in order to translate the strings in portugese? Please let me know

    Read the article

< Previous Page | 169 170 171 172 173 174 175 176 177 178 179 180  | Next Page >