|
Post by tonywyc on Feb 18, 2022 14:03:27 GMT -5
Hi
I work in other program language RPG where we had two special value call Lowval and HighVal... I was hope to build this a string variable i can use in processing strings and arrays.
|
|
|
Post by tsh73 on Feb 18, 2022 14:27:20 GMT -5
I have no idea but this is BASIC if it could be explained probably it could be coded. So could you explain it?
(don't expect me learn another language just for that - "two special value " in complelely alien to me " program language RPG " - not counts as explanation)
|
|
|
Post by tonywyc on Feb 18, 2022 15:41:26 GMT -5
Sure Tsh73
Sure thing I can explain it Lowval was constant that held the lowest single character Hival Was constant that held the highest single character
The reason we had it to help write logic for array and file processing.
Does this help?
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Feb 18, 2022 16:12:08 GMT -5
Hi tonywyc,
In Basic, every character has an ASCII number assigned, here is a listing for ones printable:
for i = 32 to 255 print "i = ";i;", chr$(i)";chr$(i) next
"Non printables" are like Chr$(9) which is a Tab, Chr$(13) the enter key, Chr$(10) a line feed, Chr$27) escape, the handy most 4 under Chr$(32).
There is a another function, Chr$(n) buddy, called Asc(OneS$) which gives you the assigned number for a letter, digit or other symbol.
print "A",Asc("A") print "a",Asc("a") print "Z",Asc("Z") print "z",Asc("z") print "0", Asc("0") print "9", Asc("9")
|
|
|
Post by tonywyc on Feb 18, 2022 17:08:50 GMT -5
bplus
when I run this code i got an error
global Lowval$ global Hival$
Loval$ = Char$(1) Hival$ = Char$(255) end
MEssage: Runtime Error: Subscript out of range: 255, char$()
So what value will work for hival???
|
|
|
Post by dan1101 on Feb 18, 2022 18:11:55 GMT -5
Do you mean Chr$()? The command for ASCII characters in BASIC is Chr$() with no "a", NOT Char$()
Your Char$() is being interpreted as a standard string array, which needs to be dimensioned with at DIM statement unless it is 10 items or less.
|
|
|
Post by tonywyc on Feb 18, 2022 18:14:02 GMT -5
Gosh I guess the problem I add an A to Char it should be Chr$ ,,,
sorry I work harder not to ask new be questions
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Feb 18, 2022 18:15:21 GMT -5
bplus when I run this code i got an error global Lowval$ global Hival$ Loval$ = Char$(1) Hival$ = Char$(255) end MEssage: Runtime Error: Subscript out of range: 255, char$() So what value will work for hival??? Why are you using Char$()? LB thinks you are using an un DIM'd array. It's Chr$() and Chr$(n) where n < 32 is not exactly recommended for printing. Oh I see that dan1101 already got it! good! Very curious to see what you tonywyc are going to do with Loval$ and Hival$.
|
|
|
Post by tonywyc on Feb 18, 2022 19:07:14 GMT -5
bplus.
1. Way to mark elements in an array that you would not want to process. You mark it hival then sort the array 2. I can be used as return value for the function... the function can then return 4 values 1 = Yes, 0 = No, Lowval = less then , Hival = greater
|
|
|
Post by tsh73 on Feb 18, 2022 22:38:23 GMT -5
Here's a page I found docs.oracle.com/goldengate/1212/gg-winux/GWURF/column_conversion_functions018.htm#GWURF802from that it looks like concept relates to fixed length string JB does not have such a thing strings are dynamic and smaller string (sort-wise) is always empty string, "" Since there is no real upper limot on s string length, there is no upper value (there is Random Access Files, though - fields are strings of fixed length) You can use replstr$(space$(n), " ", chr$(0)) replstr$(space$(n), " ", chr$(255)) for getting strings as in link above. But could it be useful?
|
|
|
Post by Rod on Feb 19, 2022 3:44:54 GMT -5
One example of an array you wanted to sort would help everyone understand. If we are talking about ignoring characters during sorting, say to sort only the alpha numeric characters and ignore other characters then Liberty has that built into it’s sort routine. But is it about min,max?
You need to give us a wider description of the task in hand. Don’t worry about posting questions, that is why we are all here.
I had a read at the RPG docs about sorting and use of hival lowval but I am really non the wiser the language is too far from BASIC to understand easily. So working example would really help.
|
|
Dennis
Full Member
Old but still active
Posts: 147
|
Post by Dennis on Feb 19, 2022 4:17:25 GMT -5
About 2 years ago, I tried using high-values/low-values (hex "FF" and hex "00" or, chr$(0) and chr$(255)) in one of my programs to manipulate data in certain tables.
I ended up with problems after sorting. Eventually resorted to using all "Z's" in certain filelds as a "high" marker.
I was converting programs from another basic to LB when I encountered the problem. The previous basic that I was using recognised the high/low-values correctly.
I gave up too quickly but since I now have some time on my hands, I am going to experiment.
Regards Dennis
|
|
|
Post by tonywyc on Feb 22, 2022 7:06:21 GMT -5
About 2 years ago, I tried using high-values/low-values (hex "FF" and hex "00" or, chr$(0) and chr$(255)) in one of my programs to manipulate data in certain tables. I ended up with problems after sorting. Eventually resorted to using all "Z's" in certain filelds as a "high" marker. I was converting programs from another basic to LB when I encountered the problem. The previous basic that I was using recognised the high/low-values correctly. I gave up too quickly but since I now have some time on my hands, I am going to experiment. Regards Dennis
|
|
bplus
Full Member
Posts: 127
|
Post by bplus on Feb 22, 2022 10:41:15 GMT -5
global nItems nItems = 25 dim a$(nItems)
for i = 1 to nItems r = int(rnd(1) * 10) + 1 for j = 1 to r r2 = int(rnd(1) * 26) + 1 a$(i) = a$(i);mid$("ABCDEFGHIJKLMNOPQRSTUVWXYZ", r2, 1) next Print a$(i) next call FindHiLo HiVal$, LoVal$ print :print "Hival: "; HiVal$, "Loval: ";LoVal$
sub FindHiLo byRef Hi$, byRef Lo$ Hi$ = a$(1) : Lo$ = a$(1) for i = 2 to nItems if a$(i) < Lo$ then Lo$ = a$(i) if a$(i) > Hi$ then Hi$ = a$(i) next end sub
|
|