PDA

View Full Version : Alltrim in V8


ABC123

mfletcher1
03-03-2007, 11:23 PM
When I was using V7, I would create an operation to go through a file, with selected record numbers, and insert spaces at the beginning of a field and add a letter to those selected records.

In the expression part of the query, I would put " " (to indicate the number of spaces I wanted to insert) +alltrim(fieldname).

I have tried the same thing in V8 and it does not seem to work.

Am I doing something wrong or has the program changed?

Thanks.

jkletrovets
03-03-2007, 11:50 PM
Hi Marvin

Hmmm...Seems to be working here. From the interactive window.


dim vtest as c
vtest="tester"
? vtest
= "tester"

vtest=" "+alltrim(vtest)
? vtest
= " tester"

But, I think I might be missing something you are trying to do. You don't have to add spaces ahead of time to concatenate a letter in front. You could just do something like varname="AA"+alltrim(fieldname)

Field name's field type must be a character or you need to convert the field to a string.


Regards,

Jeff

glenschild
03-04-2007, 09:08 AM
Hi Marvin

Have you considered using padl which may well achieve what you need?

Regards

Glen

mfletcher1
03-04-2007, 09:17 AM
I think that my problem is that when I use that logic in an operation, and define the set of records, it is not finding the records.

I have checked the record number and entered it into the operation parameters, but nothing happens. I thought it was the alltrim aspect but I think it is something about the record number.

Any suggestions?

Thanks.

jkletrovets
03-04-2007, 10:36 AM
I think we would need a much more detailed explanation of what you are doing/trying to do to be able to help you.

Regards,

Jeff

mfletcher1
03-04-2007, 11:59 AM
1) I have a database with a character field with numbers and letters in it. It is 8 characters wide but items are in only the first 2 or 3 spaces in the field.
2) I am trying to insert a letter and a space or a letter and 2 spaces before the first number in the field
3) I have created a operation and chosen the "update records" option. I have said I wanted to create rather than use the genie.
4) In the screen to create the operation, I have indicated the name of the field, in the field column. In the column called expression, I have put a quotation mark, a letter, a blank, another quotation mark, and the following text (without the quotation marks) "alltrim(fieldname)".
5) I have saved the operation.
6) I have run it, and said I wanted to operate between records x and y. It runs, but nothing happens. I have selected the record sequence from the database, without any indexes on and used the indicator in the lower left corner to tell me what the number of record is.

I should indicate that this works in my other databases, so I may have done something really strange in this particular database. However, I can not think why this does not work.

Is this enough detail?

jkletrovets
03-04-2007, 12:22 PM
Hi Marvin

Thanks for the info. Attached is a sample update operation I just made. There is a one field table with 8 characters. The field is currently populated with 3 characters for each record. I have a save update operation that you can run that will update the records to have ZZ_ put in front of the current field data. I would avoid trying to put blank spaces in the record.

If it is just generic text like a part description field or general text then I don't think it matters. Although maybe the field you have is just a generic text field and it doesn't matter. I guess you can decide. In any case, the attached example works but it is doing all records.

If you are not getting any results with your current for x and y. Then it sounds like that criteria is not producing any valid records to process. I would look at that criteria. If you still don't have any luck, I would be happy to take a look if you can post a sample. Sometimes a fresh pair of eyes does wonders! :)

Regards,

Jeff

mfletcher1
03-04-2007, 12:58 PM
I think the problem is that there is something weird about this database. I tried to change record #18, either as a record number or as a marked item, and it was not picked up.

Could you look it and see if you can see anything weird about the database.

It is the first field I am trying to modify. I can explain the reasons as to why I am trying to insert the blanks, but I really think the problem is finding the records.

Thanks.

Marv

mfletcher1
03-04-2007, 12:59 PM
I think I attached the database in this note.

Bob Houle
03-04-2007, 02:00 PM
You need to define what it is you really want to do with this field of data...

Record #1 = "___1____"
Record #7 = "___7____"
Record #8 = "__7C____"
Record #18 = "14______"
Record #819 = "B 1______"
Record #883 = "14______"
Record #1009 = "14______"
(I used the underscore to show spaces because of forum formatting)

These are some of the patterns I found.
I did not see any index field that would make this field unique.


