Posted: 4th Nov 2023 10:09
I would like to use gettextinput to let users name a picture to save. I use starttextinput (the initial string doesn't seem to work either). I get the box and type in it and press enter. Everything seems fine but the string doesn't save a file name to the image. I am not sure if I have to change the input to be able to use it. I was adding the titlepic$+last$ together but it only names the file .png with no inputtext. I am using agk classic 12-12-22.
Posted: 4th Nov 2023 12:57
can't say i've much experience with that command but:
+ Code Snippet
// Project: NamePic 
// Created: 2023-11-04

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "NamePic" )
SetWindowSize( 640,360, 0 )
SetWindowAllowResize( 1 )

// set display properties
SetVirtualResolution( 640,360 )
SetOrientationAllowed( 1, 1, 1, 1 ) // portrait, portrait2, landscape, landscape2
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )

CenterWindow()

do
	If GetPointerPressed()
		ThisFile$ = ChooseRawFile("*.jpg;*.png",1)
		If ThisFile$ <> ""
			FType$ = GetStringToken(ThisFile$,".",2)
			NamePic(LoadImage("raw:"+ThisFile$), FType$)
		EndIf
    EndIf

    Print( "Click to Load Image and Rename" )
    Sync()
loop

Function NamePic(img,ft$)
	ThisSPR = CreateSprite(img)
	SetSpriteSize(ThisSPR,-1,100)
	SetSpritePositionByOffset(ThisSPR,GetDeviceWidth()/2.0,250)
	Sync()
	StartTextInput()
	Repeat
		Print("[Enter] Image Name")
		Sync()
	Until GetTextInputCompleted()
	DeleteSprite(ThisSPR)
	If GetTextInputCancelled() = 0
		SaveImage(img, GetTextInput()+"."+ft$)
		OpenBrowser(GetWritePath()+"/media")
	EndIf
EndFunction

Function CenterWindow()
	X = GetMaxDeviceWidth()/2.0 - GetWindowWidth()/2.0
	Y = GetMaxDeviceHeight()/2.0 - GetWindowHeight()/2.0
	SetWindowPosition( X,Y)
EndFunction


meanwhile, i didn't see a RenameFile() command so it wouldn't have to make a copy of the file but i expect MadBit's FileExplore has one.

short on time ATM so i'll have to leave this here for now. hope that helps
Posted: 4th Nov 2023 20:22
Thank you that fixed it. To make it clear this is what I use.

startTextInput()
repeat
sync()
until GetTextInputComplete()
SaveImage(2, GetTextInput()+".png")
deleteImage(2)

What I had problems with was I didn't use a repeat until loop and no sync(). Also I didn't know you can just GetTextInput() to get the typed text without using a string$. Thank you again Nomad for the help.