How do I start another program/application using c/c++, I want to start outlook express once my program has completed it task.

Paul M

Chacmool wrote:

You can access the button-info from the Sender-pointer like this:

AnsiString caption = ((TButton*)Sender)->Caption

Thanks for that it works fine, although I could not access the caption property so I used the objects name instead ie:

AnsiString caption = ((TButton*)Sender)->Name

PM

Chacmool wrote:

Yes it is possible... don't fully understand what you mean though...

If I had a function called add that required two integer arguments, and returned an integer, its prototype would look like this:

int add(int a, int b)

to call this function I would use the following syntax:

add(1, 2)

this would return 3

Now if I wanted to pass an argument to a function in Builder (Button1Click in this case) is it possible to pass an argument directly (as oppose to picking up values from elsewhere. the reason I want to do this is to avoid having to use Global scope variables.

I have now actually recoded my program differently and now require to determine the name of the Sender variable passed to the Button1Click function. ie was it initiated from a Button Click or called from another area of the program. I know this is possible but don't know how to do it. Any Help appreciated.

I am trying to run a function within C++ Builder when the user clicks a button. The function requires a pointer to a custom object as an argument. Is it possible to pass the argument to the button code.

ie: ThisRec is a pointer to an object how do I pass this as an argument to the button?

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  RefreshTable(ThisRec);
}

5

(4 replies, posted in Programming)

I have written some code myself that works fine, can anyone suggest any way of making it more efficient?

#define arrays
   @dwfs1 = ();
   @dwfs2 = ();
   @dwfs3 = ();
   
#read contents of directory into first array
   while ($_ = readdir(DH)){
      push(@dwfs1, $_);
   }
   close(DH);

#create a second array containing the old revisions
   foreach $item1(@dwfs1){
      @dwf1 = split(/_rev-/, $item1);
      $popped = 0;
      foreach $item2(@dwfs1){
         @dwf2 = split(/_rev-/, $item2);
         if ($dwf1[0] eq $dwf2[0] && $dwf1[1] lt $dwf2[1] && $popped == 0) {
            push(@dwfs2, $item1);
            $popped = 1;
         }
      }
   }
   
#store items unique (ie latest revs) in third array
   foreach $item1(@dwfs1){
      $match = 0;
      foreach $item2(@dwfs2){
         if($item1 eq $item2){
            $match = 1;
         }
      }
      if ($match == 0){
         push(@dwfs3, $item1);
      }
   }

PM

6

(35 replies, posted in PunBB 1.2 show off)

You can get the current URL using javascript, the code below has been included at http://langworthy.bpweb.net/index1.php This works with the action=in function as do the others methods which return a valid URL you only need action=qout (part of the modded login.php) to return you back to your current page when logging out.

<form method="post" action="forum/login.php?action=in">
    <input type="hidden" name="form_sent" value="1">
<script language="javascript">
  var href = location.href;
  document.write('<input type="hidden" name="redirect_url" value="');
  document.write(href);
  document.write('">');
</script>
    Username3:  <input type="text" name="req_username" size="25" maxlength="25"><br>
    Password3:  <input type="password" name="req_password" size="16" maxlength="16"><br>
    <input type="submit" name="login" value="Login">
</form>

Paul M

7

(35 replies, posted in PunBB 1.2 show off)

Actually the code on the Mod Discussions forum does not work, it refers you to the forum homepage.

I have set up a test page at http://langworthy.bpweb.net/index1.php where you can see each bit of code in action. The username and password is test

I have ammended the code in login.txt to:

<form method="post" action="forum/login.php?action=in">
    <input type="hidden" name="form_sent" value="1">
    <input type="hidden" name="redirect_url" value="<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\">";?>

    Username1:  <input type="text" name="req_username" size="25" maxlength="25"><br>
    Password1:  <input type="password" name="req_password" size="16" maxlength="16"><br>
    <input type="submit" name="login" value="Login">
</form>

PM

8

(35 replies, posted in PunBB 1.2 show off)

qlogin is no longer required, The revised code above uses PunBB functions, but there is a neater solution with explanation on the Mod Discussions/Login Box forum.

9

(35 replies, posted in PunBB 1.2 show off)

Paul wrote:

Great Work. I have acres of webspace lying around on a commercial host. If you want me to up the files just email them to me and I will post the link back here.

To login to your PunBB forum from a main page from your site you can do so by:

1. replacing login.php with the modified version (see quote, you may have to wait a few hours for the link to appear) The mods will not alter the functionality of the script in any way.

Note, If PunBB is part of your main website you may as well use the cookie it creates to control access to any web pages that are for your site members only. For this reason the code below will allow logging in and control.

