Defining/altering a Variables contents


#1

I have a six digit number that I need to insert the letter “x” into a variable – like this 1234x56. The first 4 digits identify a department, the last two digits represent a record sequence number. In this case, a record needs to be deleted, but kept in the database and sorted to the bottom of the list for the department. So placing an alpha character in this position allows the database to sort correctly. I used to do this with the sandwich procedure and put the alpha character in front of the number – but if someone has all records selected and then sorts, all deletes go to the bottom of the database rather than stay with the department. Of course, if they remember to group the records first – it works fine. By inserting the alpha character between the department & sequence number – the database sorts correctly regardless of grouping, I’m having trouble getting my procedure to place the alpha character correctly in the variable so it can replace the existing number in the field. My procedure opens the TEO and places the contents into a variable, then replaces the data in the active TEO with the “x” inserted in the number – or at least that’s what I’d like it to do. I’m not able to figure out how to correctly define the variables contents. Here’s one example, I’ve tried many different approaches, this one quits Pan6, but I’ve seen other attempts that say “implicit”:

Local theswap
theswap=””
SuperObject “AIN”,“Open"
if info(“activesuperobject”)≠”“
activesuperobject “gettext”,pattern(theswap,”####(x)##")
ActiveSuperObject “InsertText”,theswap
endif

I’m currently in Pan 6 because my staff still use Pan6 - we’re waiting on the expandable text issue to be resolved - I know it’s on the to do list. I have done lots of conversion to PanX for all my databases and really am liking it!


#2

Change this line to:

activesuperobject "gettext",pattern(val(theswap),"####x##")

This works in both Pan 6 & Pan X.


#3

Thanks Gary, I discovered a dumb mistake on my part - I failed to initialize the variable correctly. The procedure below worked. Thanks so much for your help1
SuperObject “AIN”,“Open"
if info(“activesuperobject”)≠”"
activesuperobject “gettext”,theswap
activesuperobject "close"
SuperObject “AIN”,“Open"
activesuperobject “SetSelection”,0,6
activesuperobject “clear"
ActiveSuperObject “InsertText”,pattern(val(theswap),”####x##”)
endif


#4

It’s the value in the field that you want to change, so there is really no reason why the SuperObject needs to be involved at all. That procedure could be reduced to something like

TheField = sandwich("",TheField[1,-3],"x") +TheField[-2,-1]

You would replace TheField with the actual name of the field.


#5

Thanks Dave, I agree - I did try and change the fields value using sandwich - but didn’t get the formula correct - I have trouble understanding [1,-3] and [-2,-1] - I need to read up on that as I’m sure I’ll be using something similar again. Thank you for helping


#6

See p69 of Formulas & Programming in Panorama documentation.


#7

Thank you Michael, I re-read and that helps


#8

Don’t forget, a great way to learn about Text Funnels, or really any formula feature, is to play with them in the Formula Wizard, especially in Panorama X where you see the result of a change immediately.


#9

Very nice and a great way to learn! Thanks Jim


#10

When you think about it, this really revolutionises the concept of user manuals.