Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - StringList
Page 1 of 2

PostPosted: Thu Sep 23, 2004 11:05 pm
by Gazza
Database

Fields:

Name
Age
PostCode

I populate a StringList from the database (Just the Name), then view every Name with a ListBox. I can then jump to that record by using the .selitem as it will point to the correct record in the database. However if I have a list based on a query, and fill that list into a ListBox, it will not jump to the correct record.

What is the best way to combat this problem,

Thanks in advance Gaz

PostPosted: Fri Sep 24, 2004 6:46 am
by nmc
Use a second stringlist to store the record numbers, or use a self written draw function for your list, store the record number in your stringlist an strip it of when displaying an item.

PostPosted: Fri Sep 24, 2004 10:08 am
by Gazza
This would take a lot of coding.

I could get the information using:

lstView.gettext(lstView.selitem);

Then I would have to search the entire second StingList for the result, and strip out the string, leaving the recID.

I do like the StringList idea, as you do not have to define the size of the String, as with an Array.

The problem with the Token, is that it doubles the amount of indexes within the StringList. This would be better, if the tokens could have the same index as the string.

This would be a nice command and solution:

StringList viewName;

viewName.add("Gaz");
viewName.add("Tina");

// .gettext(String, TokenIndex[])
viewName.gettext("Gaz", 0)

Any ideas?

PostPosted: Fri Sep 24, 2004 10:36 am
by nalonge
Gazza, I use a StringList to add my items for the list box and I use the Dict object to store the position of the record in the list box and the recordID for that record. When the user selects the item in the list box I use the .value property of the Dict object and hand it the .selItem. It will return to me the recordID and from the I take the user to an edit screen.

Let me know if you need to see some code.

Nick

PostPosted: Fri Sep 24, 2004 11:29 am
by Gazza
Hi Nike,

That method works great if you are using all the records, you don't really need the dict option though, unless you have your own unique id for the record, I use the normal record id.

.selitem in that case will point to the correct record. As you can use it for the recID.

If you have the records

Gaz, ID2
Tina, ID5

Pulled out from a query, the .selitem point to 0 and 1.

As nmc pointed out, using two StringLists is a solution,

void openFiles2()
{
Database db;
DBRecord rec;

string recName;
int maxRec;
int curRec;

if (db.open(appPrefs.dbName, false))
{
maxRec = db.nrecs;

for(curRec = 0; curRec < maxRec; curRec++)
{
if (db.getrec(curRec, rec, true))
{
rec.read(&recName, typeof(recName), 1);
tempName.add(recName);
viewName.add(curRec + ": " + recName);
rec.close();
}
}
db.close();
}

lstView.setitemslist(tempName);
}

handler lstView.onselect()
{
int strLoop = 0;
int strMax = 0;

int rNumber;

string sel_item;

sel_item = viewName.item(lstView.selitem);

strMax = strlen(sel_item);

for(strLoop = 0; strLoop < strMax; strLoop++)
{
if(substr(sel_item, strLoop, 1) == ":")
{
rNumber = strleft(sel_item, strLoop);
strLoop = strMax;
}
}

appPrefs.iRecord = rNumber;
recMgr.init();
frmView.close();
mainForm.load();
}

Not as long winded as I though it would be.

PostPosted: Fri Sep 24, 2004 12:13 pm
by nalonge
Actually, I am only showing 10 records at a time and giv the user navigation buttons. So the listIndex will never match the record ID (the listIndex will always be 0-9).

Here is some code:

Code: Select all

Draw d;
int curStart;

StringList slAccounts;
void GetAccounts();
void GetTrans();
void drawColorList(int item, int x, int y, int w, int h, string text);
Dict recordID;
string AddSpace(string,int);
int bc;

void GetTrans(){

   Database db;
   DBRecord rec;
   int i;
   int listpos;
   bool useall;
   bool IsCleared;
   string ListItem;
   StringList sTrans;
   
   
   sTrans.clear();
   recordID.clear();
   
   listpos = 0;
   useall = true;
   
   db.open("njjc_TransDB",true);
   
   //alert(db.nrecs);
   curStart = db.nrecs;
   
   if(db.nrecs >= 10){
      useall = false;
   }
      
   for(i=0;i<=db.nrecs;i++){
      if((!useall && i>= db.nrecs-10) || (db.nrecs <= 10)){      
         if(db.getrec(i,rec,true)){
            IsCleared = false;
            ListItem = "";
            
            rec.read(&entry.trans,typeof(entry.trans),1);
            
            ListItem = strleft(entry.trans.tDate,5) + "!";
            
            if(entry.trans.tPayee != ""){
               ListItem = ListItem + entry.trans.tPayee + "!";
            }else{
               ListItem = ListItem + "(none)" + "!";
            }
            
            if(entry.trans.tWithAmt != ""){
               ListItem = ListItem + "-" + entry.trans.tWithAmt + "!";
            }else{
               ListItem = ListItem + entry.trans.tDepAmt + "!";
            }
            
            if(entry.trans.tCleared == "C"){
               
               ListItem = ListItem + "x";
            }else{
               ListItem = ListItem + " ";
            }
            
            sTrans.add(ListItem);
            
            recordID.add(listpos,rec.id);
            listpos ++;
            rec.close();
         }
      }
   }
   
   
   
   db.close();
   
   lstRecentTrans.setitemslist(sTrans);
   lstRecentTrans.setdrawfunc(drawColorList);
   lstRecentTrans.redraw();

}

