Sample program using STL Container (MAP)


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]

Posted by Robert G Laurin on August 14, 2018 at 12:27:33:

Here's a sample STL Container program that writes 100 Random records to a STL Container and reads it back in order. Remember that there will be duplicate keys, so from 100 expect 60+ records back.

Enjoy!!


! //IB//Src(STL-RND.IBS) Obj(STL-RND,OBJ) Opt(L)

!================ Declaratives =================================================

Length 8.0 & Local IND, COUNT
Length 8 & Local KEY$
Length 80 & Local DATA$

mySTL: MAP

!================ Executables ==================================================

Clear

Print (0) (CS);(ET)

DO
LET IND = RND(IND) * 100 ! Generate Random Number 0-99
KEY$ = STR(IND)
COUNT = COUNT + 1
DATA$ = STR(IND) + STR(COUNT) ! Data is Key + Order of which is was generated
stlSet(mySTL, KEY$, DATA$) ! Write in Random Order
Loop While COUNT < 100 ! Do it a hundred times

stlBegin(mySTL) ! STL POS=BOF

Let COUNT = 0
Do
DATA$ = stlRead(mySTL) ! Get Data from STL
Let COUNT = COUNT + 1
Print COUNT;':';DATA$
stlNext(mySTL) Excp=Excp.EOF ! Advance STL Pointer Excp=EOF
Loop

Excp.EOF:
Print 'End of File, EXCP=';EXCP;' Records:';COUNT
Let COUNT = stlSize(mySTL) ! No of Records in STL
Print 'Size of Container:';COUNT
stlClear(mySTL) ! Clear STL Container
Wait
End




Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

What is the name of the main Signature System's Product?  

Comments:

Optional Link URL:
Link Title:
Optional Image URL:

You may attach up to 5 files to your followup (see below):





Each file can be a maximum of 1MB in length Uploaded files will be purged from the server on a regular basis.


[ Follow Ups ] [ Post Followup ] [ Signature.net Forum ]