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" } |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)