handler lstRecentTrans.onselect() {
   appSettings.selRecord = recordID.value(lstRecentTrans.selitem);
   appSettings.EditMode = 1;
   frmTrans.load();
}


Also, you can use StringList.tokens(yourString,":") and get you name/recID from the Array.

PostPosted: Fri Sep 24, 2004 1:05 pm
by Gazza
Hi Nick,

Thanks for the code, I can see where you are coming from now.
Nice solution. I will make the changes.

An interesting thing in your code is this:

lstRecentTrans.setitemslist(sTrans);
lstRecentTrans.setdrawfunc(drawColorList);
lstRecentTrans.redraw();

I have been setting the visibility to ListBox to false,
updating the list, then back to true to have the same
affect. Its nice to see a much better solution.

:) Thanks

About the StingList Token,

I did have this originally:

viewName.tokens(blankEntry.name, "/")
viewName.add(blankEntry.name + "/" + rec.id);

All though it adds the entry as,
index 0: Gaz
index 1: 0
Index 2: Tina
index 3: 1

How can you get the ID for Gaz?

PostPosted: Fri Sep 24, 2004 1:14 pm
by nalonge
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Gazza</i>
<br />
About the StingList Token,

I did have this originally:

viewName.tokens(blankEntry.name, "/")
viewName.add(blankEntry.name + "/" + rec.id);

All though it adds the entry as,
index 0: Gaz
index 1: 0
Index 2: Tina
index 3: 1

How can you get the ID for Gaz?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Gaz, I think the token only works in my case then because I am using Dict and not StringList.

Here is my draw function:
Code: Select all

//--------------------------------------------------------------
void drawColorList(int item, int x, int y, int w, int h, string text) {
  //Data comes in like this date ! amount ! Payee

   StringList thetext;
   thetext.tokens(text,"!");
   
   d.begin();

   d.textTrunc(x + 0, y, 41, thetext.item(0));
   d.textTrunc(x + 33, y, 60, thetext.item(1));
   
   if(strleft(thetext.item(2),1) == "-"){
      d.textColor(143);
      d.textTrunc(x + 109, y, 40, substr(thetext.item(2),1,strlen(thetext.item(2))));
   }else{
      d.textColor(240);
      d.textTrunc(x + 109, y, 40, thetext.item(2));
      
   }
   d.textColor(240);
   d.textTrunc(x + 145, y, 10, thetext.item(3));
   d.end();
   
}


I have been trying to get the list to alternate row color. If anyone has implemented this I would love to see the solution.

PostPosted: Fri Sep 24, 2004 2:14 pm
by nmc
> This would take a lot of coding.
Maybe you dont got me right...
what i meant was:
Code: Select all
   ...
   i = 0;
   while (i < db.nrecs) {
      if (record[i]-contents matches query) {
         viewlist.add(name);
         idlist.add(i);
      }
      ++i;
   }
   myList.setitemlist(viewlist);
   ...


And to get the rec id:
Code: Select all
   int i = myList.selitem;
   int id = idlist.item(i);
   if (db.getrec(id, ...)) {
      ...
   }

So you get only one additional line while computing the query and very easy access to the record id of any displayed item at any time.

PostPosted: Fri Sep 24, 2004 2:48 pm
by Gazza
Hi nmc,

I see what you mean, I made long wind of it.

Nice solution.

:)

I liked both solutions, although I like this one due the benefits as you posted.

PostPosted: Wed Jul 26, 2006 10:04 pm
by sangahm
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">

I have been trying to get the list to alternate row color. If anyone has implemented this I would love to see the solution.

<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Did you ever find a solution to creating alternate row colors in a list?

PostPosted: Thu Aug 03, 2006 4:35 pm
by Gazza
Code: Select all
void drawColorList(int item, int x, int y, int w, int h, string text)
{
   cnt++;
   
   if(cnt > 1)
   {
      r = 230;
      g = 230;
      b = 230;
      cnt = 0;
   }
      else
      {
         r = 212;
         g = 212;
         b = 212;
      }
}


Don't have time to implement this properly, but this ideas works.

PostPosted: Thu Aug 03, 2006 5:55 pm
by sangahm
I'm not sure I follow Gaza.

As I understand it, the drawColorList method is called once to populate all string elements into the UIList.

If it was iterative (called for each element to draw into UIlist), then I'd see how you are setting the rgb values on each call.

PostPosted: Thu Aug 03, 2006 7:55 pm
by nmc
Try something like

if (item % 1)
use color1
else
use color 2

instead.

PostPosted: Fri Aug 04, 2006 12:01 am
by sangahm
That worked nmc, however I made a change to make it
if (int%2)
to get the proper alternating colors.

I'm still fiddling with filling in the fields to get proper color between fields, but it is starting to look very promising.