2. Add the following code at the top of each webpage you wish to either protect or login from. fail.php can be changed to point to your own failed login page. $member < 0 is used to restrict access, this example would allow anyone to view the page changing the 0 to 1 would change the access to members and admin, changing 0 to 2 would allow admin only.

<?php
  include("auth.php");
  if($member < 0){
    header ("Location: fail.php");
  }
?>

3. Add the following code where you wish the login boxes to appear (this is the minimum code, styles and formatting would be applied to suit your site). The body 'onLoad' tag is added only if you wish your login username field to have focus.

<body onLoad="document.getElementById('login').req_username.focus()">
<?php
  if ($member == 0)
    include("login.txt");
  else
    echo '<a href="forum/login.php?action=qout">Logout?</a>';
?>

4. Copy auth.php and login.txt to the same directory as your webpages.

auth.php contains the following code. $member = 0 if no cookie exists or a cookie for a Guest user has been set. $member = 1 if a member has logged in, $member = 2 if an administrator (with a username of admin) has logged in:


<?php
  function un_escape($str){
    return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str;
  }
  if(isset($punbb_cookie)){
    list($str) = unserialize(un_escape($punbb_cookie));
    if ($str == "Guest")
      $member = 0;
    else if ($str == "admin")
      $member = 2;
    else
      $member = 1;
  } else
      $member = 0;
?>


login.txt contains the following code (this is the minimum code, styles and formatting would be applied to suit your site). The 'action' path may need to be ammended to point to where you have login.php.


<form method="post" action="forum/login.php?action=qin" id="login" onsubmit="return process_form(this)">
  <input type="hidden" name="form_sent" value="1">
  <input type="hidden" name="MainSiteLogin" value="<?php $text = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PATH_INFO'];echo "$text\">";?>
    <table cellspacing="1" cellpadding="4">
      <tr>
        <td nowrap"><b>Username</b></td>
        <td> <input type="text" name="req_username" size="25" maxlength="25"></td>
      </tr>
      <tr>
        <td nowrap"><b>Password</b>  </td>
        <td > <input type="password" name="req_password" size="16" maxlength="16"></td>
      </tr>
      <tr>
        <td><input type="submit" name="login" value="Login"></td>
      </tr>
    </table>
</form>

I hope this has been explained OK

Paul M

10

(35 replies, posted in PunBB 1.2 show off)

I have completed the ammendment of the site login scripts calling PunBB's functions and made it simple so that a non programmers can set it up. I cannot upload the files to PunnBB so I will put them on a website and post the URL soon.

Paul M

11

(4 replies, posted in Programming)

MarcB

It is to do with the way the site is updated and the type of files, The files are AutoCAD dwf files which are viewed through the browser using a custom plug-in. the plug-in can only reference and view the files if they are served up following strict rules.

Paul M

12

(4 replies, posted in Programming)

I am after a sorting algorithm written in perl to perform the following task:

I have a variable number of files within a directory (anything from 0 to a couple of hundred) They are named very specifically in the following manner:

document1_rev-0
document2_rev-0
document2_rev-A
document2_rev-B
document3_rev-0
document4_rev-0
document4_rev-A

The documentx part of the file could be anything, the _rev-x part always starts at _rev-0 (zero) and each time the document is revised will change to A through to Z (it is be highly unlikley to ever reach Z). I want the algorithm to return a list showing only the latest revisions. ie the list above should appear as:

document1_rev-0
document2_rev-B
document3_rev-0
document4_rev-A

There are two ways this can be acheived, either keep a dynamic list updated as each file is read from disk in turn, or read all files into an array (or something similar) and then run the algorithm on the array to strip out old revisions. (Due to the nature/use of the files I do not want to use a database to perform the above).

I will pay the princely sum of £10 (In sterling or Amazon book tokens, should anyone not wish to disclose an address for it to be sent to) for the solution which I beleive is most efficient (this would be acheived by trial and error as I probably wouldn't be capable of determining it any other way. My decision would be final and not up for debate, Although I would expect if other postings are anything to go by a debate would rage on afterwards to a point where you will be counting clock cycles and how much further one particular electron had travelled around it silicon orbit)

On a serious note I look forward to receiving some feedback

Paul M

13

(35 replies, posted in PunBB 1.2 show off)

Louis wrote:

Ahhh. All the tables and font tags! <faints sound="thud" />


The code as published is a quick fix at the moment, We will be separating the php from the html in due course, this code was published on request. We will post a slicker version in the near future.

PM

14

(35 replies, posted in PunBB 1.2 show off)

John above is the old code, the new qlogin will recognise either password hash, but will not replace the md5 password. Logging in from the revised punBB forum code will update each users encrypted password to the new algorithm. Also the old code above doesn't log you out of the users online database, This has been fixed in the later version.