[Sticky] INDEX: list of Proclaim Maths functions

Solved a problem in an elegant manner and want to show off your code? Know a hard-to-find feature? Post it here for the benefit of others. Questions don't belong here.
steve
Posts: 486
Joined: Wed Nov 30, 2011 10:20 pm
Been thanked: 128 times

Re: [Sticky] INDEX: list of Proclaim Maths functions

Post by steve »

one use is for comparison operators
e.g.

Code: Select all

IF 1 NOT= 1 THEN 
    MESSAGE( "not eq" )  
ELSE 
    MESSAGE( "eq" ) 
END 
this 'compiles' when syntax checked to

Code: Select all

IF 1 <> 1 THEN 
    MESSAGE( "not eq" )  
ELSE 
    MESSAGE( "eq" ) 
END 
likewise there are 'translations' for
NOT=,!=,LE,GE,LT,GT
Last edited by steve on Fri Mar 05, 2021 12:57 pm, edited 1 time in total.

Code Killer
Posts: 49
Joined: Thu Oct 29, 2015 10:04 am
Location: Kent
Has thanked: 36 times
Been thanked: 3 times

Re: [Sticky] INDEX: list of Proclaim Maths functions

Post by Code Killer »

Hi Steve,

I was expecting it was going to be more unique. :lol:

Thanks again :D

CELRY
Posts: 5
Joined: Wed Feb 02, 2022 9:13 am
Been thanked: 1 time

Re: LISTITEM

Post by CELRY »

steve wrote:
Fri Nov 09, 2018 2:53 pm
returns a character string from a list, based on an integer position

LISTITEM (list , element , character)

example

Code: Select all

vlist = "Monday,tuesday,wednesday,thursday,friday,saturday,sunday"
v1 = listitem(vlist,1,","{
message ("first day is ",v1)
#prints Monday
CAVEAT/BUG
If you use a field for defining your starting list, then do not use the comma delimiter as it doesn't work.

Code: Select all

#set up example alpha field with comma delimited text
put( "Monday,tuesday,wednesday,thursday,friday,saturday,sunday", {mytext field.Alpha})
#retrieve field into variable
vlist = TEXT( {mytext field.Alpha})
v1 = listitem(vlist,1,",")
#or v1 = listitem({mytext field.Alpha},1,",") - doesn't work either
vcount =listsize(vlist,",")
message ("Count: ",vcount) #returns 1!
message ("first day is ",v1) #errors: prints Monday,tuesday,wednesday,thursday,friday,saturday,sunday
Any examples of using a list to store integers instead of strings?

proclaimadmin
Site Admin
Posts: 49
Joined: Wed Nov 30, 2011 9:37 pm
Has thanked: 1 time
Been thanked: 2 times

DECODE-HEX-STRING

Post by proclaimadmin »

Available from 3.4.1.23 and 3.5.0.02

DECODE-HEX-STRING("string of hex")
e.g.

Code: Select all

vtext = DECODE-HEX-STRING("4e6576657220676f6e6e61206769766520796f75207570")
MESSAGE("Decoded text: ",vtext)

proclaimadmin
Site Admin
Posts: 49
Joined: Wed Nov 30, 2011 9:37 pm
Has thanked: 1 time
Been thanked: 2 times

DECODE-BASE64-STRING

Post by proclaimadmin »

Available from 3.4.1.23 and 3.5.0.02

DECODE-BASE64-STRING("string of BASE64")
e.g.

Code: Select all

vtext = DECODE-BASE64-STRING("aHR0cHM6Ly9iaXQubHkvdGhlLXBvd2VyLW9mLWxpbms=")
MESSAGE("Decoded text: ",vtext)
note that there is a command "FROMBASE64" that does something similar but not what you want.