>>>I think the problem is that there is something weird about this database. I tried to change record #18, either as a record number or as a marked item, and it was not picked up. <<<


I believe that's why when you asked for "14"... you did not succeed.

For now, I would strip out the spaces at the start of the field, this will add some consistancy.

I would then add some field rules to force the user to correctly place the data in this field.

This will make searching easier as well.


HTH,
--Bob

Mike Wilson
03-04-2007, 02:17 PM
I have put a quotation mark, a letter, a blank, another quotation mark, and the following text (without the quotation marks) "alltrim(fieldname)".

Marvin,
Bob is correct.

Also, based upon what you wrote, it translates to this:
"A "alltrim(fieldname). Missing in there is a "+" sign => "A " + alltrim(fieldname).

mfletcher1
03-04-2007, 02:21 PM
I tried to run the change operation on record #18, to change "14 " to " 14". This has worked in other databases with the same structure. I need this structure to create a certain type of structure. It works in other databases.

However, the change operation never seemed to find record #18, in order to make the change. I tried two ways to tell the change operation to find the record, either by marking it, or using the record number.

How can I tell whether the problem I am having is due to the database itself, the search routine I am applying to the change operation, or the change operation?

Thanks for trying to puzzle this out for me.

mfletcher1
03-04-2007, 02:26 PM
Mike W,

Sorry if I left the "+" out.

Here is what I put in the Expression field...

" "+alltrim(nameoffield)

Which should translate to 2 blank spaces, a plus sign, the alltrim operation, and the name of the field.

This has worked in all my databases except 1.

jkletrovets
03-04-2007, 07:12 PM
Marvin

It seems Bob and Mike confirmed what I wrote earlier about not using spaces in a field like this. Unless you are absolutely tied to this format for some reason, I think it might make sense to change your methodology. Perhaps add a unique id field and do an update operation with serial data so you could 100 percent for sure have a unique identifier for each record? For what it is worth, I did the following in the interactive window. It shows record 18 not with one or two space(s) but 6.


dim tbl as p
tbl=table.open("argentina")
tbl.fetch_goto(18)
? tbl.numarg
= "14 "

Regards,

Jeff

mfletcher1
03-04-2007, 08:42 PM
Jeff,

I really am tied to the format.

I am just curious as to whether the 6 spaces after the number is significant in an operation that uses the alltrim.

Basically what I am trying to do, is remove 2 spaces at the end of record and place them at the beginning of the record. It has worked in all my other databases, which are all structured in the same way as this one is.

It is strange. If I can not do it this way, then I will go through and manually insert the space. I was just trying to save time and energy.

Selwyn Rabins
03-04-2007, 11:21 PM
When I was using V7, I would create an operation to go through a file, with selected record numbers, and insert spaces at the beginning of a field and add a letter to those selected records.

In the expression part of the query, I would put " " (to indicate the number of spaces I wanted to insert) +alltrim(fieldname).

I have tried the same thing in V8 and it does not seem to work.

Am I doing something wrong or has the program changed?

Thanks.

alltrim() has not changed.

jkletrovets
03-04-2007, 11:52 PM
Marvin,

I noticed there are 3 records in the table that have a value of "14 ". Recno 18 is one of them. I did the following in the interactive window which accomplishes what I think you are after. Your update operation must have a statement it can't recognize as far as finding the record you are trying to lookup.


dim tbl as p
tbl=table.open("argentina")
tbl.fetch_goto(18)
vtest=alltrim(tbl.numarg)
tbl.change_begin()
tbl.numarg=" "+vtest
tbl.change_end()
? tbl.numarg
= " 14 "

I also did an update operation based on record no 18 and it worked as you are looking for as well. See attached image.

Hope that helps some.

Regards,

Jeff

mfletcher1
03-05-2007, 08:25 AM
Jeff,

This is really weird. I am obviously missing something really obvious here.

The only difference between what I see when I enter the record numbers and what you sent me are the check boxes to the right of the entry windows.

Are all the operations included in the database that I sent? What I am wondering is, if you could try the operation on the database itself and see if you get a different result than I do, using my operation.

Thanks for putting up with this puzzle.

Marv

jkletrovets
03-05-2007, 08:35 AM
Marvin

There are 5 operations with the data you sent. Which one do you want me to look at?

Regards,

