Search Results

Search found 19539 results on 782 pages for 'pretty print'.

Page 92/782 | < Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >

  • PHP5: restrict access to function to certain classes

    - by Tim
    Is there a way in PHP5 to only allow a certain class or set of classes to call a particular function? For example, let's say I have three classes ("Foo", "Bar", and "Baz"), all with similarly-named methods, and I want Bar to be able to call Foo::foo() but deny Baz the ability to make that call: class Foo { static function foo() { print "foo"; } } class Bar { static function bar() { Foo::foo(); print "bar"; } // Should work } class Baz { static function baz() { Foo::foo; print "baz"; } // Should fail } Foo::foo(); // Should also fail There's not necessarily inheritance between Foo, Bar, and Baz, so the use of protected or similar modifiers won't help; however, the methods aren't necessarily static (I made them so here for the simplicity of the example).

    Read the article

  • How is inheritance implemented at the memory level?

    - by cambr
    Suppose I have class A { public: void print(){cout<<"A"; }}; class B: public A { public: void print(){cout<<"B"; }}; class C: public C { }; How is inheritance implemented at the memory level? Does C copy print() code to itself or does it have a pointer to the it that points somewhere in A part of the code? How does the same thing happen when we override the previous definition, for example in B (at the memory level)?

    Read the article

  • What is the equivalent of PHP's $_POST in a Perl CGI script and how can I use it?

    - by dexter
    I have two Perl files: action.pl and the other is test.pl action.pl has a form: print $cgi->header, <<html; <form action="test.pl" method="post"> html while (my @row = $sth->fetchrow) { print $cgi->header, <<html; ID:<input name="pid" value="@row[0]" readonly="true"/><br/> Name: <input name="pname" value="@row[1]"/><br/> Description : <input name="pdescription" value="@row[2]"/><br/> Unit Price :<input name="punitprice" value="@row[3]"/><br/> html } print $cgi->header, <<html <input type="submit" value="update Row"> </form> html What should I write in test.pl so as to access the form values submitted by the user? In other words, what equivalent of PHP's $_POST['pid'] in Perl?

    Read the article

  • TSQL - compare tables

    - by Rya
    I want to create a stored procedure that compares the results of two queries. If the results of the 2nd table can be found in the first, print 'YES', otherwise, print 'No'. Table 1: SELECT dbo.Roles.RoleName, dbo.UserRoles.RoleID FROM dbo.Roles LEFT OUTER JOIN dbo.UserRoles ON dbo.Roles.RoleID = dbo.UserRoles.RoleID WHERE (dbo.Roles.PortalID = 0) AND (dbo.UserRoles.UserID = 2) Table 2: Declare @RowData as nvarchar(2000) Set @RowData = ( SELECT EditPermissions FROM vw_XMP_DMS_Documents where DocumentID = 2) Select Data from dbo.split(@RowData, ',') For example. Table 1: John Jack James Table 2: John Sally Jane Print 'YES' Is this possible??? Thank you all very much. -R

    Read the article

  • Creating a Non-Databound Report in Winforms

    - by Jon
    I am using Visual Studio 2008 and all the components that come with it as well as Infragisitics for Winforms. I need to design a label that will print to a label printer. None of the controls are databound and will most likely be set in code eg/Label.Text = "My Heading"; as there will be minimal information on the label. One piece of information is a barcode so I need the functionality to do that, I assume I can just set the font of the label to barcode and it will do its thing. Can I just add a Crystal Report to a form design it, set the label text properties in code, tell it what printer to print to and then call report.Print(); I've had a quick go and seems not as easy as I thought. Thanks

    Read the article

  • Python code, extracting extensions

    - by user1434001
    import os path = '/Users/Marjan/Documents/Nothing/Costco' print path names = os.listdir(path) print len(names) for name in names: print name Here is the code I've been using, it lists all the names in this category in terminal. There are a few filenames in this file (Costco) that don't have .html and _files. I need to pick them out, the only issue is that it has over 2,500 filenames. Need help on a code that will search through this path and pick out all the filenames that don't end with .html or _files. Thanks guys

    Read the article

  • SQL server db and printing confusion.

    - by RAJ K
    I have billing application based on C# WPF, Screenshot is here. as you can see there is a datagrid, programmatically binded. this datagrid contains lists of item going to be billed. So when user reaches "Print memo" part (in stack panel 2) i have to update listed items in stock table and insert entries in sales table and finally print the memo. I want to know is there any speedy way to so because as user gives print command I have to clear datagrid which holds product lists and start accepting new lists. if you could provide few code or link, will be really helpful.. thanks.........

    Read the article

  • breaking the look in jython

    - by kdev
    Hi everyone , I have a written a loop for and if condition and i want to break to loop completely when if gets satisfied. while count: i=0 for line in read_record: #print str.strip(count[1:28]) #print str.strip(read_record[i]) if string.find(str.strip(read_record[i]),str.strip(count[1:28]))>0: code=str.strip(read_record[i+19])+str.strip(read_record[i+20]) print code[25:] break i=i+1 so here if the if string.find condition gets satified i want to go to while loop flow. Please tell me what will be the best place to break and how should i modify the program so that once the if condition is satified iam out of the loop and start again with while loop .

    Read the article

  • Scrolling Panel Printing Issue

    - by Paul
    Hi I have a site where we have the content in scrolling panels to make it neater and line up. The issue comes when trying to print the contents of my panel hidden by the scroll. Here is my panel <asp:Panel Height="400px" ID="pnlContent" class="ContentPanel ScrollBars="Vertical" runat="server" > <!-- Content bla bla bla --> </asp:Panel> Here is my media="print" style sheet code for the ContentPanel .ContentScroller { overflow:visible; } The overflow:visible does not seem to remover the ScrollBars="Vertical" Any ideas on how to get this hidden content to print?

    Read the article

  • python [lxml] - cleaning out html tags

    - by sadhu_
    from lxml.html.clean import clean_html, Cleaner def clean(text): try: cleaner = Cleaner(scripts=True, embedded=True, meta=True, page_structure=True, links=True, style=True, remove_tags = ['a', 'li', 'td']) print (len(cleaner.clean_html(text))- len(text)) return cleaner.clean_html(text) except: print 'Error in clean_html' print sys.exc_info() return text I put together the above (ugly) code as my initial forays into python land. I'm trying to use lxml cleaner to clean out a couple of html pages, so in the end i am just left with the text and nothing else - but try as i might, the above doesnt appear to work as such, i'm still left with a substial amount of markup (and it doesnt appear to be broken html), and particularly links, which aren't getting removed, despite the args i use in remove_tags and links=True any idea whats going on, perhaps im barking up the wrong tree with lxml ? i thought this was the way to go with html parsing in python?

    Read the article

  • Python - open text file, but specify name when executing command

    - by Dunnolol
    I have a directory of text files that all end in the extension .txt My goal is to print the contents of the text file. I wish to be able use the wildcard *.txt to be able to specific the text file name I wish to open (I'm thinking along the lines of something like "F:\text*.txt" ?), split the lines of the text file, then print the output. Here is an example of what I want to do, but I want to be able to change "somefile" when executing my command. f = open('F:\text\somefile.txt', 'r') for line in f: print line,

    Read the article

  • Does this language feature already exist?

    - by Pindatjuh
    I'm currently developing a new language for programming in a continuous environment (compare it to electrical engineering), and I've got some ideas on a certain language construction. Let me explain the feature by explanation and then by definition: x = a U b; Where x is a variable and a and b are other variables (or static values). This works like a union between a and b; no duplicates and no specific order. with(x) { // regular 'with' usage; using the global interpretation of "x" x = 5; // will replace the original definition of "x = a U b;" } with(x = a) { // this code block is executed when the "x" variable // has the "a" variable assigned. All references in // this code-block to "x" are references to "a". So saying: x = 5; // would only change the variable "a". If the variable "a" // later on changes, x still equals to 5, in this fashion: // 'x = a U b U 5;' // '[currentscope] = 5;' // thus, 'a = 5;' } with(x = b) { // same but with "b" } with(x != a) { // here the "x" variable refers to any variable // but "a"; thus saying x = 5; // is equal to the rewriting of // 'x = a U b U 5;' // 'b = 5;' (since it was the scope of this block) } with(x = (a U b)) { // guaranteed that "x" is 'a U b'; interacting with "x" // will interact with both "a" and "b". x = 5; // makes both "a" and "b" equal to 5; also the "x" variable // is updated to contain: // 'x = a U b U 5;' // '[currentscope] = 5;' // 'a U b = 5;' // and thus: 'a = 5; b = 5;'. } // etc. In the above, all code-blocks are executed, but the "scope" changes in each block how x is interpreted. In the first block, x is guaranteed to be a: thus interacting with x inside that block will interact on a. The second and the third code-block are only equal in this situation (because not a: then there only remains b). The last block guarantees that x is at least a or b. Further more; U is not the "bitwise or operator", but I've called it the "and/or"-operator. Its definition is: "U" = "and" U "or" (On my blog, http://cplang.wordpress.com/2009/12/19/binop-and-or/, there is more (mathematical) background information on this operator. It's loosely based on sets. Using different syntax, changed it in this question.) Update: more examples. print = "Hello world!" U "How are you?"; // this will print // both values, but the // order doesn't matter. // 'userkey' is a variable containing a key. with(userkey = "a") { print = userkey; // will only print "a". } with(userkey = ("shift" U "a")) { // pressed both "shift" and the "a" key. print = userkey; // will "print" shift and "a", even // if the user also pressed "ctrl": // the interpretation of "userkey" is changed, // such that it only contains the matched cases. } with((userkey = "shift") U (userkey = "a")) { // same as if-statement above this one, showing the distributivity. } x = 5 U 6 U 7; y = x + x; // will be: // y = (5 U 6 U 7) + (5 U 6 U 7) // = 10 U 11 U 12 U 13 U 14 somewantedkey = "ctrl" U "alt" U "space" with(userkey = somewantedkey) { // must match all elements of "somewantedkey" // (distributed the Boolean equals operated) // thus only executed when all the defined keys are pressed } with(somewantedkey = userkey) { // matches only one of the provided "somewantedkey" // thus when only "space" is pressed, this block is executed. } Update2: more examples and some more context. with(x = (a U b)) { // this } // can be written as with((x = a) U (x = b)) { // this: changing the variable like x = 5; // will be rewritten as: // a = 5 and b = 5 } Some background information: I'm building a language which is "time-independent", like Java is "platform-independant". Everything stated in the language is "as is", and is continuously actively executed. This means; the programmer does not know in which order (unless explicitly stated using constructions) elements are, nor when statements are executed. The language is completely separated from the "time"-concept, i.e. it's continuously executed: with(a < 5) { a++; } // this is a loop-structure; // how and when it's executed isn't known however. with(a) { // everytime the "a" variable changes, this code-block is executed. b = 4; with(b < 3) { // runs only three times. } with(b > 0) { b = b - 1; // runs four times } } Update 3: After pondering on the type of this language feature; it closely resemblances Netbeans Platform's Lookup, where each "with"-statement a synchronized agent is, working on it's specific "filter" of objects. Instead of type-based, this is variable-based (fundamentally quite the same; just a different way of identifiying objects). I greatly thank all of you for providing me with very insightful information and links/hints to great topics I can research. Thanks. I do not know if this construction already exists, so that's my question: does this language feature already exist?

    Read the article

  • Loop through collections

    - by ScG
    I have two classes class A { public string something { get; set; } public IList<B> b= new List<B>(); } class B { public string else { get; set; } public string elseelse { get; set; } } I have populated an object of class A called obj. How can I loop through this object and print values. Do I have to use two foreach's like the one show here or is there a better way? foreach (var z in obj) { // print z.something; foreach (var x in z.b) { // print x.elseelse; } }

    Read the article

  • How to get a list of users for all instance's databases

    - by stee1rat
    I guess the procedure should be something like this: declare @db varchar(100) declare @user varchar(100) declare c cursor for select name from sys.sysdatabases open c fetch next from c into @db while @@fetch_status = 0 begin print @db exec ('use ' + @db) declare u cursor for select name from sys.sysusers where issqlrole <> 1 and hasdbaccess <> 0 and isntname <> 1 open u fetch next from u into @user while @@fetch_status = 0 begin print @user fetch next from u into @user end print '--------------------------------------------------' close u deallocate u fetch next from c into @db end close c deallocate c But the problem is that exec ('use ' + @db) doesn't work. And i always get user list of currently chosen database. How should i fix that? P.S.: I want this code to work on both 2000 and 2005 sql servers.

    Read the article

  • Why is the value of __name__ changing after assignment to sys.modules[__name__]?

    - by martineau
    While trying to do something similar to what's in the ActiveState recipe titled Constants in Python by Alex Martelli, I ran into an unexpected side-effect that assigning a class instance to an entry in sys.modules apparently has in Python 2.7 -- namely that doing so apparent changes the value of __name__ to None as illustrated in the following code fragment: class _test(object): pass import sys print '__name__: %r' % __name__ # __name__: '__main__' sys.modules[__name__] = _test() print '__name__: %r' % __name__ # __name__: None if __name__ == '__main__': # never executes... import test print "done" I'd like to understand why this is happening. I don't believe it was that way in Python 2.6 and earlier versions since I have some older code where apparently the if __name__ == '__main__': conditional worked as expected following the assignment (but no longer does). FWIW, I also noticed that the name _class is getting rebound from a class object to None, too, after the assignment. Also seems odd to me that they're being rebound to 'None' rather than disappearing altogether... Update: I'd like to add that any workarounds for achieving the effect of if __name__ == '__main__':, given what happens would be greatly appreciated. TIA!

    Read the article

  • Javascript: why I cannot load my external js page in Drupal ?

    - by Patrick
    hi, when I add the tag script to load an external javascript file, my page is not longer displayed. There are not error in Firebug, there are not errors such as "File not found" or "Not enough permissions", the browser just displays a blank page for some reason. <?php print $head; ?> <?php print $styles; ?> <?php print $scripts; ?> <script type="text/JavaScript" src="main.js" /> If I remove the last line everything works perfectly. The previous php lines are the standard Drupal head lines. This is the content of my js file: $(document).ready( function() { alert("hello"); }); thanks

    Read the article

  • Deferred printing in Java

    - by Bober02
    I have a specific issue with general console printing and I was wondering whether anyone has a solution for it. I am trying to print a dataTable which would look like sth like this: Table ---------------------- Name |Surname | ---------------------- Mike |Mikhailowish| Rafaello|Mirena | and so on. In order to print the border of the bar I need to know what the maximum length of each column value is. I don't want to go through the whole database to find that out and then again to print it. I would rather like to do sth like: System.out.printLater(s); //herejust leave a pointer to a StringBuilder you will build ... s.append("--------"); ... System.out.printAllDeferred(); I understand the above is probably in 99.99999% chances impossible, but perhaps you guys have a clever way of achieving the above?

    Read the article

  • How to get "printer ready bytes" from a source in c#?

    - by luis_villase
    Hey everyone! I'm in a bit of trouble here, hoping you can help a fellow programmer out. I have an application that receives a pointer to raw bytes (plus length and stuff) and sends said raw data to a printer. This is important, I have no choice but to use this method to get any printing done. If I send a raw string, it will print with no problem. However, I need to be able to print formatted text, images, etc. So the thing is... I would like to be able to get printer ready bytes from a given source (maybe a pdf, or html, does not matter as long as it contains formatted text and/or images). It would be like "splitting" the print command like so: a) Open file and read data b) Load printer data into memory c) Send bytes to printer Obviously, I've got a) and c) covered, it's b) the one that's breaking my head. Any thoughts? Thanks in advance for your help.

    Read the article

  • What could cause a returning function to crash? C++

    - by JeanOTF
    So I have been debugging this error for hours now. I writing a program using Ogre3d relevant only because it doesn't load symbols so it doesn't let me stack trace which made finding the location of the crash even harder. So, write before I call a specific function I print out "Starting" then I call the function and immediately after I print "Stopping". Throughout the function I print out letters A-F where F is printed right before the function returns (one line above the last '}') The weird thing is when the crash occurs it is after the 'F' is printed but there is no 'Stopping'. Does this mean that the crash is happening in between somewhere? The only thing I can think of is something going wrong during the deallocation of some of the memory allocated during the function. I've never had anything happen like this, I will keep checking to make sure it's going wrong where I think it is.

    Read the article

  • Flattening hash into string in Ruby

    - by fahadsadah
    Is there a way to flatten a hash into a string, with optional delimiters between keys and values, and key/value pairs? For example, print {:a => :b, :c => :d}.flatten('=','&') should print a=b&c=d I wrote some code to do this, but I was wondering if there was a neater way: class Hash def flatten(keyvaldelimiter, entrydelimiter) string = "" self.each do |key, value| key = "#{entrydelimiter}#{key}" if string != "" #nasty hack string += "#{key}#{keyvaldelimiter}#{value}" end return string end end print {:a => :b, :c => :d}.flatten('=','&') #=> 'c=d&a=b' Thanks

    Read the article

  • How to convert ms access data into pdf in vb.net

    - by user225269
    I want to convert the ms access data into a document so that the print function in vb.net will read it. Where do I start from here? Here is my form: http://screencast.com/t/MGU4N2UyNmY And here is the code for print preview. Try PrintPreviewDialog1.ShowDialog() Catch es As Exception MessageBox.Show(es.Message) End Try How do I incorporate the above code, to the code below so that there is something that can be seen when I hit the print button? Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\search.mdb") Dim cmd As OleDbCommand = New OleDbCommand("Select * from GH where NAME= '" & TextBox6.Text & "' ", cn) cn.Open() Dim rdr As OleDbDataReader rdr = cmd.ExecuteReader If rdr.HasRows Then rdr.Read() NoAcc = rdr("NAME") If (TextBox6.Text = NoAcc) Then TextBox1.Text = rdr("IDNUMBER") If (TextBox6.Text = NoAcc) Then TextBox7.Text = rdr("DEPARTMENT") If (TextBox6.Text = NoAcc) Then TextBox8.Text = rdr("COURSE") End If Please help,thanks

    Read the article

  • how to make this piece of code work in C++?

    - by cambr
    #include<stdio.h> void print(int *arr[], int s1, int s2) { int i, j; printf("\n"); for(i = 0; i<s1; i++) { for(j = 0; j<s2; j++) { printf("%d, ", *((arr+i)+j)); } } printf("\n"); } int main() { int a[4][4] = {{0}}; print(a,4,4); } This works in C, but not in C++. error: cannot convert `int (*)[4]' to `int**' for argument `1' to `void print(int**, int, int)' Why does it not work in C++? What change is needed to be made?

    Read the article

  • Can't subtract in a for loop in C/Objective-C

    - by user1612935
    I'm going through the Big Nerd Ranch book on Objective-C, which takes you through some early C stuff. I've played with C before, and am pretty experienced in PHP. Anyhow, I'm doing the challenges and this one is not working the way I think it should. It's pretty simple - start at 99, loop through and subtract three until you get to zero, and every time you get a number that is divisible by 5 print "Found one." Pretty straightforward. However, subtracting by three in the for loop is not working #include <stdio.h> int main (int argc, const char * argv[]) { int i; for(i = 99; i > 0; i-3){ printf("%d\n", i); if(i % 5 == 0) { printf("Found one!\n"); } } return 0; } It creates and endless loop at 99, and I'm not sure why.

    Read the article

  • Output custom messages based on row value

    - by decimal
    I've made a simple guestbook mysql/php page. An entry is displayed if the approve column has a value of 1. For the adminstrator, I want to display either "message approved" or "not approved". Here's my code: while ($row = mysql_fetch_array ($r)) { print "<p>Guest:" .$row['name']. "</p> <p>Date:" .$row['date']. "</p> <p>Comment:". $row['comment']. "</p>"; if ($row['approve'] = '1') { print '<p>YES, the message has been approved</p>'; } else { print '<p>NO, it hasn\'t been approved</p>'; } Whatever value the if statement checks approve is equal to, all approve values are output as that value.

    Read the article

  • SqlAlchemy hangs after adding record in MS SQL

    - by Patrick
    I'm running SQLAlchemy on Jython and trying to connect to a MS SQL database using jTDS with windows authentication. I can query and delete just fine but when I try to insert new values it will hang when I commit. int 'before add' session.add(newVal) print 'after add' session.commit() print 'after commit' I see the first two print statements but not the last. My CPU maxes out and I can't even query the table directly using the MS SQL Management Studio. When I kill the Jython java process I can query again but the new values haven't been added. Strangely enough I can insert values directly using an SQL command: insert_sql = "INSERT INTO my_table (my_value) VALUES ('test_value')" session.execute(insert_sql) session.commit() Any ideas what I'm doing wrong?

    Read the article

< Previous Page | 88 89 90 91 92 93 94 95 96 97 98 99  | Next Page >