Omnis 7 Classic Find remove character value

Martin Obongita martin.obongita at yahoo.com
Mon Nov 27 09:13:53 UTC 2023


Thank you, Jim. Reading through the procedure has hinted at all the ideas I could use to solve my issue.
Very helpful indeed. I think it would be a one-liner in Studio 10.
Martin.


Sent from Yahoo Mail for iPhone


On Sunday, November 26, 2023, 11:16 PM, Jim Creak <junkmannz at gmail.com> wrote:

Hi Martin,

I have a Procedure called $STR_Replace as follows:

;  
Optimize procedure
;  
Parameter PF_Field_to_check (Field name)
Parameter PC_Look_For (Character  10000000)
Parameter PC_Change_To (Character  10000000)
Other parameters are optional
Parameter PB_Match_Case (Boolean) = kTrue    ;; Match the case of the word?
Parameter PB_Match_Everytime (Boolean) = kTrue
Parameter PB_Whole_Words (Boolean) = kFalse    ;; Only match whole words
;  
Calculate LC_RETURN as ''
Calculate LC_WORK_WITH as PF_Field_to_check
If not(PB_Match_Case)
Calculate PC_Look_For as upp(PC_Look_For)
End If
Calculate LN_Len_Look4 as len(PC_Look_For)
Calculate LN_POS_FIND as pick(PB_Match_Case,pos(PC_Look_For,upp(LC_WORK_WITH)),pos(PC_Look_For,LC_WORK_WITH))
While LN_POS_FIND>0
If PB_Whole_Words
Calculate LB_BEFORE_OK as (LN_POS_FIND=1)|not(chk(upp(mid(LC_WORK_WITH,LN_POS_FIND-1,1)),'A','Z'))
Calculate LB_AFTER_OK as (LN_POS_FIND+len(PC_Look_For)>len(LC_WORK_WITH))|not(chk(upp(mid(LC_WORK_WITH,LN_POS_FIND+len(PC_Look_For),1)),'A','Z'))
Calculate #F as LB_BEFORE_OK&LB_AFTER_OK
Else
Calculate #F as kTrue
End If
If flag true
If PB_Match_Everytime
Calculate LC_RETURN as con(LC_RETURN,mid(LC_WORK_WITH,1,LN_POS_FIND-1))
Calculate LC_WORK_WITH as con(PC_Change_To,mid(LC_WORK_WITH,LN_POS_FIND+LN_Len_Look4,len(LC_WORK_WITH)))
Else
Calculate LC_RETURN as con(LC_RETURN,mid(LC_WORK_WITH,1,LN_POS_FIND-1),PC_Change_To)
Calculate LC_WORK_WITH as mid(LC_WORK_WITH,LN_POS_FIND+LN_Len_Look4,len(LC_WORK_WITH))
End If
Else
Calculate LC_RETURN as con(LC_RETURN,mid(LC_WORK_WITH,1,LN_POS_FIND))
Calculate LC_WORK_WITH as mid(LC_WORK_WITH,LN_POS_FIND+1,len(LC_WORK_WITH))
End If
Calculate LN_POS_FIND as pick(PB_Match_Case,pos(PC_Look_For,upp(LC_WORK_WITH)),pos(PC_Look_For,LC_WORK_WITH))
End While
Calculate PF_Field_to_check as con(LC_RETURN,LC_WORK_WITH)
Quit procedure
;  
Local variable LB_AFTER_OK (Boolean)
Local variable LB_BEFORE_OK (Boolean)
;  
Local variable LC_WORK_WITH (Character  10000000)
Local variable LC_RETURN (Character  10000000)
;  
Local variable LN_Len_Look4 (Long integer) = 0
Local variable LN_POS_FIND (Long integer) = 0
Local variable LN_POS_ORIG (Long integer) = 0


So, to meet your request I would do something like

;  
Set current list LL_List
Define list (Store long data) {LLC_Text}
;  
;  ...  Load what you want to export into the list
;  
Calculate LC_Chr_2_Del as “#"
Set current list LL_List
Set search as calculation {pos(LC_Chr_2_Del,LLC_Text)>0}
Search list (From start,Select matches (OR),Deselect non-matches (AND))
For each line in list (Selected lines only) from 1 to #LN step 1
Call procedure $STR_Replace (LL_List(nam(LLC_Text),LL_List.$line),LC_Chr_2_Del,"") {$STR_Replace}
End For
;  
;  DONE
;  
Quit procedure
;  
Local variable LC_Chr_2_Del (Character  10000000) = ""
;  
Local variable LL_List (List)
Local variable LLC_Text (Character  10000000) = ""

> On 27/11/2023, at 3:04 am, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> 
> Hi everyone,
> This is a question to the old Omnis version 7 classic. Does anyone remember how you used to find a character in a column list and how you removed it? Especially when exporting a text file to Excel without special characters.
> Many thanks.
> Martin
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 






More information about the omnisdev-en mailing list