Jeff

mfletcher1
03-05-2007, 08:48 AM
Jeff,

Tough one since I have modified them so many times since I sent it. I am attaching the latest version of the file.

Could you run Test1 on record 119.

This should be interesting.

Marv

jkletrovets
03-05-2007, 09:11 AM
Marvin

Well, it worked just like you are looking for it to. I attached a couple snapshots.

Regards,

Jeff

mfletcher1
03-05-2007, 09:24 AM
Ok. Now something odd is really going on.

I tried the same thing on my database that you did on my database, but it did not work. The only difference I can see between what you sent me and what I have is that your second screen showed a "Select Records" screen, while mine showed a "Run Operation Genie" screen. I did, however, use the filter expression, as you did, and the end result was the same, nothing.

I have the Version 8, Build 1269, system addins 3059. Is this what you are running?

Marv

jkletrovets
03-05-2007, 09:37 AM
Marvin

Yep, that is the version I am running with Windows XP Pro SP2.

The "select records" button is available when when you open the saved operation from the control panel in design mode. I ran your saved operation from the Run Genie and it worked there as well. I removed the selection criteria in design mode and then just added it in the Run Genie.

Hmmm... Not sure what is going on.

Jeff

mfletcher1
03-05-2007, 09:46 AM
Jeff,

Odder and odder.

At this point my ideas are exhausted. Let me think about it and get back later in the day.

Thanks for all your efforts.

I just have a feeling it is something simple I am doing but do not know what.

Marv

mfletcher1
03-05-2007, 09:52 PM
Jeff,

I did some further experimentation and found something really odd. When I ran the operation with no records selected (all the records) the change worked. When I ran the same operation with a variety of methods to indicate a criteria used (filter expression or record numbers or range of record numbers) the change did not work.

To me this indicates that for some reason the operation is sound (and it runs on your machine) but that I must have some setting or way I entered the parameters that the program is choking and not working.

Is there a way to create a record of what is actually occurring during the operation, which may give some clue as to what is happening?

Marv

jkletrovets
03-06-2007, 09:41 AM
Marvin

The only thing I can think of is that you somehow still have a filter that includes the record you subsequently want to process. So when you try to run the update operation the record cannot be found because it is already "filtered" out of the data set. I'm not sure where you are running your update operation from - but if it is from a button on a form you could issue as the first line (action script) on the button:

topparent.show_all()


This will make sure that all records are being included in update operation by turning.

Regards,

Jeff

mfletcher1
03-06-2007, 03:19 PM
Jeff,

Unfortunately I am running the operation from "create operation" and "run operation" choices.

When I create the operation, as you have seen, I do not think I have put in any parameters.

I tried the same operation on another database and had the same results.

Are there any settings in the program that might have an impact on this? It seems that something has changed between V7 and V8 in some setting that has an impact on the way I am entering the parameters, but does not have an impact on your system.

I am grasping for straws at that point.

Marv

jkletrovets
03-06-2007, 03:29 PM
Marvin

If you open the table in question in view mode (just double click on it from inside control panel) you can tell if a filter is on the data. See attached. I'm about out of suggestions. Does seem weird what is happening on your end.

Regards,

Jeff

mfletcher1
03-06-2007, 09:20 PM
This is really weird.

I found that the filter was not turned on. However, I began to try a variety of options from the menu inside the database and, incredibly, the operation worked correctly.

In other words, when I ran the operation from outside the database it did not work, while when I ran the operation from inside the database, using the same operation and the same way of entering the parameters, it did work.

When you ran the operation on my database, did you do it from inside the database or from the outside?

Marv

jkletrovets
03-06-2007, 09:35 PM
Hey Marvin

I ran it from both places and it worked. Go figure....

Jeff

mfletcher1
03-06-2007, 09:42 PM
Jeff,

Weird!

Well at least it works. I also learned more about Alpha5 in the process.

Thanks again for your patience.

Marv

jkletrovets
03-06-2007, 09:57 PM
Marvin

Yep, that is weird. I don't like not knowing why things are working like they are but it appears ok on this end so it is kinda hard.

Glad to help. Glad at least you have a solution that works.

>>I also learned more about Alpha5 in the process.

There is a lot to learn. It's a great program. I learn more everyday too.

Regards,

Jeff