1. #1
    New Member Follow User Gallery
    Join Date
    Apr 2019

    Default Question: how to read string from file and extract integer

    I want to do this thing, but not really understand how to do it on Zscripting, hope on your support guys, thanks

    I want to read .txt file that have this looking:

    model.obj 20
    model2.obj 35
    model3.obj 50
    model1000.obj 20

    here model.obj it's name , and integer it's ZRemesher:"Target polygon count"

    I check forum and find how to do reading from txt file and importing this files, and apply ZRemesher, but i can't understand how here working function working with string.
    So question: how to extract from each line this integers (20,35,50,....,20) and setup them as Target polygon count parameter for each model

    Thanks for reading!

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004


    You need to extract the substrings so you have the file name and the target count as separate strings. Then if the target count string is assigned to a number variable it is automatically cast as a number:

    [IButton,ReadFromFile,"Read from a text file",
    //create memory block from the file
    //read a line into a string variable
    //find "obj"
    [If,endPath > -1,//if "obj" found
    //extract file path string
    //extract target polys string
    [ISet,Tool:Geometry:Target Polygons Count,lTargetPolys]
    [IUpdate,1,1]//update the UI
    [If,gOffset >= [MemGetSize,ZB_TextInputMem],[LoopExit]]
    [MemDelete,ZB_TextInputMem] //all done, delete memblock

  3. #3
    New Member Follow User Gallery
    Join Date
    Apr 2019


    When i write this question i hope, that you Marcus will see it, thanks for your answer,help and time!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts