Post Reply 
HP 48GX Indefinite Loops
04-02-2022, 02:15 PM
Post: #8
RE: HP 48GX Indefinite Loops
(03-28-2022 03:33 AM)Eddie W. Shore Wrote:  What about a DO... UNTIL... END loop? It works like a WHILE loop but the loop ends when a condition is met.

Thanks for replying! I tried the following.

Program: CSV→
Checksum: # CAC6h
Bytes: 282.5
Purpose: Remove line feed characters from a string. Store
the resulting strings in a list.

\<< 1 CF CSV DUP SIZE
10 CHR { } 1 \→ csv
size char points
position
\<<
DO csv DUP DUP
char POS DUP DUP 0
==
\<< 1 SF
\>> IFT
'position' STO 2 -
1 SWAP SUB points
SWAP + 'points' STO
position 1 + size
SUB 'csv' STO
UNTIL 1 FS?
END points
\>>
\>>

@ Source: Notepad .csv file.
248,1529945.48000,521921.77300,100.60300,IRC 5/8 IL
249,1530002.95100,521922.24500,99.85000,AXLE
250,1530006.67800,521982.23700,102.17700,IRC 1/2 IL

@ Input: Load Object... to Emu48.
"248,1529945.48000,521921.77300,100.60300,IRC 5/8 IL ■
249,1530002.95100,521922.24500,99.85000,AXLE ■
250,1530006.67800,521982.23700,102.17700,IRC 1/2 IL"

@ First iteration: Substring stored in 'points.'
"248,1529945.48000,521921.77300,100.60300,IRC 5/8 IL"

@ First iteration: Remaining string stored in 'csv.'
"249,1530002.95100,521922.24500,99.85000,AXLE ■
250,1530006.67800,521982.23700,102.17700,IRC 1/2 IL"

@ Second iteration: Substring stored in 'points.'
"249,1530002.95100,521922.24500,99.85000,AXLE"

@ Second iteration: Remaining string stored in 'csv.'
"250,1530006.67800,521982.23700,102.17700,IRC 1/2 IL"

@ Third iteration: POS 0 ==, end WHILE loop

@ Output: Error!
@ Last string is empty.
{
"248,1529945.48000,521921.77300,100.60300,IRC 5/8 IL"
"249,1530002.95100,521922.24500,99.85000,AXLE"
"" }

@ Desired output.
{
"248,1529945.48000,521921.77300,100.60300,IRC 5/8 IL"
"249,1530002.95100,521922.24500,99.85000,AXLE"
"250,1530006.67800,521982.23700,102.17700,IRC 1/2 IL"
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 48GX Indefinite Loops - MNH - 03-28-2022, 01:11 AM
RE: HP 48GX Indefinite Loops - MNH - 04-02-2022 02:15 PM
RE: HP 48GX Indefinite Loops - DavidM - 03-28-2022, 04:11 AM
RE: HP 48GX Indefinite Loops - DavidM - 03-29-2022, 12:30 PM
RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 01:59 AM
RE: HP 48GX Indefinite Loops - DavidM - 04-03-2022, 10:58 AM
RE: HP 48GX Indefinite Loops - DavidM - 04-03-2022, 11:39 AM
RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 05:39 PM
RE: HP 48GX Indefinite Loops - ttw - 03-30-2022, 01:02 AM
RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 12:57 PM
RE: HP 48GX Indefinite Loops - MNH - 04-03-2022, 04:25 PM



User(s) browsing this thread: 1 Guest(s)